void tst_QSizeF::scale() { QSizeF t1(10.4, 12.8); t1.scale(60.6, 60.6, Qt::IgnoreAspectRatio); QCOMPARE(t1, QSizeF(60.6, 60.6)); QSizeF t2(10.4, 12.8); t2.scale(43.52, 43.52, Qt::KeepAspectRatio); QCOMPARE(t2, QSizeF(35.36, 43.52)); QSizeF t3(9.6, 12.48); t3.scale(31.68, 31.68, Qt::KeepAspectRatioByExpanding); QCOMPARE(t3, QSizeF(31.68, 41.184)); QSizeF t4(12.8, 10.4); t4.scale(43.52, 43.52, Qt::KeepAspectRatio); QCOMPARE(t4, QSizeF(43.52, 35.36)); QSizeF t5(12.48, 9.6); t5.scale(31.68, 31.68, Qt::KeepAspectRatioByExpanding); QCOMPARE(t5, QSizeF(41.184, 31.68)); QSizeF t6(0.0, 0.0); t6.scale(200, 240, Qt::IgnoreAspectRatio); QCOMPARE(t6, QSizeF(200, 240)); QSizeF t7(0.0, 0.0); t7.scale(200, 240, Qt::KeepAspectRatio); QCOMPARE(t7, QSizeF(200, 240)); QSizeF t8(0.0, 0.0); t8.scale(200, 240, Qt::KeepAspectRatioByExpanding); QCOMPARE(t8, QSizeF(200, 240)); }
void test_relational() { cout << "test_relational" << endl; sc_time t1; sc_time t2( 1, SC_FS ); sc_time t3( 1.2345, SC_NS ); sc_time t4( 1.2341, SC_NS ); sc_time t5( -1.5432, SC_NS ); cout << ( t1 == t2 ) << endl; cout << ( t1 != t2 ) << endl; cout << ( t1 < t2 ) << endl; cout << ( t1 <= t2 ) << endl; cout << ( t1 > t2 ) << endl; cout << ( t1 >= t2 ) << endl; cout << ( t3 == t4 ) << endl; cout << ( t3 != t4 ) << endl; cout << ( t3 < t4 ) << endl; cout << ( t3 <= t4 ) << endl; cout << ( t3 > t4 ) << endl; cout << ( t3 >= t4 ) << endl; cout << ( t1 == t5 ) << endl; cout << ( t1 != t5 ) << endl; cout << ( t1 < t5 ) << endl; cout << ( t1 <= t5 ) << endl; cout << ( t1 > t5 ) << endl; cout << ( t1 >= t5 ) << endl; }
int main(int argc, const char *argv[]) { int accu = 0; for (size_t bite = 0; bite < 64; ++bite) { pong p; moost::Thread t1(p); moost::Thread t2(p); moost::Thread t3(p); moost::Thread t4(p); moost::Thread t5(p); moost::Thread t0(&ping); moost::Thread t01(&ping); moost::Thread t02(&ping); moost::Thread t03(&ping); moost::Thread t04(&ping); t0.join(); t01.join(); t02.join(); t03.join(); t04.join(); t1.join(); t2.join(); t3.join(); t4.join(); t5.join(); accu = i; } if (accu == 0) std::cout << "OK" << std::endl; else std::cout << "KO" << std::endl; return (0); }
void testmain() { print("struct"); t1(); t2(); t3(); t4(); t5(); t6(); t7(); t8(); t9(); t10(); t11(); t12(); t13(); t14(); unnamed(); assign(); arrow(); incomplete(); bitfield_basic(); bitfield_mix(); bitfield_union(); bitfield_unnamed(); bitfield_initializer(); test_offsetof(); flexible_member(); empty_struct(); }
void test_print() { cout << "test_print" << endl; sc_time t1; cout << t1 << endl; uint64 v = 1230; sc_time t2( v, false ); cout << t2 << endl; v *= 10000; sc_time t3( v, false ); cout << t3 << endl; v *= 100; sc_time t4( v, false ); cout << t4 << endl; v *= 10000; sc_time t5( v, false ); cout << t5 << endl; v *= 100; sc_time t6( v, false ); cout << t6 << endl; v *= 10000; sc_time t7( v, false ); cout << t7 << endl; }
int main(int argc, char* argv[]) { auto master_thread_id = std::this_thread::get_id(); auto lambda_f = [=]() { auto thread_id = std::this_thread::get_id(); if (thread_id == master_thread_id) { std::lock_guard<std::mutex> l(cout_mutex); std::cout << "Master thread. ID=" << thread_id << std::endl; } else { std::lock_guard<std::mutex> l(cout_mutex); std::cout << "Child thread. ID=" << thread_id << std::endl; } }; ScopedThread t1(lambda_f); ScopedThread t2(lambda_f); ScopedThread t3(lambda_f); ScopedThread t4(lambda_f); ScopedThread t5(lambda_f); lambda_f(); }
void testSerialize () { BTree<int> empty; BTree<int> t90 (90,empty,empty), t12 (12,t90,empty), t30 (30,empty,t12), t50 (50,empty,empty), t5 (5,t50, empty), t7 (7,t30,t5); std::ofstream f ("tree.txt"); f << t7; f.close (); BTree<int> newTree; std::ifstream fin ("tree.txt"); newTree.read (fin); //assert (t7==newTree); std::cout << std::endl << newTree; }
void test_types() { std::cout << "--- types ---\n"; Void_type t1; std::cout << t1 << '\n'; // void Boolean_type t2; std::cout << t2 << '\n'; // bool Integer_type t3; std::cout << t3 << '\n'; // int Float_type t4; std::cout << t4 << '\n'; // double Function_type t5({&t2, &t3}, t2); std::cout << t5 << '\n'; // (bool, int32) -> bool Pointer_type t6(t2); std::cout << t6 << '\n'; // bool*; Reference_type t7(t5); std::cout << t7 << '\n'; // ((bool, int32) -> bool)&; Function_type t8({}, t1); std::cout << t8 << '\n'; // () -> void Sequence_type t9(*new Pointer_type(t8)); std::cout << t9 << '\n'; // (() -> void)*[] }
int main(){ float* A = (float*) memalign(16, LEN5*sizeof(float)); float* B = (float*) memalign(16, LEN5*sizeof(float)); float* C = (float*) memalign(16, LEN5*sizeof(float)); float* D = (float*) memalign(16, LEN5*sizeof(float)); float* E = (float*) memalign(16, LEN5*sizeof(float)); for (int i = 0; i < LEN5; i++){ A[i] = (float)(i)/(float)LEN5; B[i] = (float)(i+1)/(float)LEN5; C[i] = (float)(i+2)/(float)LEN5; D[i] = (float)(i+3)/(float)LEN5; E[i] = (float)(i+4)/(float)LEN5; } unsigned long long start_c, end_c, diff_c; start_c = _rdtsc(); t5(A,B,C,D,E); end_c=_rdtsc(); diff_c = end_c - start_c; float giga_cycle = diff_c / 1000000000.0; float ttt = (float)0.; #pragma novector for (int i = 0; i < LEN5; i++) ttt += A[i]; printf("t5 took\t %.2f and the result is %f\n", giga_cycle, ttt); }
static const char* op_plus_equal () { std::cout << __func__ << std::endl; ioa::time t1 (1, 500500); ioa::time t2 (-2, -300300); ioa::time t3 (t1); t3 += t1; mu_assert (t3.sec () == 3); mu_assert (t3.usec () == 1000); ioa::time t4 (t1); t4 += t2; mu_assert (t4.sec () == 0); mu_assert (t4.usec () == -799800); ioa::time t5 (t2); t5 += t1; mu_assert (t5.sec () == 0); mu_assert (t5.usec () == -799800); ioa::time t6 (t2); t6 += t2; mu_assert (t6.sec () == -4); mu_assert (t6.usec () == -600600); return 0; }
void testPrintWithStack () { BTree<int> empty; BTree<int> t90 (90,empty,empty), t12 (12,t90,empty), t30 (30,empty,t12), t50 (50,empty,empty), t5 (5,t50, empty), t7 (7,t30,t5); t7.printWithStack(std::cout); std::stringstream str; t7.printWithStack(str); int x, y, z; str >> x >> y >> z; assert (x == 30); assert (y == 90); assert (z == 12); //или assert (str.str() == "30 90 12 7 50 5 "); }
int test11() { context ctx(MAGIC_VALUE11); { exc_test t1(ctx, MAGIC_VALUE11_2); try { exc_test t2(ctx, MAGIC_VALUE11_2); throw exc_test(ctx, MAGIC_VALUE11); // this magic value is expected to be catched in ff_throw() and captured in context::state } catch (exc_test&) { exc_test t3(ctx, MAGIC_VALUE11_2); try { exc_test t4(ctx, MAGIC_VALUE11_2); ff_throw(ctx); } catch (exc_test&) { exc_test t5(ctx, MAGIC_VALUE11_2); ctx.state = UNEXPECTED_CATCH1; } } } return ctx.balance(); }
int main(void) { wheel::EventMapping events; wheel::Timer t5("timer", 5000000, true); wheel::Timer t2("timer2", 2000000, true); printf("created timer at %08x, with 5000 µsec interval\n", &t5); printf("created timer at %08x, with 2000 µsec interval\n", &t2); events.map_event(wheel::event_from_ptr(WHEEL_EVENT_TIMER, &t5), "test timer", [&](wheel::Event& e) { e.data.seek(1); uint64_t ptr = e.data.read<uint64_t>(); printf("event from timer @ %08x\n", ptr); } ); events.map_event(wheel::event_from_ptr(WHEEL_EVENT_TIMER, &t2), "test timer2", [&](wheel::Event& e) { e.data.seek(1); uint64_t ptr = e.data.read<uint64_t>(); printf("event from timer @ %08x\n", ptr); } ); while(1) { events.process(); } return 0; }
void testMemory () { BTree<int> empty; BTree<int> t90 (90,empty,empty), t12 (12,t90,empty), t30 (30,empty,t12), t50 (50,empty,empty), t5 (5,t50, empty), t7 (7,t30,t5); BTree<int> *tmp = new BTree<int> (t7); assert (tmp->member (90)); assert (tmp->member (7)); assert (*tmp == t7); delete tmp; assert (t7.member (90)); assert (t7.member (7)); t90 = t7; assert (t90 == t7); t7 = t7; assert (t90 == t7); assert (t7 == t7); }
int main(void) { vector<int> ret; TreeNode root(1); TreeNode t2(2); TreeNode t3(3); TreeNode t4(4); TreeNode t5(5); TreeNode t6(6); TreeNode t7(7); TreeNode t8(8); TreeNode t9(9); TreeNode t10(10); root.left = &t2; root.right = &t3; t2.left = &t4; t3.left = &t5; t3.right = &t6; t5.left = &t7; t6.left = &t8; t6.right = &t9; t8.left = &t10; Solution s; ret = s.preorderTraversal(&root); for(auto it = ret.begin(); it != ret.end(); ++it) { std::cout << *it << " "; } std::cout << std::endl; }
int main() { TreeNode root1(1); TreeNode root2(1); TreeNode t2(2); TreeNode t3(3); TreeNode t4(4); TreeNode t5(5); TreeNode t6(6); TreeNode t7(7); TreeNode t8(8); TreeNode t9(9); root1.left = &t2; root1.right = &t3; root2.left = &t2; root2.right = &t3; t2.left = &t4; t2.right = &t5; t3.right = &t6; t4.left = &t7; t4.right = &t8; t8.left = &t9; Solution s; std::cout << s.isSameTree(&root1, &root2) << std::endl; return 0; }
bool iterator_replace_test( ) { bool rc = true; const std::string s1( "Insert me!" ); std::string t1( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ); t1.replace( t1.begin( ), t1.end( ), s1 ); if( t1 != "Insert me!" || INSANE( t1 ) ) FAIL std::string t2( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ); t2.replace( t2.begin( ), t2.begin( ) + 1, s1 ); if( t2 != "Insert me!BCDEFGHIJKLMNOPQRSTUVWXYZ" || INSANE( t2 ) ) FAIL std::string t3( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ); t3.replace( t3.end( ), t3.end( ), s1 ); if( t3 != "ABCDEFGHIJKLMNOPQRSTUVWXYZInsert me!" || INSANE( t3 ) ) FAIL std::string t4( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ); t4.replace( t4.begin( ) + 4, t4.begin( ) + 7, s1 ); if( t4 != "ABCDInsert me!HIJKLMNOPQRSTUVWXYZ" || INSANE( t4 ) ) FAIL std::string t5( "Shorty" ); t5.replace( t5.begin( ), t5.begin( ) + 2, 2, 'x' ); if( t5 != "xxorty" || INSANE( t5 ) ) FAIL // Need to test other iterator replace methods. return( rc ); }
bool replace_test( ) { bool rc = true; const std::string s1( "Insert me!" ); std::string t1( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ); t1.replace( 0, std::string::npos, s1, 0, std::string::npos ); if( t1 != "Insert me!" || INSANE( t1 ) ) FAIL std::string t2( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ); t2.replace( 0, 1, s1, 0, std::string::npos ); if( t2 != "Insert me!BCDEFGHIJKLMNOPQRSTUVWXYZ" || INSANE( t2 ) ) FAIL std::string t3( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ); t3.replace( 1, 0, s1, 0, 1 ); if( t3 != "AIBCDEFGHIJKLMNOPQRSTUVWXYZ" || INSANE( t3 ) ) FAIL std::string t4( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ); t4.replace( 26, 0, s1, 0, std::string::npos ); if( t4 != "ABCDEFGHIJKLMNOPQRSTUVWXYZInsert me!" || INSANE( t4 ) ) FAIL std::string t5( "ABCDEFGHIJKLMNOPQRSTUVWXYZ" ); t5.replace( 4, 3, s1, 2, 5 ); if( t5 != "ABCDsert HIJKLMNOPQRSTUVWXYZ" || INSANE( t5 ) ) FAIL std::string t6( "Shorty" ); t6.replace( 1, 2, s1, 0, 2 ); if( t6 != "SInrty" || INSANE( t6 ) ) FAIL // Need to test other replace methods. return( rc ); }
int CC_Client::run_basic_tests (void) { Test_Single_Lock_With_Mode t1 (naming_service_, CosConcurrencyControl::read); Test_Single_Lock_With_Mode t2 (naming_service_, CosConcurrencyControl::write); Test_Single_Lock_With_Mode t3 (naming_service_, CosConcurrencyControl::upgrade); Test_Single_Lock_With_Mode t4 (naming_service_, CosConcurrencyControl::intention_read); Test_Single_Lock_With_Mode t5 (naming_service_, CosConcurrencyControl::intention_write); // This test should be run for several different lock mode, but // since we do not support Test_Release_Not_Held_Lock t6 (naming_service_, CosConcurrencyControl::read); if (t1.run () == CC_SUCCESS && t2.run () == CC_SUCCESS && t3.run () == CC_SUCCESS && t4.run () == CC_SUCCESS && t5.run () == CC_SUCCESS && t6.run () == CC_SUCCESS ) return CC_SUCCESS; else return CC_FAIL; }
int main (int, char *[]) { ACE_START_TEST ("Group_Test"); int stamp = 20; /* ================================================================== */ ACE_DEBUG((LM_INFO, "-----------group target-----------\n")); ACE_DEBUG((LM_INFO, "constrctor(Stamp)..................\n")); ACE_CLASSIX_Group_Stamp t0(100); t0.dump(); /* ================================================================== */ ACE_DEBUG((LM_INFO, "-----------group target-----------\n")); ACE_DEBUG((LM_INFO, "constrctor(Stamp)..................\n")); ACE_CLASSIX_Group_Stamp t1(stamp); t1.dump(); /* ================================================================== */ ACE_DEBUG((LM_INFO, "empty constrctor(Stamp) & set_group()\n")); ACE_CLASSIX_Group_Stamp t2; if (t2 == t1) ACE_DEBUG((LM_ERROR, "t2 == t1, should be !=\n")); t2.set_addr(&stamp); t2.dump(); if (t2 != t1) ACE_DEBUG((LM_ERROR, "????t2 != t1, should be ==\n")); /* ================================================================== */ ACE_DEBUG((LM_INFO, "Constrctor(Dynamic) & set_group()\n")); ACE_CLASSIX_Group_Dynamic t3; t3.dump(); ACE_CLASSIX_Group_Stamp t4; t4.set_addr(t2.get_addr(), t2.get_size()); t4.dump(); if (t4 == t2) ACE_DEBUG((LM_ERROR, "????t4 == t2, should be !=\n")); t4.set_addr(&stamp); t4.dump(); if (t4 != t2) ACE_DEBUG((LM_ERROR, "????t4 != t2, should be ==\n")); ACE_CLASSIX_Group t5(t3.get_addr(), t3.get_size()); t5.dump(); if (t5 != t3) ACE_DEBUG((LM_ERROR, "????t5 != t3, should be ==\n")); if (t2 != t1) ACE_DEBUG((LM_ERROR, "????t2 != t1, should be ==\n")); /* ================================================================== */ ACE_END_TEST; return 0; }
void test() { const unsigned runs = 1000; unsigned next_progress_report = 10, progress; last_error_count = 0; engine.seed(std::time(0)); BOOST_TEST_EQ(Number(), 0); for (unsigned r = 1; r <= runs; ++r) { progress = 100 * r / runs; while (progress >= next_progress_report) { std::cout << "..." << progress << "%"; std::cout.flush(); next_progress_report += 10; } a = kanooth::numbers::generate_random_bits_number<ref_type>(engine, 1000); b = kanooth::numbers::generate_random_bits_number<ref_type>(engine, 512); c = kanooth::numbers::generate_random_bits_number<ref_type>(engine, 256); d = kanooth::numbers::generate_random_bits_number<ref_type>(engine, 32); si = d.convert_to<int>(); ui = si; a1 = static_cast<test_type>(a.str()); b1 = static_cast<test_type>(b.str()); c1 = static_cast<test_type>(c.str()); d1 = static_cast<test_type>(d.str()); t1(); t2(); t3(); t4(); t5(); if(last_error_count != (unsigned)boost::detail::test_errors()) { last_error_count = boost::detail::test_errors(); //std::cout << std::hex << std::showbase; std::cout << "a = " << a << std::endl; std::cout << "a1 = " << a1 << std::endl; std::cout << "b = " << b << std::endl; std::cout << "b1 = " << b1 << std::endl; std::cout << "c = " << c << std::endl; std::cout << "c1 = " << c1 << std::endl; std::cout << "d = " << d << std::endl; std::cout << "d1 = " << d1 << std::endl; } } std::cout << std::endl; }
void testmain(void) { print("pointer"); t1(); t2(); t3(); t4(); t5(); t6(); subtract(); }
void tst_QSize::scale() { QSize t1( 10, 12 ); t1.scale( 60, 60, Qt::IgnoreAspectRatio ); QCOMPARE( t1, QSize(60, 60) ); QSize t2( 10, 12 ); t2.scale( 60, 60, Qt::KeepAspectRatio ); QCOMPARE( t2, QSize(50, 60) ); QSize t3( 10, 12 ); t3.scale( 60, 60, Qt::KeepAspectRatioByExpanding ); QCOMPARE( t3, QSize(60, 72) ); QSize t4( 12, 10 ); t4.scale( 60, 60, Qt::KeepAspectRatio ); QCOMPARE( t4, QSize(60, 50) ); QSize t5( 12, 10 ); t5.scale( 60, 60, Qt::KeepAspectRatioByExpanding ); QCOMPARE( t5, QSize(72, 60) ); // test potential int overflow QSize t6(88473, 88473); t6.scale(141817, 141817, Qt::KeepAspectRatio); QCOMPARE(t6, QSize(141817, 141817)); QSize t7(800, 600); t7.scale(400, INT_MAX, Qt::KeepAspectRatio); QCOMPARE(t7, QSize(400, 300)); QSize t8(800, 600); t8.scale(INT_MAX, 150, Qt::KeepAspectRatio); QCOMPARE(t8, QSize(200, 150)); QSize t9(600, 800); t9.scale(300, INT_MAX, Qt::KeepAspectRatio); QCOMPARE(t9, QSize(300, 400)); QSize t10(600, 800); t10.scale(INT_MAX, 200, Qt::KeepAspectRatio); QCOMPARE(t10, QSize(150, 200)); QSize t11(0, 0); t11.scale(240, 200, Qt::IgnoreAspectRatio); QCOMPARE(t11, QSize(240, 200)); QSize t12(0, 0); t12.scale(240, 200, Qt::KeepAspectRatio); QCOMPARE(t12, QSize(240, 200)); QSize t13(0, 0); t13.scale(240, 200, Qt::KeepAspectRatioByExpanding); QCOMPARE(t13, QSize(240, 200)); }
void testBFS () { BTree<int> empty; BTree<int> t90 (90,empty,empty), t12 (12,t90,empty), t30 (30,empty,t12), t50 (50,empty,empty), t5 (5,t50, empty), t7 (7,t30,t5); t7.levelsPrint(std::cout); }
int main(){ Solution a; TreeNode t1(1),t2(2),t3(3),t4(4),t5(5); TreeNode* pt1=&t1, *pt2=&t2, *pt3=&t3, *pt4=&t4, *pt5=&t5; pt1->right=pt2; //pt1->right=pt3; // pt2->left=pt4; // pt3->right=pt5; std::cout<<a.minDepth(NULL)<<std::endl; }
void tst_QTime::isNull() { QTime t1; QVERIFY( t1.isNull() ); QTime t2(0,0,0); QVERIFY( !t2.isNull() ); QTime t3(0,0,1); QVERIFY( !t3.isNull() ); QTime t4(0,0,0,1); QVERIFY( !t4.isNull() ); QTime t5(23,59,59); QVERIFY( !t5.isNull() ); }
int main(void) { assert(4 == sizeof(int)); x += t1(); x += t2(); x += t3(); x += t4(); x += t5(); x += t6(); return x & 255; }
int main(int argc, char *argv[]) { int i, t, c, pi; char test[64]; if (argc > 1) { t = 0; for (i=0; i<strlen(argv[1]); i++) { c = tolower(argv[1][i]); if (!strchr(test, c)) { test[t++] = c; test[t] = 0; } } } else strcat(test, "0123456789"); pi = pigpio_start(0, 0); if (pi < 0) { fprintf(stderr, "pigpio initialisation failed (%d).\n", pi); return 1; } printf("Connected to pigpio daemon (%d).\n", pi); if (strchr(test, '0')) t0(pi); if (strchr(test, '1')) t1(pi); if (strchr(test, '2')) t2(pi); if (strchr(test, '3')) t3(pi); if (strchr(test, '4')) t4(pi); if (strchr(test, '5')) t5(pi); if (strchr(test, '6')) t6(pi); if (strchr(test, '7')) t7(pi); if (strchr(test, '8')) t8(pi); if (strchr(test, '9')) t9(pi); if (strchr(test, 'a')) ta(pi); if (strchr(test, 'b')) tb(pi); if (strchr(test, 'c')) tc(pi); pigpio_stop(pi); return 0; }
int main () { Tree t1(1), t2("u"), t3(5); Tree t4(t1,"*",t2); Tree t5("-",t3); t4(12.0, 0, 0); t5.value(); Tree t6(t1,"/",t3); t6(12.12,0,0); Tree t7(t1,"+",t5); t7.value(); }
void testTree(){ Tree<int> t2(2),t1(1),t3(3),t4(4),t5(5),t6(6); t1.appendChildTree(t2); t1.appendChildTree(t3); t3.appendChildTree(t4); t4.appendChildTree(t5); t5.appendChildTree(t6); cout << "t1's depth is:" << t1.depth() << endl; t1.travelDfs(); //cout << endl << "Hello from Tree.cpp" << endl; //TRACE0("Print in Tree.cpp:::TRACE0.\n"); //TRACE1("t1's depth is:%d.\n",t1.depth()); int in; cin >> in; }