diff options
author | Campbell Barton <ideasman42@gmail.com> | 2016-01-19 12:44:57 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2016-01-19 12:44:57 +0300 |
commit | dea38d78c4c4dc965a622be6e676158686a076e2 (patch) | |
tree | 7de09ad131feec1d7b98dabb5b4457fd0cb2b913 | |
parent | df465368baed5cc7e510c4f26ceef728beeb45ad (diff) |
GTests: were using C++11 feature
-rw-r--r-- | tests/gtests/blenlib/BLI_array_utils_test.cc | 52 | ||||
-rw-r--r-- | tests/gtests/testing/testing.h | 7 |
2 files changed, 33 insertions, 26 deletions
diff --git a/tests/gtests/blenlib/BLI_array_utils_test.cc b/tests/gtests/blenlib/BLI_array_utils_test.cc index 596c3976819..e532419691a 100644 --- a/tests/gtests/blenlib/BLI_array_utils_test.cc +++ b/tests/gtests/blenlib/BLI_array_utils_test.cc @@ -34,10 +34,10 @@ TEST(array_utils, ReverseString4) TEST(array_utils, ReverseInt4) { - const std::vector<int> data_cmp = {3, 2, 1, 0}; - std::vector<int> data = {0, 1, 2, 3}; - BLI_array_reverse(data.data(), data.size()); - EXPECT_EQ(data, data_cmp); + const int data_cmp[] = {3, 2, 1, 0}; + int data[] = {0, 1, 2, 3}; + BLI_array_reverse(data, ARRAY_SIZE(data)); + EXPECT_EQ_ARRAY(data_cmp, data, ARRAY_SIZE(data)); } /* BLI_array_findindex */ @@ -72,49 +72,49 @@ TEST(array_utils, FindIndexInt4) } /* BLI_array_binary_and */ -#define BINARY_AND_TEST(data_cmp, data_a, data_b, data_combine) \ +#define BINARY_AND_TEST(data_cmp, data_a, data_b, data_combine, length) \ { \ - data_combine.resize(data_cmp.size()); \ - BLI_array_binary_and(data_combine.data(), data_a.data(), data_b.data(), data_cmp.size()); \ - EXPECT_EQ(data_combine, data_cmp); \ + BLI_array_binary_and(data_combine, data_a, data_b, length); \ + EXPECT_EQ_ARRAY(data_cmp, data_combine, length); \ } ((void)0) TEST(array_utils, BinaryAndInt4Zero) { - std::vector<int> data_a = {0, 1, 0, 1}, data_b = {1, 0, 1, 0}, data_cmp = {0, 0, 0, 0}; - std::vector<int> data_combine; - BINARY_AND_TEST(data_cmp, data_a, data_b, data_combine); + const int data_cmp[] = {0, 0, 0, 0}; + int data_a[] = {0, 1, 0, 1}, data_b[] = {1, 0, 1, 0}; + int data_combine[ARRAY_SIZE(data_cmp)]; + BINARY_AND_TEST(data_cmp, data_a, data_b, data_combine, ARRAY_SIZE(data_cmp)); } TEST(array_utils, BinaryAndInt4Mix) { - std::vector<int> data_a = {1, 1, 1, 1}, data_b = {1, 0, 1, 0}, data_cmp = {1, 0, 1, 0}; - std::vector<int> data_combine; - BINARY_AND_TEST(data_cmp, data_a, data_b, data_combine); + const int data_cmp[] = {1, 0, 1, 0}; + int data_a[] = {1, 1, 1, 1}, data_b[] = {1, 0, 1, 0}; + int data_combine[ARRAY_SIZE(data_cmp)]; + BINARY_AND_TEST(data_cmp, data_a, data_b, data_combine, ARRAY_SIZE(data_cmp)); } #undef BINARY_AND_TEST /* BLI_array_binary_or */ -#define BINARY_OR_TEST(data_cmp, data_a, data_b, data_combine) \ - { \ - data_combine.resize(data_cmp.size()); \ - BLI_array_binary_or(data_combine.data(), data_a.data(), data_b.data(), data_cmp.size()); \ - EXPECT_EQ(data_combine, data_cmp); \ - } ((void)0) +#define BINARY_OR_TEST(data_cmp, data_a, data_b, data_combine, length) \ +{ \ + BLI_array_binary_or(data_combine, data_a, data_b, length); \ + EXPECT_EQ_ARRAY(data_combine, data_cmp, length); \ +} ((void)0) TEST(array_utils, BinaryOrInt4Alternate) { - std::vector<int> data_a = {0, 1, 0, 1}, data_b = {1, 0, 1, 0}, data_cmp = {1, 1, 1, 1}; - std::vector<int> data_combine; - BINARY_OR_TEST(data_cmp, data_a, data_b, data_combine); + int data_a[] = {0, 1, 0, 1}, data_b[] = {1, 0, 1, 0}, data_cmp[] = {1, 1, 1, 1}; + int data_combine[ARRAY_SIZE(data_cmp)]; + BINARY_OR_TEST(data_cmp, data_a, data_b, data_combine, ARRAY_SIZE(data_cmp)); } TEST(array_utils, BinaryOrInt4Mix) { - std::vector<int> data_a = {1, 1, 0, 0}, data_b = {0, 0, 1, 0}, data_cmp = {1, 1, 1, 0}; - std::vector<int> data_combine; - BINARY_OR_TEST(data_cmp, data_a, data_b, data_combine); + int data_a[] = {1, 1, 0, 0}, data_b[] = {0, 0, 1, 0}, data_cmp[] = {1, 1, 1, 0}; + int data_combine[ARRAY_SIZE(data_cmp)]; + BINARY_OR_TEST(data_cmp, data_a, data_b, data_combine, ARRAY_SIZE(data_cmp)); } #undef BINARY_OR_TEST diff --git a/tests/gtests/testing/testing.h b/tests/gtests/testing/testing.h index 9083654f1d5..b0a6379e5c0 100644 --- a/tests/gtests/testing/testing.h +++ b/tests/gtests/testing/testing.h @@ -75,4 +75,11 @@ double CosinusBetweenMatrices(const TMat &a, const TMat &b) { } #endif +template <typename T> +inline void EXPECT_EQ_ARRAY(const T *expected, T *actual, const size_t N) { + for(size_t i = 0; i < N; ++i) { + EXPECT_EQ(expected[i], actual[i]); + } +} + #endif // __BLENDER_TESTING_H__ |