00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #ifndef WDENDROGRAM_TEST_H
00026 #define WDENDROGRAM_TEST_H
00027
00028 #include <cxxtest/TestSuite.h>
00029
00030 #include "../../WLogger.h"
00031 #include "../WDendrogram.h"
00032
00033
00034
00035
00036 class WDendrogramTest : public CxxTest::TestSuite
00037 {
00038 public:
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054 void testStringCreation( void )
00055 {
00056 WDendrogram d( 5 );
00057 d.merge( 0, 1, 0.8 );
00058 d.merge( 5, 2, 0.4 );
00059 d.merge( 3, 4, 0.60 );
00060 d.merge( 6, 7, 0.32 );
00061 std::stringstream ss;
00062 ss << "(0, (0,))" << std::endl;
00063 ss << "(0, (1,))" << std::endl;
00064 ss << "(0, (2,))" << std::endl;
00065 ss << "(0, (3,))" << std::endl;
00066 ss << "(0, (4,))" << std::endl;
00067 ss << "(1, (0, 1), (0, 1), 0.8)" << std::endl;
00068 ss << "(2, (2, 0, 1), (2, 5), 0.4)" << std::endl;
00069 ss << "(1, (3, 4), (3, 4), 0.6)" << std::endl;
00070 ss << "(3, (2, 0, 1, 3, 4), (6, 7), 0.32)" << std::endl;
00071 if( ss.str() != d.toString() )
00072 {
00073 std::cout << "Expected:" << std::endl << ss.str();
00074 std::cout << "But got:" << std::endl << d.toString();
00075 TS_FAIL( "Invalid dendrogram to string generation" );
00076 }
00077 }
00078
00079
00080
00081
00082 void setUp( void )
00083 {
00084 WLogger::startup();
00085 }
00086 };
00087
00088 #endif // WDENDROGRAM_TEST_H