void Test1() { // 一层 GeneralList gl("(a,b)"); gl.Print(); cout<<"Depth:"<<gl.Depth()<<endl; // 两层 GeneralList g2("(a,b,(c,d))"); g2.Print(); cout<<"Depth:"<<g2.Depth()<<endl; // 三层 + 有空格的 GeneralList g3("(a, b,(c,d),(e,(f),h))"); g3.Print(); cout<<"Depth:"<<g3.Depth()<<endl; cout<<"Size:"<<g3.Size()<<endl; // 多层空表嵌套 GeneralList g4("(((),()))"); g4.Print(); cout<<"Depth:"<<g4.Depth()<<endl; GeneralList g5(g3); g5.Print(); GeneralList g6 = g5; g6.Print(); }
void test() { g1(X1()); g2(X2()); // expected-warning{{C++98 requires an accessible copy constructor for class 'X2' when binding a reference to a temporary; was private}} g3(X3()); // expected-warning{{no viable constructor copying parameter of type 'X3'}} g4(X4<int>()); g5(X5()); // Generates a warning in the default argument. }
bool sanity() { GameState g0(5, 7, 7); // Not a valid game state GameState g1(1, 2, 254); // Finish in 1 round GameState g2(2, 3, 254); // ... in 2 rounds GameState g3(3, 4, 254); // ... in 3 rounds GameState g4(4, 5, 254); // GameState g5(4, 9, 254); // These come from a (slower) python implementation GameState g6(8, 11, 254); GameState g7(12, 19, 254); GameState g8(8, 35, 254); GameState g9(1, 4, 6); // From webpage, known to finish in 15 minutes = at round 2 if (explore_game(g0)!=0) return false; // Verify that we get the expected number if (explore_game(g1)!=1) return false; // of rounds for given input states if (explore_game(g2)!=2) return false; // if (explore_game(g3)!=3) return false; // report an error if not if (explore_game(g4)!=4) return false; if (explore_game(g5)!=5) return false; if (explore_game(g6)!=6) return false; if (explore_game(g7)!=7) return false; if (explore_game(g8)!=8) return false; if (explore_game(g9)!=2) return false; return true; }
int main (void) { struct s g6_s = { 106 }; start (1, 0); g1 (tmp); start (2, 0); g2 (&tmp); start (3, 0); g3 (&tmp); start (4, 0); g4 (&tmp); start (5, 0); g5 (tmp); start (6, &g6_s); g6 (tmp); start (7, 0); g7 (tmp); start (8, 0); g8 (&tmp); start (9, 0); g9 (&tmp); return 0; }
/* Gauge32( void); Gauge32( const unsigned long i); Gauge32 ( const Gauge32 &g); ~Gauge32(); SmiUINT32 get_syntax(); SnmpSyntax *clone() const; Gauge32& operator=( const Gauge32 &uli); Gauge32& operator=( const unsigned long i); operator unsigned long(); SnmpSyntax& operator=( SnmpSyntax &val); -- What is a Gauge? According to RFC 1155 section: 3.2.3.4 This application-wide type represents a non-negative integer which may increase or decrease, but which latches at a maximum value of 2^32-1 (4294967295 dec) for gauges. */ static void TestGuage (void) { #if !defined (ACE_WIN32) long l = LONG_MAX, nl = LONG_MIN; // limits.h unsigned long ul = ULONG_MAX, def = 0; int i = INT_MAX, ni = INT_MIN; unsigned int ui = UINT_MAX; unsigned short us = 10; short si = static_cast<short> (65535); // constructors Gauge32 g1; ACE_ASSERT(g1 == def); Gauge32 g2(l); ACE_ASSERT(g2 == static_cast<unsigned long> (l)); Gauge32 g3(nl); ACE_ASSERT(g3 == static_cast<unsigned long> (nl)); Gauge32 g4(ul); ACE_ASSERT(g4 == ul); Gauge32 g5(i); ACE_ASSERT(g5 == static_cast<unsigned long> (i)); Gauge32 g6(ni); ACE_ASSERT(g6 == static_cast<unsigned long> (ni)); Gauge32 g7(ui); ACE_ASSERT(g7 == ui); Gauge32 *g8 = new Gauge32(g5); ACE_ASSERT(g8 != 0); delete g8; ACE_DEBUG ((LM_DEBUG, "(%P|%t) g1(\"\") [%u]\n", (unsigned long)g1)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) g2(\"%u\") [%u]\n", l, (unsigned long)g2)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) g3(\"%u\") [%u]\n", nl, (unsigned long)g3)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) g4(\"%u\") [%u]\n", ul, (unsigned long)g4)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) g5(\"%u\") [%u]\n", i, (unsigned long)g5)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) g6(\"%u\") [%u]\n", ni, (unsigned long)g6)); ACE_DEBUG ((LM_DEBUG, "(%P|%t) g7(\"%u\") [%u]\n", ui, (unsigned long)g7)); // assignent g1 = g2; // obj ACE_ASSERT(g1 == g2); g1 = g1; // self ACE_ASSERT(g1 == g1); g1 = def; // unsigned long ACE_ASSERT(g1 == def); g1 = us; // unsigned short ACE_ASSERT(g1 == static_cast<unsigned long> (us)); g1 = si; // unsigned short ACE_ASSERT(g1 == static_cast<unsigned long> (si)); #endif /*ACE_WIN32*/ }
int main () { g1(); g2(); g3(); if (rand) g4(); g5(); g6(); return 0; }
qreal MyWidget::g(qreal x, qreal y, qreal z) { switch (variant) { case 5: return g5(x, y, z); case 8: return g8(x, y, z); } return 0; }
int main1(void) { int i; /* Check vec_extract with a non constant element numbering */ for(i=0;i<10;i++) { if (f(a, i) != (i&0x3)) abort (); } /* Check vec_extract with a constant element numbering */ if (f0(a) != 0) abort (); if (f1(a) != 1) abort (); if (f2(a) != 2) abort (); if (f3(a) != 3) abort (); /* Check that vec_extract works with a constant element higher than the number of elements. */ if (f4(a) != 0) abort (); /* Check vec_extract with a non constant element numbering */ for(i=0;i<10;i++) { if (g(b, i) != (i&0x7)) abort (); } /* Check vec_extract with a constant element numbering */ if (g0(b) != 0) abort (); if (g1(b) != 1) abort (); if (g2(b) != 2) abort (); if (g3(b) != 3) abort (); if (g4(b) != 4) abort (); if (g5(b) != 5) abort (); if (g6(b) != 6) abort (); if (g7(b) != 7) abort (); /* Check that vec_extract works with a constant element higher than the number of elements. */ if (g8(b) != 0) abort (); return 0; }
int main() { A a; B b; C c; Gadget g1( a, b, c ); Gadget g2( b, c, a ); Gadget g3( a, b ); // uses a default-constructed C Gadget g4( a, c ); // uses a default-constructed B Gadget g5( c ); // uses a default-constructed A and B Gadget g6; // uses a default-constructed A, B and C // fails to compile: // Gadget gf1( a, a ); // duplicate type // Gadget gf2( a, b, 42 ); // invalid type }
int main(void) { /***************************** Natrual Syntax ********************************/ Base a; Base b; Base c; Derived aa; // test ordinary function functor<void( ) > g0(&test0); g0(); functor<double (double)> g1; g1 = &test1; assert(12.123 == g1(12.123)); // test member function functor<void (int)> g2(&Base::d); functor<int (int)> g3(&Base::static_b); functor<int (int, int, int, int, int, int, int, int, int)> g4(&Base::d9); functor<int (int)> g5(&Base::virtual_c); // operator = functor<int (int, int)> g6; g6 = &Derived::Derived_a2; functor<int (int)> g7(&Derived::virtual_c); // copy constructor functor<int (int)> g7_2; g7_2 = g7; functor<int (int)> g7_3(g7); // reference functor<int (int)> &g7_4 = g7; // pointer functor<int (int)> *g7_5 = &g7; g2(&a, 18); assert(18 == a.getBase()); assert(g3(29) == 29); assert(g4(&b, 1,2,3,4,5,6,7,8,9) == (1+2+3+4+5+6+7+8+9)); assert(g5(&c, 5) == 5); assert(g6(&aa, 5, 6) == 5+6); assert(g7(&aa, 6) == 10+6); assert(g7_2(&aa, 6) == 10+6); assert(g7_3(&aa, 6) == 10+6); assert(g7_4(&aa, 6) == 10+6); assert((*g7_5)(&aa, 6) == 10+6); /************************************* STL *************************************/ int myints[] = {32,71,12,45,26,80,53,33}; std::vector<int> myvector1(myints, myints+8); std::vector<int> myvector2(myints, myints+8); functor<bool (int, int)> functorCmp = &mycmp; std::sort(myvector1.begin(), myvector1.end()); std::sort(myvector2.begin(), myvector2.end(), functorCmp); assert(myvector1.size() == myvector2.size()); for (unsigned int i = 0; i < myvector1.size(); ++i) { assert(myvector1[i] == myvector2[i]); } /***************************** Performance Test ********************************/ // performanceTest (500000000); return 0; }
void entry_point(void) { int *p = f5(); g5(p); }
void display(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); gluLookAt(r*cos(c*du), h, r*sin(c*du), 0, 0, 0, 0, 3, 0); //head position;eye direction(0.0,0.0,0.0),original point;(0.0,1.0,0.0),head above direction¡£ //cylinder a(1, 15, 0, 90, 0, 0, 5, 0); //r,h,xangle yangle zangle, module position(xx yy zz) //sphere b(3, 100, 100, 0, 0, 0, 0, 2.5, 0); //r,xangle yangle zangle, module position(xx yy zz) //cube c(5, 10, 0, 0, 1, 1, 1); //length xangle yangle zangle, module position(xx yy zz) //rectangularpyramid d(4, 0, 0, 0, 0, 2, 0); //length xangle yangle zangle, module position(xx yy zz) //triangularpyramid f(2, 0, 0, 0, 8, 8, 8);//length xangle yangle zangle, module position(xx yy zz) //f.draw(); sphere sp(3, 100, 100, 0, 0, -2, 0, 8, 0); cylinder cy(3, 5, 0, 90, 0, -3, 9, -10); cube cu(3, 0, 0, 0, 0, 8, 10); triangularpyramid tr(2, 0, 0, 0, 0, -6, 8); rectangularpyramid rec(2, 0, 0, 0, 0, -6, -8); cylinder k1(0.3, 2, 90, 0, 0, 0, 0, 0); cylinder k2(0.3, 2, -90, 0, 0, 0, 0, 0); cylinder k3(0.3, 2, -45, 0, 0, 0, 0, 0); cylinder k4(0.3, 2.5, 45, 0, 0, 0, 0, 0); cylinder u1(0.3, 2, 90, 0, 0, 0, 0, 3); cylinder u2(0.3, 1.5, -90, 0, 0, 0, 0, 3); cylinder u3(0.3, 2, 0, 0, 0, 0, -1.8, 3); cylinder u4(0.3, 2, 90, 0, 0, 0, 0, 5); cylinder u5(0.3, 1.5, -90, 0, 0, 0, 0, 5); cylinder g1(0.3, 2, -90, 0, 0, 0, -0.5, 6.4); cylinder g2(0.3, 1.5, -90, 0, 0, 0, -0.5, 6.4); cylinder g3(0.3, 2, 0, 0, 0, 0, -0.3, 6.4); cylinder g4(0.3, 2, 0, 0, 0, 0, 1.3, 6.4); cylinder g5(0.3, 2, 90, 0, 0, 0, 0, 8.4); cylinder g6(0.3, 1.5, -90, 0, 0, 0, 0, 8.4); cylinder g7(0.3, 2, 0, 0, 0, 0, -1.8, 6.4); cylinder e1(0.3, 1.8, -90, 0, 0, 0, -0.2, 10); cylinder e2(0.3, 1.8, 90, 0, 0, 0, -0.2, 10); cylinder e3(0.3, 2, 0, 0, 0, 0, -0.3, 10); cylinder e4(0.3, 2, 0, 0, 0, 0, 1.3, 10); cylinder e5(0.3, 2, 0, 0, 0, 0, -1.8, 10); cylinder r1(0.3, 1.8, -90, 0, 0, 0, -0.2, 13.5); cylinder r2(0.3, 1.8, 90, 0, 0, 0, -0.2, 13.5); cylinder r3(0.3, 2, 0, 0, 0, 0, -0.3, 13.5); cylinder r4(0.3, 1.2, 0, 0, 0, 0, 1.3, 13.5); cylinder r5(0.3, 1.7, 60, 0, 0, 0, 1.3, 14.5); cylinder r6(0.3, 2.5, 45, 0, 0, 0, 0, 13.5); cylinder c1(0.3, 2, 90, 0, 0, 0, 0, -15); cylinder c2(0.3, 2, -90, 0, 0, 0, 0, -15); cylinder c3(0.3, 3, 0, 0, 0, 0, -1.8, -15); cylinder c4(0.3, 3, 0, 0, 0, 0, 1.8, -15); cylinder plus1(0.3,3.5, 0, 0, 0, 0, 0, -11); cylinder plus2(0.3, 4, 90, 0, 0, 0, 2, -9.2); cylinder plus3(0.3, 3.5, 0, 0, 0, 0, 0, -6); cylinder plus4(0.3, 4, 90, 0, 0, 0, 2, -4.2); cy.draw(); sp.draw(); cu.draw(); tr.draw(); rec.draw(); k1.draw(); k2.draw(); k3.draw(); k4.draw(); u1.draw(); u2.draw(); u3.draw(); u4.draw(); u5.draw(); g1.draw(); g2.draw(); g3.draw(); g4.draw(); g5.draw(); g6.draw(); g7.draw(); e1.draw(); e2.draw(); e3.draw(); e4.draw(); e5.draw(); r1.draw(); r2.draw(); r3.draw(); r4.draw(); r5.draw(); r6.draw(); c1.draw(); c2.draw(); c3.draw(); c4.draw(); plus1.draw(); plus2.draw(); plus3.draw(); plus4.draw(); glFlush(); }
/* --std=c90 -Wv */ void f1(void) { int i; struct tag { int x; } x; int *p; i(); x(); p(); } void f2(void) { void h2(int, double); void g2(); h2(0, 1); g2(0, 1); } /* prototype vs. non-prototype */ void f3(void) { struct tag { int x; } h3(void), x; int g3(void), y; x = h3(); y = g3(); } /* struct vs. non-struct */ void f4(void) { struct tag h4(void); h4(); } /* error - incomplete return */ void f5(void) { void h5(int, double); void g5(void); h5(0, 1); g5(); } /* argument vs. no argument */
int g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); return 0; }
int main(int argc, char *argv[]) { QCoreApplication a(argc, argv); jcz::TileFactory * tileFactory = new jcz::TileFactory(); RandomNextTileProvider rntp; Game * game = new Game(&rntp); qDebug("NODE_VARIANT: " STR(NODE_VARIANT)); if (false) { qDebug() << "CONTROL_GAME" << CONTROL_GAME; for (int i = 0; i < 10000; ++i) { qDebug() << "================================\nRUN" << i; Game g1(&rntp), g2(&rntp), g3(&rntp), g4(&rntp), g5(&rntp); Q_ASSERT(g1.equals(g2)); Q_ASSERT(g2.equals(g1)); g1.addPlayer(&RandomPlayer::instance); g1.addPlayer(&RandomPlayer::instance); // g1.addPlayer(new jcz::JCZPlayer(tileFactory)); for (Player * p : g1.getPlayers()) { g2.addPlayer(p->clone()); g3.addPlayer(p->clone()); g4.addPlayer(p->clone()); g5.addPlayer(p->clone()); } Q_ASSERT(g1.equals(g2)); Q_ASSERT(g2.equals(g1)); g1.newGame(Tile::BaseGame, tileFactory); g2.newGame(Tile::BaseGame, tileFactory); g4.newGame(Tile::BaseGame, tileFactory); g5.newGame(Tile::BaseGame, tileFactory); Q_ASSERT(g1.equals(g2)); Q_ASSERT(g2.equals(g1)); int steps = 0; bool notDone = true; //for ( ; steps < 23; ++steps) for ( ; notDone; ++steps) { notDone = g1.step(); MoveHistoryEntry const & e = g1.getMoveHistory().back(); g4.simStep(e); g5.simPartStepChance(e.tileIndex); g5.simPartStepTile(e.move.tileMove); g5.simPartStepMeeple(e.move.meepleMove); Q_ASSERT(g1.equals(g4)); Q_ASSERT(g4.equals(g1)); Q_ASSERT(g1.equals(g5)); Q_ASSERT(g5.equals(g1)); #if CONTROL_GAME g3.newGame(Tile::BaseGame, tileFactory, g1.getMoveHistory()); Q_ASSERT(g1.equals(g3)); Q_ASSERT(g3.equals(g1)); #endif } for (int i = 0; i < steps; ++i) { g1.simUndo(); g4.simUndo(); g5.simPartUndoMeeple(); g5.simPartUndoTile(); g5.simPartUndoChance(); Q_ASSERT(g1.equals(g4)); Q_ASSERT(g4.equals(g1)); Q_ASSERT(g1.equals(g5)); Q_ASSERT(g5.equals(g1)); #if CONTROL_GAME g3.newGame(Tile::BaseGame, tileFactory, g1.getMoveHistory()); Q_ASSERT(g1.equals(g3)); Q_ASSERT(g3.equals(g1)); #endif } Q_ASSERT(g1.equals(g2)); Q_ASSERT(g2.equals(g1)); } return 0; } if (true) { static int const playouts = 5000; Game g(&rntp); g.addPlayer(&RandomPlayer::instance); g.addPlayer(&RandomPlayer::instance); // g.addPlayer(new jcz::JCZPlayer(tileFactory)); // g.addPlayer(new jcz::JCZPlayer(tileFactory)); // g.addPlayer(new SimplePlayer()); QTime t; t.start(); for (int i = 0; i < playouts; ++i) { g.newGame(Tile::BaseGame, tileFactory); int steps = 0; do { ++steps; } while (g.step()); } int e = t.elapsed(); std::cout << playouts << "p / " << e << "ms = " << playouts / (e / 1000.0) << " pps" << std::endl; // return 0; } if (true) { static int const playouts = 5000; Game g(&rntp); g.addPlayer(&RandomPlayer::instance); g.addPlayer(&RandomPlayer::instance); // g.addPlayer(new SimplePlayer()); g.newGame(Tile::BaseGame, tileFactory); QTime t; t.start(); for (int i = 0; i < playouts; ++i) { int steps = 0; do { ++steps; } while (g.step()); for (; steps > 0; --steps) { g.simUndo(); } } int e = t.elapsed(); std::cout << playouts << "p / " << e << "ms = " << playouts / (e / 1000.0) << " pps" << std::endl; return 0; } if (false) { Player * p1 = &RandomPlayer::instance; // auto * p2 = new MonteCarloPlayer<>(tileFactory); auto * p2 = new MonteCarloPlayer2<>(tileFactory); game->addPlayer(p1); game->addPlayer(p2); QTime t; int const n = 5; t.start(); for (int i = 0; i < n; ++i) { #if !COUNT_PLAYOUTS t.start(); #endif game->newGame(Tile::BaseGame, tileFactory); for (int ply = 0; game->step(); ++ply) { // std::cout << ply << std::endl; } int e = t.elapsed(); #if COUNT_PLAYOUTS std::cout << i << " " << p2->playouts << "p / " << e << "ms = " << (p2->playouts) / (e / 1000.0) << " pps" << std::endl; #else std::cout << i << " " << e << std::endl; #endif } std::cout << (t.elapsed() / n) << std::endl; return 0; } if (true) { Player * p1 = &RandomPlayer::instance; auto * p2 = new MCTSPlayer<>(tileFactory); game->addPlayer(p1); game->addPlayer(p2); QTime t; int const n = 5; t.start(); for (int i = 0; i < n; ++i) { #if !COUNT_PLAYOUTS t.start(); #endif game->newGame(Tile::BaseGame, tileFactory); for (int ply = 0; game->step(); ++ply) { // std::cout << "ply " << ply << std::endl; } int e = t.elapsed(); #if COUNT_PLAYOUTS std::cout << i << " " << p2->playouts << "p / " << e << "ms = " << (p2->playouts) / (e / 1000.0) << " pps" << std::endl; #else std::cout << i << " " << e << std::endl; #endif #if MCTS_COUNT_EXPAND_HITS std::cout << i << " " << p2->hit << "hits / " << p2->miss << "misses = " << (p2->hit / qreal(p2->miss)) << std::endl; #endif } std::cout << (qreal(t.elapsed()) / qreal(n)) << std::endl; return 0; } if (false) { SimplePlayer3 s3; game->addPlayer(&s3); game->newGame(Tile::BaseGame, tileFactory); forever { game->simStep(&RandomPlayer::instance); if (game->getPlayerMeeples(0) <= 0) break; } qDebug() << game->getPlayerMeeples(0); forever { game->simStep(&s3); if (game->getPlayerMeeples(0) > 0) break; } qDebug() << game->getPlayerMeeples(0); qDebug(); MoveHistoryEntry h = game->getMoveHistory().back(); game->undo(); qDebug() << "m" << game->getPlayerMeeples(0); // qDebug() << "r" << game->getPlayerReturnMeeples(0); game->simStep(h); qDebug() << "m" << game->getPlayerMeeples(0); // qDebug() << "r" << game->getPlayerReturnMeeples(0); game->undo(); qDebug() << "m" << game->getPlayerMeeples(0); // qDebug() << "r" << game->getPlayerReturnMeeples(0); qDebug(); qDebug("simPartStepChance"); game->simPartStepChance(h.tileIndex); qDebug() << "m" << game->getPlayerMeeples(0); // qDebug() << "r" << game->getPlayerReturnMeeples(0); qDebug("simPartStepTile"); game->simPartStepTile(h.move.tileMove); qDebug() << "m" << game->getPlayerMeeples(0); // qDebug() << "r" << game->getPlayerReturnMeeples(0); qDebug() << "placements" << game->getPossibleMeeplePlacements(0, game->simTile).size(); qDebug("simPartStepMeeple"); game->simPartStepMeeple(h.move.meepleMove); qDebug() << "m" << game->getPlayerMeeples(0); // qDebug() << "r" << game->getPlayerReturnMeeples(0); qDebug(); qDebug(); qDebug("simPartUndoMeeple"); game->simPartUndoMeeple(); qDebug() << "m" << game->getPlayerMeeples(0); // qDebug() << "r" << game->getPlayerReturnMeeples(0); qDebug() << "placements" << game->getPossibleMeeplePlacements(0, game->simTile).size(); qDebug("simPartUndoTile"); game->simPartUndoTile(); qDebug() << "m" << game->getPlayerMeeples(0); // qDebug() << "r" << game->getPlayerReturnMeeples(0); qDebug("simPartUndoChance"); game->simPartUndoChance(); qDebug() << "m" << game->getPlayerMeeples(0); // qDebug() << "r" << game->getPlayerReturnMeeples(0); }
int main(){ Scalar a("a",STRING,"Hello"); Scalar b("b",STRING,"World"); std::cout << " a : " << a << std::endl; std::cout << " b : " << b << std::endl; Scalar c("c",STRING,"Hello"); std::cout << " c : " << c << std::endl; std::cout << " a == b : " << (a == b) << std::endl; std::cout << " a == c : " << (a == c) << std::endl; std::cout << " a < b : " << (a < b) << std::endl; std::cout << " c < a : " << (c < a) << std::endl; std::cout << " b < a : " << (b < a) << std::endl; Scalar ga("ga",BOOLEAN,"M"); Scalar gb("gb",BOOLEAN,"F"); Scalar gc("gc",BOOLEAN,"F"); Scalar d("d",STRING,"M"); std::cout << " ga : " << ga << std::endl; std::cout << " gb : " << gb << std::endl; std::cout << " gc : " << gc << std::endl; std::cout << " d : " << d << std::endl; std::cout << " (ga == gb) : " << (ga == gb) << std::endl; std::cout << " (gb == gc) : " << (gb == gc) << std::endl; std::cout << " (ga == d) : " << (ga == d) << std::endl; std::cout << " (gb < gc) : " << (gb < gc) << std::endl; std::cout << " (ga < gc) : " << (ga < gc) << std::endl; std::cout << " (gc < ga) : " << (gc < ga) << std::endl; std::cout << " (ga < a) : " << (ga < a) << std::endl; std::cout << " (b < gb) : " << (b < gb) << std::endl; std::cout << "Testing Assignment and Copy operators" << std::endl; Scalar copy1(ga); std::cout << " copy1 of ga : " << copy1 << std::endl; std::cout << " name and type : " << copy1.getName() << " = " << copy1.getValueType() << std::endl; Scalar e("e",STRING,"Namaste"); std::cout << " e : " << e << std::endl; e=ga; std::cout << " e=ga : " << e << std::endl; std::cout << " name and type : " << e.getName() << " = " << e.getValueType() << std::endl; e=a; std::cout << " e=a : " << e << std::endl; std::cout << " name and type : " << e.getName() << " = " << e.getValueType() << std::endl; ga=a; std::cout << " ga=a : " << ga << std::endl; std::cout << " name and type : " << ga.getName() << " = " << ga.getValueType() << std::endl; std::cout << "Testing Scalar variables of type ANY" << std::endl; Scalar anyVar("anyVar"); std::cout << " name and type : " << anyVar.getName() << " = " << anyVar.getValueType() << std::endl; std::cout << " anyVar : " << anyVar << std::endl; std::cout << " anyVar < ga : " << (anyVar < ga) << std::endl; std::cout << " a < anyVar : " << (a < anyVar) << std::endl; std::cout << " a == anyVar : " << (a == anyVar) << std::endl; anyVar.set(STRING,"Wow"); std::cout << " anyVar=Wow : " << anyVar << std::endl; Scalar anyVar1("anyVar1"); std::cout << " anyVar1 : " << anyVar1 << std::endl; std::cout << " name and type : " << anyVar1.getName() << " = " << anyVar1.getValueType() << std::endl; anyVar1 = anyVar; std::cout << " anyVar1=anyVar : " << anyVar1 << std::endl; std::cout << " name and type : " << anyVar1.getName() << " = " << anyVar1.getValueType() << std::endl; Scalar anyVar2("anyVar2"); std::cout << " anyVar2 : " << anyVar2 << std::endl; std::cout << " name and type : " << anyVar2.getName() << " = " << anyVar2.getValueType() << std::endl; anyVar = anyVar2; std::cout << " anyVar=anyVar2 : " << anyVar << std::endl; std::cout << " anyVar name and type : " << anyVar.getName() << " = " << anyVar.getValueType() << std::endl; std::cout << " anyVar2 name and type : " << anyVar2.getName() << " = " << anyVar2.getValueType() << std::endl; Scalar anyType("anyType",ANY,"Testing Any"); std::cout << " anyType : " << anyType << std::endl; std::cout << " name and type : " << anyType.getName() << " = " << anyType.getValueType() << std::endl; std::cout << " anyVar2 < anyType : " << (anyVar2 < anyType) << std::endl; std::cout << " anyVar2 == anyType : " << (anyVar2 == anyType) << std::endl; Scalar g1("g1",GENOTYPE,"120/120"); Scalar g2("g2",GENOTYPE,"120/120"); Scalar g3("g3",GENOTYPE,"112/118"); Scalar g4("g4",GENOTYPE,"C/T"); Scalar g5("g5",GENOTYPE,"A/A"); std::cout << " g1 : " << g1 << std::endl; std::cout << " name and type : " << g1.getName() << " = " << g1.getValueType() << std::endl; anyVar2 = g1; std::cout << " anyVar2=g1 : " << anyVar2 << std::endl; std::cout << " name and type : " << anyVar2.getName() << " = " << anyVar2.getValueType() << std::endl; std::cout << " g2 : " << g2 << std::endl; std::cout << " g3 : " << g3 << std::endl; std::cout << " g4 : " << g4 << std::endl; std::cout << " g5 : " << g5 << std::endl; std::cout << " name and type : " << g5.getName() << " = " << g5.getValueType() << std::endl; std::cout << " g1 < g2 : " << (g1 < g2) << std::endl; std::cout << " g2 == g1 : " << (g2 == g1) << std::endl; std::cout << " g5 < g4 : " << (g5 < g4) << std::endl; std::cout << " g2 < g4 : " << (g2 < g4) << std::endl; std::cout << " g2 < e : " << (g2 < e) << std::endl; std::cout << " ga == g2 : " << (ga == g2) << std::endl; Scalar f("f",STRING,"123/125"); Scalar g6Any("g6Any"); std::cout << " g6Any : " << g6Any << std::endl; std::cout << " name and type : " << g6Any.getName() << " = " << g6Any.getValueType() << std::endl; g6Any = f; std::cout << " g6Any=f : " << g6Any << std::endl; std::cout << " name and type : " << g6Any.getName() << " = " << g6Any.getValueType() << std::endl; g3 = g6Any; std::cout << " g3=g6Any : " << g3 << std::endl; std::cout << " name and type : " << g3.getName() << " = " << g3.getValueType() << std::endl; Scalar g7Inv("g7Inv"); g7Inv.set(GENOTYPE,"0/0"); std::cout << " g7Inv : " << g7Inv << std::endl; std::cout << " name and type : " << g7Inv.getName() << " = " << g7Inv.getValueType() << std::endl; Scalar d1("d1",DATE,"1987-08-23"); Scalar d2("d2",DATE,"1987-08"); Scalar d3("d3",DATE,"[1987-1990]"); Scalar d4("d4",DATE,"~2000-02-13"); Scalar d5("d5",DATE,"1948"); Scalar d6Any("d6Any"); std::cout << " d1 : " << d1 << std::endl; std::cout << " name and type : " << d1.getName() << " = " << d1.getValueType() << std::endl; std::cout << " d6Any : " << d6Any << std::endl; std::cout << " name and type : " << d6Any.getName() << " = " << d6Any.getValueType() << std::endl; d6Any = d1; std::cout << " d6Any=d1 : " << d6Any << std::endl; std::cout << " name and type : " << d6Any.getName() << " = " << d6Any.getValueType() << std::endl; std::cout << " d2 : " << d2 << std::endl; std::cout << " d3 : " << d3 << std::endl; std::cout << " d4 : " << d4 << std::endl; std::cout << " d5 : " << d5 << std::endl; Scalar d7Inv("d7Inv"); d7Inv.set(DATE,"2003-[03-04-12"); std::cout << " d7Inv : " << d7Inv << std::endl; std::cout << " name and type : " << d7Inv.getName() << " = " << d7Inv.getValueType() << std::endl; std::cout << " d1 < d2 : " << (d1 < d2) << std::endl; std::cout << " d2 == d1 : " << (d2 == d1) << std::endl; std::cout << " d2 == d3 : " << (d2 == d3) << std::endl; std::cout << " d3 < d2 : " << (d3 < d2) << std::endl; std::cout << " d5 < d4 : " << (d5 < d4) << std::endl; std::cout << " d2 < d4 : " << (d2 < d4) << std::endl; std::cout << " d2 < e : " << (d2 < e) << std::endl; std::cout << " ga == d2 : " << (ga == d2) << std::endl; Scalar d8Copy(d4); std::cout << " Copy of d4 : " << d8Copy << std::endl; std::cout << " name and type : " << d8Copy.getName() << " = " << d8Copy.getValueType() << std::endl; std::cout << " d4 == d8Copy : " << (d4 == d8Copy) << std::endl; Scalar n1("n1",NUMBER,"19-23"); Scalar n2("n2",NUMBER,"18-38"); Scalar n3("n3",NUMBER,"17"); Scalar n4("n4",NUMBER,"~20"); Scalar n5("n5",NUMBER,"48"); Scalar n6Any("n6Any"); std::cout << " n1 : " << n1 << std::endl; std::cout << " name and type : " << n1.getName() << " = " << n1.getValueType() << std::endl; std::cout << " n6Any : " << n6Any << std::endl; std::cout << " name and type : " << n6Any.getName() << " = " << n6Any.getValueType() << std::endl; n6Any = n1; std::cout << " n6Any=n1 : " << n6Any << std::endl; std::cout << " name and type : " << n6Any.getName() << " = " << n6Any.getValueType() << std::endl; std::cout << " n2 : " << n2 << std::endl; std::cout << " n3 : " << n3 << std::endl; std::cout << " n4 : " << n4 << std::endl; std::cout << " n5 : " << n5 << std::endl; Scalar n7Inv("n7Inv"); n7Inv.set(NUMBER,"2003-["); std::cout << " n7Inv : " << n7Inv << std::endl; std::cout << " name and type : " << n7Inv.getName() << " = " << n7Inv.getValueType() << std::endl; std::cout << " n1 < n2 : " << (n1 < n2) << std::endl; std::cout << " n2 == n1 : " << (n2 == n1) << std::endl; std::cout << " n2 == n3 : " << (n2 == n3) << std::endl; std::cout << " n3 < n2 : " << (n3 < n2) << std::endl; std::cout << " n5 < n4 : " << (n5 < n4) << std::endl; std::cout << " n2 < n4 : " << (n2 < n4) << std::endl; std::cout << " n2 < e : " << (n2 < e) << std::endl; std::cout << " ga == n2 : " << (ga == n2) << std::endl; Scalar n8Copy(n4); std::cout << " Copy of n4 : " << n8Copy << std::endl; std::cout << " name and type : " << n8Copy.getName() << " = " << n8Copy.getValueType() << std::endl; std::cout << " n4 == n8Copy : " << (n4 == n8Copy) << std::endl; Number::addNumberMissingValue("99"); std::cout << "Added 99 as Number missing value" << std::endl; Scalar n8("n8",NUMBER,"99"); std::cout << " n8=99 : " << n8 << std::endl; return 0; }
void g6(int a1, int a2, int a3, int a4, int a5, int a6) const { g5(a1, a2, a3, a4, a5); g1(a6); }