[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Toon-members] TooN/test vec_test.cc
From: |
Edward Rosten |
Subject: |
[Toon-members] TooN/test vec_test.cc |
Date: |
Tue, 13 Jan 2009 12:25:07 +0000 |
CVSROOT: /cvsroot/toon
Module name: TooN
Changes by: Edward Rosten <edrosten> 09/01/13 12:25:07
Modified files:
test : vec_test.cc
Log message:
Better testing.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/TooN/test/vec_test.cc?cvsroot=toon&r1=1.1&r2=1.2
Patches:
Index: vec_test.cc
===================================================================
RCS file: /cvsroot/toon/TooN/test/vec_test.cc,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- vec_test.cc 13 Jan 2009 10:44:45 -0000 1.1
+++ vec_test.cc 13 Jan 2009 12:25:07 -0000 1.2
@@ -1,26 +1,50 @@
#define TOON_TEST_INTERNALS
#include <TooN/TooN.h>
+#include <string>
using namespace TooN;
using namespace std;
int lineno;
+template<class A, class B> struct no_duplicates
+{
+ typedef B type;
+};
+
+
+template<class A> struct no_duplicates<A, A>
+{
+ typedef class IgnoreMe{} type;
+};
+
+
#define TRY lineno = __LINE__; try{
+#define EXPECT_CATCH(X, Y) \
+catch(no_duplicates<TooN::Internal::X, TooN::Internal::Y>::type e)\
+{\
+ cerr << "Test FAILED on line " << lineno << " from " << func_lineno << ".
Expected " << #X << ", got " << #Y << "." << endl;\
+}\
+
#define EXPECT(X) \
- cerr << "Test FAILED on line " << lineno << ". Expected " << #X << ",
got nothing." << endl;\
+ if(#X == string("NoError"))\
+ cerr << "Test OK on line " << lineno << " from " << func_lineno
<< endl;\
+ else\
+ cerr << "Test FAILED on line " << lineno << " from " <<
func_lineno << ". Expected " << #X << ", got nothing." << endl;\
}\
catch(TooN::Internal::X e)\
{\
- cerr << "Test OK on line " << lineno << endl;\
-}\
-catch(...)\
-{\
- cerr << "Test FAILED on line " << lineno << ". Expected " << #X << ", got
unknown error." << endl;\
+ cerr << "Test OK on line " << lineno << " from " << func_lineno << endl;\
}\
+EXPECT_CATCH(X, BadIndex)\
+EXPECT_CATCH(X, SliceError)\
+EXPECT_CATCH(X, StaticSliceError)\
+EXPECT_CATCH(X, SizeMismatch)\
+EXPECT_CATCH(X, StaticSizeMismatch)\
-void test_bad_static_static_slices()
+#define test_bad_static_slices(...) test_bad_static_slices_(__LINE__ ,
__VA_ARGS__)
+template<class C> void test_bad_static_slices_(int func_lineno, C v)
{
TRY{
Vector<2> v;
@@ -41,54 +65,43 @@
EXPECT(StaticSliceError);
}
-void test_bad_static_dynamic_slices()
+#define test_bad_dynamic_slices(...) test_bad_dynamic_slices_(__LINE__,
__VA_ARGS__)
+template<class C> void test_bad_dynamic_slices_(int func_lineno, C v)
{
TRY{
- Vector<2> v;
v.slice(0,3);
}
EXPECT(SliceError);
TRY{
- Vector<2> v;
v.slice(2,2);
}
EXPECT(SliceError);
TRY{
- Vector<2> v;
v.slice(-1,1);
}
EXPECT(SliceError);
}
-void test_bad_dynamic_static_slices()
-{
- TRY{
- Vector<> v(2);
- v.slice<0, 3>();
- }
- EXPECT(SliceError);
- TRY{
- Vector<> v(2);
- v.slice<2, 2>();
- }
- EXPECT(SliceError);
+int main()
+{
+ test_bad_static_slices(Vector<2>());
+ test_bad_dynamic_slices(Vector<2>());
- TRY{
- Vector<> v(2);
- v.slice<-1, 1>();
- }
- EXPECT(StaticSliceError);
-}
+ test_bad_static_slices(Vector<4>().slice<0,2>());
+ test_bad_dynamic_slices(Vector<4>().slice<0,2>());
+ test_bad_static_slices(Vector<4>().slice(0,2));
+ test_bad_dynamic_slices(Vector<4>().slice(0,2));
+ test_bad_static_slices(Vector<>(2));
+ test_bad_dynamic_slices(Vector<>(2));
+ test_bad_static_slices(Vector<>(4).slice<0,2>());
+ test_bad_dynamic_slices(Vector<>(4).slice<0,2>());
-int main()
-{
- test_bad_static_static_slices();
- test_bad_static_dynamic_slices();
- test_bad_dynamic_static_slices();
+ test_bad_static_slices(Vector<>(4).slice(0,2));
+ test_bad_dynamic_slices(Vector<>(4).slice(0,2));
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Toon-members] TooN/test vec_test.cc,
Edward Rosten <=