Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-03-20 16:05:30 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-03-20 16:14:56 +0300
commitf39a4a4a4e48acb1afd96101796d72ea060cf6f5 (patch)
tree57a99b8359e620e9dbb2fd1490b964c9600d78ed /tests/gtests/testing
parentde535fdd52afd89208d60ec8206a1a20e6b316fd (diff)
Cleanup: More C++ like nature for word split test
While it looks more longer, but also contains more comments about what's going on. Surely, this function almost never breaks and investing time into maintaining its tests is not that important, but we should have a good, clean, understandable tests so they act as a nice example of how they are to be written. Especially important to show correct language usage, without old school macros magic. Doing this at a lunch breaks, so will be series of some updates in the area.
Diffstat (limited to 'tests/gtests/testing')
-rw-r--r--tests/gtests/testing/testing.h21
1 files changed, 17 insertions, 4 deletions
diff --git a/tests/gtests/testing/testing.h b/tests/gtests/testing/testing.h
index d5a7b076970..9efdbe22557 100644
--- a/tests/gtests/testing/testing.h
+++ b/tests/gtests/testing/testing.h
@@ -1,6 +1,8 @@
#ifndef __BLENDER_TESTING_H__
#define __BLENDER_TESTING_H__
+#include <vector>
+
#include "glog/logging.h"
#include "gflags/gflags.h"
#include "gtest/gtest.h"
@@ -99,17 +101,28 @@ 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) {
+inline void EXPECT_EQ_VECTOR(const std::vector<T>& expected, const std::vector<T>& actual) {
+ EXPECT_EQ(expected.size(), actual.size());
+ if (expected.size() == actual.size()) {
+ for(size_t i = 0; i < expected.size(); ++i) {
+ EXPECT_EQ(expected[i], actual[i]) << "Element mismatch at index " << i;
+ }
+ }
+}
+
+template <typename T>
+inline void EXPECT_EQ_ARRAY(const T *expected, const T *actual, const size_t N) {
for(size_t i = 0; i < N; ++i) {
- EXPECT_EQ(expected[i], actual[i]);
+ EXPECT_EQ(expected[i], actual[i]) << "Element mismatch at index " << i;
}
}
template <typename T>
-inline void EXPECT_EQ_ARRAY_ND(const T *expected, T *actual, const size_t N, const size_t D) {
+inline void EXPECT_EQ_ARRAY_ND(const T *expected, const T *actual, const size_t N, const size_t D) {
for(size_t i = 0; i < N; ++i) {
for(size_t j = 0; j < D; ++j) {
- EXPECT_EQ(expected[i][j], actual[i][j]);
+ EXPECT_EQ(expected[i][j], actual[i][j])
+ << "Element mismatch at index " << i << ", component index " << j;
}
}
}