void TestScanner() { TestBegin("Scanner"); Scanner s; Token tok; s.From( " \t\n" " \ta.b = 1;\n" " > < == <= >= != =~ && || . , : ; [ ] ( ) { } = + += -= *\r\n" "123 0123 0xafbDDdd00\r" "01233999 00. 1E9 1E-9 1e+9 1.1e900\n" "\'fasdfa/#@$@@@\\n\'\n" "\"fjalksdfjal#@$@#$@#\\n\"\n" "_abcd\r" ); while( s.NextToken(&tok) && tok.Rep() != TOK_eof ){ tok.Print(); std::putchar('\n'); } TestEnd(); }
void test_xml_parser::Run() { TestBegin(); XMLParser myparser((char *) "configuration.xml"); std::string value; bool status = false; try { mTestsRun++; if(myparser.parseXML() == ERROR) { std::cout << "failed to parse the xml " << std::endl; return; } else mTestsPassed++; // myparser.PrintMap(); } catch(...) { std::cout << "caught error" <<std::endl; } mTestsRun++; if (myparser.find("/configuration/nasdaq/name").compare("Nasdaq") == 0) status = true; else { std::cout << "could not find /configuration/nasdaq/name" << std::endl; } if(status) // if we passed part one continue to part 2. { if(myparser.find("/configuration/nasdaq/sources/database/host").compare("mm1.local") == 0 ) status = true; else { std::cout << "could not find /configuration/nasdaq/sources/database/host" << std::endl; } } /* if part one or part two failed the test failed else we passed*/ if(status) mTestsPassed++; TestEnd(); return; }
void TestRTTI() { TestBegin("RTTI"); D1 d1; D2 d2; const D1 cd1; D1 *pd1 = &d1; D2 *pd2 = &d2; D1 **ppd1 = &pd1; // this is valid =,= bug? const D1* cpd1 = pd1; D2* const pcd2 = pd2; const D2* const cpcd2 = pd2; std::printf("d1 %d\n", isa<Base>(d1)); // 0 std::printf("cd1 %d\n", isa<D2>(cd1)); // 0 std::printf("pd1 %d\n", isa<D1>(pd1)); // 1 std::printf("cpd1 %d\n", isa<D2>(cpd1)); // 0 std::printf("pcd2 %d\n", isa<D2>(pcd2)); // 1 std::printf("cpcd2 %d\n", isa<D2>(cpcd2)); // 1 std::printf("ppd1 %d\n", isa<D1>(ppd1)); // 1 std::putchar('\n'); Base *b = pd1; pd1 = dyn_cast<D1>(b); std::printf("pd1 %p\n", pd1); // 0x??? pd2 = dyn_cast<D2>(b); std::printf("pd2 %p\n", pd2); // 0 std::putchar('\n'); std::printf("d1.ID() = %d, d2.ID() = %d\n", d1.ID(), d2.ID()); Base *b1 = new D1; b1->Destroy(); TestEnd(); }