DEFINE_TEST() { const char* two = "2"; typedef mock_registrar<const G42CORE_TEST_NS detail::test_part_base_common*> registrar; test_part_mock_with_id t1(two); registrar::add(&t1); { auto test_part_sequences(G42CORE_TEST_NS detail::test_parts_combiner::combine(registrar::range())); VERIFY(1 == test_part_sequences.size()); auto i = test_part_sequences.begin(); VERIFY(std::string((*i).first) == std::string((*((*i).second.begin()))->test_id())); } test_part_mock_with_id t2("1"); registrar::add(&t2); { auto test_part_sequences(G42CORE_TEST_NS detail::test_parts_combiner::combine(registrar::range())); VERIFY(2 == test_part_sequences.size()); for(auto i = test_part_sequences.begin(); i != test_part_sequences.end(); ++i) { VERIFY((*i).second.size() == 1); VERIFY(std::string((*i).first) == std::string((*((*i).second.begin()))->test_id())); } } test_part_mock_with_id t3(two); registrar::add(&t3); verify_test_part_sequences<registrar>(2); const char* three = "3"; test_part_mock_with_id t3a(three); registrar::add(&t3a); test_part_mock_with_id t3b(three); registrar::add(&t3b); test_part_mock_with_id t3c(three); registrar::add(&t3c); verify_test_part_sequences<registrar>(3); }
int main() { tuple<> t0; tuple<int> t1(1); tuple<int, float> t2(1, 3.14159f); tuple<int, float, const char*> t3a(1, 3.14159f, "Hello, world!"); tuple<long, double, std::string> t3b(t3a); t3b = t3a; // t3a = t3b; DPG: triggers an error, as it should. tuple<int, float, std::string> t3c = make_tuple(17, 2.718281828, std::string("Fun")); int seventeen = 17; double pi = 3.14159; tuple<int&, double&> seventeen_pi = make_tuple(ref(seventeen), ref(pi)); tuple<int&, const double&> seventeen_pi2 = make_tuple(ref(seventeen), cref(pi)); tuple<int&, double&> seventeen_pi_tied = tie(seventeen, pi); assert(get<0>(t3a) == 1); assert(get<1>(t3a) == 3.14159f); assert(std::strcmp(get<2>(t3a), "Hello, world!") == 0); assert(t3a == t3b); assert(!(t3a != t3b)); assert(!(t3a < t3b)); assert(!(t3a > t3b)); assert(t3a <= t3b && t3b <= t3a); assert(t3a >= t3b && t3b >= t3a); }
void test_constructors() { cout << "test_constructors" << endl; sc_time t1; cout << t1 << endl; sc_time t2a( 0, SC_SEC ); cout << t2a << endl; sc_time t2b( 1.2345, SC_NS ); cout << t2b << endl; sc_time t2c( 1.2341, SC_NS ); cout << t2c << endl; sc_time t2d( 1, SC_FS ); cout << t2d << endl; sc_time t2e( -1.2345, SC_NS ); cout << t2e << endl; sc_time t2f( -1.2341, SC_NS ); cout << t2f << endl; char v1 = 1; signed char v2 = 2; unsigned char v3 = 3; short v4 = 4; unsigned short v5 = 5; int v6 = 6; unsigned int v7 = 7; long v8 = 8; unsigned long v9 = 9; float v10 = 10; double v11 = 11; sc_time t2g( v1, SC_NS ); cout << t2g << endl; sc_time t2h( v2, SC_NS ); cout << t2h << endl; sc_time t2i( v3, SC_NS ); cout << t2i << endl; sc_time t2j( v4, SC_NS ); cout << t2j << endl; sc_time t2k( v5, SC_NS ); cout << t2k << endl; sc_time t2l( v6, SC_NS ); cout << t2l << endl; sc_time t2m( v7, SC_NS ); cout << t2m << endl; sc_time t2n( v8, SC_NS ); cout << t2n << endl; sc_time t2o( v9, SC_NS ); cout << t2o << endl; sc_time t2p( v10, SC_NS ); cout << t2p << endl; sc_time t2q( v11, SC_NS ); cout << t2q << endl; sc_time t3a( 0, SC_SEC ); cout << t3a << endl; sc_time t3b( 1.2341, true ); cout << t3b << endl; sc_time t3c( 1.2345, true ); cout << t3c << endl; sc_time t3d( -1.2341, true ); cout << t3d << endl; sc_time t3e( -1.2345, true ); cout << t3e << endl; sc_time t3f( 1.2345, false ); cout << t3f << endl; sc_time t3g( 1.5432, false ); cout << t3g << endl; sc_time t3h( -1.2345, false ); cout << t3h << endl; sc_time t3i( -1.5432, false ); cout << t3i << endl; #if !defined( _MSC_VER ) sc_time t4a( 0ull, true ); cout << t4a << endl; sc_time t4b( 25ull, true ); cout << t4b << endl; sc_time t4c( 25ull, false ); cout << t4c << endl; #else sc_time t4a( 0ui64, true ); cout << t4a << endl; sc_time t4b( 25ui64, true ); cout << t4b << endl; sc_time t4c( 25ui64, false ); cout << t4c << endl; #endif sc_time t5( t4c ); cout << t5 << endl; }
int main() { std::tr1::tuple<int> t1a; std::tr1::tuple<int> t1b(0); std::tr1::tuple<int> t1c(t1b); t1a = t1c; std::tr1::tuple<int> t1d(std::tr1::tuple<short>(0)); t1a = std::tr1::tuple<short>(0); std::tr1::tuple<int, long> t2a; std::tr1::tuple<int, long> t2b(0, 0); std::tr1::tuple<int, long> t2c(t2b); t2a = t2c; std::tr1::tuple<int, long> t2d(std::tr1::tuple<short, int>(0, 0)); t2a = std::tr1::tuple<short, int>(0, 0); //std::tr1::tuple<int, long> t2e(std::make_pair(0, 0L)); //t2e = std::make_pair(0, 0L); // check implementation limits: std::tr1::tuple<int, long, float, int, int, int, int, int, int> t10(0, 0, 0, 0, 0, 0, 0, 0, 0); // make_tuple: verify_return_type(std::tr1::make_tuple(0, 0, 0L), std::tr1::tuple<int, int, long>()); int i = 0; std::tr1::tuple<int&, int, long> t3a(std::tr1::make_tuple(std::tr1::ref(i), 0, 0L)); verify_return_type(std::tr1::make_tuple(std::tr1::ref(i), 0, 0L), t3a); std::tr1::tuple<const int&, int, long> t3b(std::tr1::make_tuple(std::tr1::cref(i), 0, 0L)); verify_return_type(std::tr1::make_tuple(std::tr1::cref(i), 0, 0L), t3b); long j = 0; std::tr1::tuple<int&, long&> tt(std::tr1::tie(i,j)); BOOST_STATIC_ASSERT((::std::tr1::tuple_size<std::tr1::tuple<int, long> >::value == 2)); BOOST_STATIC_ASSERT((::std::tr1::tuple_size<std::tr1::tuple<int, long, float, int, int, int, int, int, int> >::value == 9)); BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::tr1::tuple<int, long> >::type, int>::value)); BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<1, std::tr1::tuple<int, long> >::type, long>::value)); BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::tr1::tuple<int&, long> >::type, int&>::value)); BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::tr1::tuple<const int&, long> >::type, const int&>::value)); // get: verify_return_type(&::std::tr1::get<0>(t1a), static_cast<int*>(0)); verify_return_type(&::std::tr1::get<1>(t2d), static_cast<long*>(0)); verify_return_type(&::std::tr1::get<0>(t3a), static_cast<int*>(0)); verify_return_type(&::std::tr1::get<0>(t3b), static_cast<const int*>(0)); const std::tr1::tuple<int>& cr1 = t1a; verify_return_type(&::std::tr1::get<0>(cr1), static_cast<const int*>(0)); const std::tr1::tuple<int&, int, long>& cr2 = t3a; verify_return_type(&::std::tr1::get<0>(cr2), static_cast<int*>(0)); const std::tr1::tuple<const int&, int, long>& cr3 = t3b; // comparison: verify_return_type(cr2 == cr3, false); verify_return_type(cr2 != cr3, false); verify_return_type(cr2 < cr3, false); verify_return_type(cr2 > cr3, false); verify_return_type(cr2 <= cr3, false); verify_return_type(cr2 >= cr3, false); // pair interface: BOOST_STATIC_ASSERT((::std::tr1::tuple_size<std::pair<int, long> >::value == 2)); BOOST_STATIC_ASSERT((::std::tr1::tuple_size<std::pair<int, float> >::value == 2)); BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<0, std::pair<int, long> >::type, int>::value)); BOOST_STATIC_ASSERT((::boost::is_same< ::std::tr1::tuple_element<1, std::pair<int, long> >::type, long>::value)); std::pair<int, long> p1; const std::pair<int, long>& p2 = p1; verify_return_type(&std::tr1::get<0>(p1), static_cast<int*>(0)); verify_return_type(&std::tr1::get<1>(p1), static_cast<long*>(0)); verify_return_type(&std::tr1::get<0>(p2), static_cast<const int*>(0)); verify_return_type(&std::tr1::get<1>(p2), static_cast<const long*>(0)); return 0; }
int main(int argc, char * const argv[]) { int opt_index, c; static struct option long_opts[] = { {"target", 1, 0, 0}, {"dumpfile", 1, 0, 0}, {"ssh", 1, 0, 0}, {0, 0, 0, 0} }; if (argc < 4 - (getenv(ENV_LUSTRE_MNTTGT)||getenv(ENV_LUSTRE_DUMPFILE))) usage(argv[0]); while ((c = getopt_long(argc, argv, "s:b:f:", long_opts, &opt_index)) != -1) { switch (c) { case 0: { if (!optarg[0]) usage(argv[0]); if (!strcmp(long_opts[opt_index].name, "target")) { setenv(ENV_LUSTRE_MNTTGT, optarg, 1); } else if (!strcmp(long_opts[opt_index].name, "dumpfile")) { setenv(ENV_LUSTRE_DUMPFILE, optarg, 1); } else if (!strcmp(long_opts[opt_index].name, "ssh")) { safe_strncpy(ssh_cmd, optarg, MAX_STRING_SIZE); } else usage(argv[0]); break; } case 's': safe_strncpy(mds_server, optarg, MAX_STRING_SIZE); break; case 'b': safe_strncpy(barrier_script, optarg, MAX_STRING_SIZE); break; case 'f': safe_strncpy(failover_script, optarg, MAX_STRING_SIZE); break; default: usage(argv[0]); } } if (optind != argc) usage(argv[0]); if (!strlen(mds_server) || !strlen(barrier_script) || !strlen(failover_script)) usage(argv[0]); /* default to using ssh */ if (!strlen(ssh_cmd)) { safe_strncpy(ssh_cmd, "ssh", MAX_STRING_SIZE); } test_ssh(); /* prepare remote command */ sprintf(barrier_cmd, "%s %s \"%s\"", ssh_cmd, mds_server, barrier_script); sprintf(failover_cmd, "%s %s \"%s\"", ssh_cmd, mds_server, failover_script); setenv(ENV_LUSTRE_TIMEOUT, "10", 1); __liblustre_setup_(); t0(); t1(); t2a(); t2b(); t3a(); t3b(); t4(); t5(); t6(); t7(); t8(); t9(); t10(); printf("liblustre is about shutdown\n"); __liblustre_cleanup_(); printf("complete successfully\n"); return 0; }