1 | |
---|
2 | #ifndef SWWREADERTEST_H |
---|
3 | #define SWWREADERTEST_H |
---|
4 | |
---|
5 | #include <cppunit/extensions/HelperMacros.h> |
---|
6 | #include <cppunit/SourceLine.h> |
---|
7 | #include <cppunit/TestAssert.h> |
---|
8 | #include <SWWReader.h> |
---|
9 | #include <osg/Geometry> |
---|
10 | #include <stdio.h> |
---|
11 | |
---|
12 | // allowable distance between two Vectors to be considered equal |
---|
13 | #define TOLERANCE 0.001 |
---|
14 | |
---|
15 | |
---|
16 | // custom assertion testing equivalence of two OSG Vec3 |
---|
17 | void checkVec3Equal( osg::Vec3 expected, osg::Vec3 actual, CppUnit::SourceLine sourceLine ) |
---|
18 | { |
---|
19 | float distance = (expected-actual).length(); |
---|
20 | if (distance < TOLERANCE) |
---|
21 | return; |
---|
22 | |
---|
23 | // test failed |
---|
24 | char s_expected[20], s_actual[20]; |
---|
25 | sprintf(s_expected, "%10.3f", expected); |
---|
26 | sprintf(s_actual, "%10.3f", actual); |
---|
27 | ::CppUnit::Asserter::failNotEqual( s_expected, s_actual, sourceLine ); |
---|
28 | } |
---|
29 | |
---|
30 | // macro shortcut to above assertion |
---|
31 | #define CPPUNIT_ASSERT_VEC3_EQUAL( expected, actual ) \ |
---|
32 | checkVec3Equal( expected, actual, CPPUNIT_SOURCELINE() ) |
---|
33 | |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | class SWWReaderTest : public CppUnit::TestFixture |
---|
38 | { |
---|
39 | CPPUNIT_TEST_SUITE( SWWReaderTest ); |
---|
40 | CPPUNIT_TEST( testValid ); |
---|
41 | CPPUNIT_TEST( testNumberOfVertices ); |
---|
42 | CPPUNIT_TEST( testTime ); |
---|
43 | CPPUNIT_TEST( testBedslopeVertexArray ); |
---|
44 | CPPUNIT_TEST( testBedslopeIndexArray ); |
---|
45 | CPPUNIT_TEST( testBedslopeNormalArray ); |
---|
46 | CPPUNIT_TEST( testConnectivity ); |
---|
47 | CPPUNIT_TEST_SUITE_END(); |
---|
48 | |
---|
49 | public: |
---|
50 | void setUp(); |
---|
51 | void tearDown(); |
---|
52 | |
---|
53 | void testValid(); |
---|
54 | void testNumberOfVertices(); |
---|
55 | void testTime(); |
---|
56 | void testBedslopeVertexArray(); |
---|
57 | void testBedslopeIndexArray(); |
---|
58 | void testBedslopeNormalArray(); |
---|
59 | void testConnectivity(); |
---|
60 | |
---|
61 | |
---|
62 | private: |
---|
63 | SWWReader* _sww; |
---|
64 | }; |
---|
65 | |
---|
66 | #endif |
---|