-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[test, TAT.hpp] Deprecate old test code, and add new tests using gtest.
- Loading branch information
Showing
53 changed files
with
106 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ | |
!/include | ||
!/lazy_graph | ||
!/python | ||
!/test | ||
!/tests | ||
!/tetragono | ||
!/tetraku | ||
!/tetraux | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#include <TAT/TAT.hpp> | ||
#include <gtest/gtest.h> | ||
|
||
TEST(test_const_integral, basic_usage_dynamic) { | ||
const auto value = TAT::to_const_integral_0_to_16(17); | ||
std::visit( | ||
[](const auto& v) { | ||
ASSERT_EQ(v.value(), 17); | ||
ASSERT_TRUE(v.is_dynamic); | ||
}, | ||
value); | ||
} | ||
|
||
TEST(test_const_integral, basic_usage_static) { | ||
const auto value = TAT::to_const_integral_0_to_16(13); | ||
std::visit( | ||
[](const auto& v) { | ||
ASSERT_EQ(v.value(), 13); | ||
ASSERT_TRUE(v.is_static); | ||
}, | ||
value); | ||
} | ||
|
||
TEST(test_const_integral, return_value) { | ||
const auto value = TAT::to_const_integral_0_to_16(13); | ||
auto v = std::visit( | ||
[](const auto& v) -> int { | ||
return v.value(); | ||
}, | ||
value); | ||
ASSERT_EQ(v, 13); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
#include <TAT/TAT.hpp> | ||
#include <gtest/gtest.h> | ||
|
||
TEST(test_multidimension_span, create_object_and_basic_attribute) { | ||
auto data = std::vector<int>(24); | ||
auto span = TAT::mdspan<int>(data.data(), {2, 3, 4}); | ||
ASSERT_EQ(span.rank(), 3); | ||
ASSERT_EQ(span.size(), 24); | ||
ASSERT_EQ(span.dimensions(0), 2); | ||
ASSERT_EQ(span.dimensions(1), 3); | ||
ASSERT_EQ(span.dimensions(2), 4); | ||
ASSERT_EQ(span.leadings(2), 1); | ||
ASSERT_EQ(span.leadings(1), 4); | ||
ASSERT_EQ(span.leadings(0), 12); | ||
ASSERT_EQ(span.dimensions()[0], 2); | ||
ASSERT_EQ(span.dimensions()[1], 3); | ||
ASSERT_EQ(span.dimensions()[2], 4); | ||
ASSERT_EQ(span.leadings()[2], 1); | ||
ASSERT_EQ(span.leadings()[1], 4); | ||
ASSERT_EQ(span.leadings()[0], 12); | ||
ASSERT_EQ(span.data(), data.data()); | ||
} | ||
|
||
TEST(test_multidimension_span, set_data_later) { | ||
auto span = TAT::mdspan<int>(nullptr, {2, 3, 4}); | ||
auto data = std::vector<int>(24); | ||
span.set_data(data.data()); | ||
ASSERT_EQ(span.data(), data.data()); | ||
const auto const_span = TAT::mdspan<int>(data.data(), {2, 3, 4}); | ||
ASSERT_EQ(const_span.data(), data.data()); | ||
} | ||
|
||
TEST(test_multidimension_span, get_set_item) { | ||
auto data = std::vector<int>(24); | ||
auto span = TAT::mdspan<int>(data.data(), {2, 3, 4}); | ||
span.at({0, 0, 0}) = 2333; | ||
ASSERT_EQ(data[0], 2333); | ||
data[13] = 666; | ||
ASSERT_EQ(span.at({1, 0, 1}), 666); | ||
} | ||
|
||
TEST(test_multidimension_span, get_item_const) { | ||
auto data = std::vector<int>(24); | ||
const auto span = TAT::mdspan<int>(data.data(), {2, 3, 4}); | ||
data[13] = 666; | ||
ASSERT_EQ(span.at({1, 0, 1}), 666); | ||
} | ||
|
||
TEST(test_multidimension_span, iterate) { | ||
auto data = std::vector<int>{0, 1, 2, 3, 4, 5, 6, 7}; | ||
const auto span = TAT::mdspan<int>(data.data(), {2, 2, 2}); | ||
auto v = 0; | ||
for (auto i = span.begin(); i != span.end(); ++i) { | ||
ASSERT_EQ(*i, v++); | ||
} | ||
} | ||
|
||
TEST(test_multidimension_span, iterate_on_empty) { | ||
const auto span = TAT::mdspan<int>(nullptr, {2, 0, 2}); | ||
for (auto i = span.begin(); i != span.end(); ++i) { | ||
} | ||
} |