void test_element_from_odil( TInputType const & source_value, TInputType const & (odil::Element::*getter)() const) { odil::Tag const source_tag(0xdead, 0xbeef); DcmTagKey const destination_tag = odil::dcmtk::convert(source_tag); odil::Element const source(source_value, VVR); DcmElement * destination = odil::dcmtk::convert(source_tag, source); BOOST_CHECK_NE(destination, (DcmElement const *)(NULL)); BOOST_CHECK_EQUAL(destination->getVR(), VEVR); BOOST_CHECK_NE( dynamic_cast<TOutputType *>(destination), (TOutputType *)(NULL)); BOOST_CHECK_EQUAL(destination->getVM(), source.size()); for(std::size_t i=0; i<source.size(); ++i) { typedef typename odil::dcmtk::VRTraits<VEVR>::ValueType ValueType; if(typeid(TInputType) == typeid(odil::Value::Reals)) { compare<ValueType>( odil::dcmtk::ElementAccessor<ValueType>::element_get(*destination, i), (source.*getter)()[i]); } else { BOOST_CHECK_EQUAL( odil::dcmtk::ElementAccessor<ValueType>::element_get(*destination, i), (source.*getter)()[i]); } } }
BOOST_FIXTURE_TEST_CASE_TEMPLATE( equal_test, F, Fixtures, F ) { BOOST_CHECK_EQUAL( F::zero, F::zero ); BOOST_CHECK_NE( F::zero, F::P01 ); for (unsigned i = 0; i<F::Plist.size(); i++) for (unsigned j = 0; j<F::Plist.size(); j++) if (i == j) BOOST_CHECK_EQUAL( F::Plist[i], F::Plist[j] ); else BOOST_CHECK_NE( F::Plist[i], F::Plist[j] ); }
/** * @test perturbation looks quit random * - no two adjanced equal values * - all values are equally distributed. */ BOOST_FIXTURE_TEST_CASE( perturbation_looks_quit_random, advertising ) { std::map< bluetoe::link_layer::delta_time, unsigned > perturbations; bluetoe::link_layer::delta_time last_perturbation = bluetoe::link_layer::delta_time::now(); all_data( filter_channel_37, [&]( const test::schedule_data& a, const test::schedule_data& b ) { const auto current_perturbation = b.on_air_time - a.on_air_time - bluetoe::link_layer::delta_time::msec( 100 ); if ( !perturbations.empty() ) { BOOST_CHECK_NE( last_perturbation, current_perturbation ); } ++perturbations[ current_perturbation ]; last_perturbation = current_perturbation; } ); double average = 0.0; unsigned count = 0; for ( auto p : perturbations ) { average += p.first.usec() * p.second; count += p.second; } BOOST_CHECK_CLOSE_FRACTION( ( average / count ), 5.0 * 1000, 0.2 ); }
static void test_not_equal_to() { { floating_point_emulation::tfloat<T, S> f(42), g(43); BOOST_CHECK_NE(f, g); } { floating_point_emulation::tfloat<T, S> f(43), g(42); BOOST_CHECK_EQUAL(f != g, true); BOOST_CHECK_EQUAL(f != 42, true); BOOST_CHECK_EQUAL(f != 42., true); BOOST_CHECK_EQUAL(f != 43, false); BOOST_CHECK_EQUAL(f != 43., false); BOOST_CHECK_EQUAL(42 != f, true); BOOST_CHECK_EQUAL(42. != f, true); BOOST_CHECK_EQUAL(43 != f, false); BOOST_CHECK_EQUAL(43. != f, false); } }
static void test_assign() { { floating_point_emulation::tfloat<T, S> f; f = 42; BOOST_CHECK_EQUAL(f, 42); BOOST_CHECK_EQUAL(f, 42.); } { floating_point_emulation::tfloat<T, S> f; f = 42.; BOOST_CHECK_EQUAL(f, 42); BOOST_CHECK_EQUAL(f, 42.); } { floating_point_emulation::tfloat<T, S> f; f = 42.42; BOOST_CHECK_NE(f, 42); BOOST_CHECK_EQUAL(f, 42.42); } { floating_point_emulation::tfloat<T, S> f, g; f = 42; g = f; BOOST_CHECK_EQUAL(f, g); } }
static void test_create() { { floating_point_emulation::tfloat<T, S> f; BOOST_CHECK_EQUAL(f, 0); BOOST_CHECK_EQUAL(f, 0.); } { floating_point_emulation::tfloat<T, S> f(42); BOOST_CHECK_EQUAL(f, 42); BOOST_CHECK_EQUAL(f, 42.); } { floating_point_emulation::tfloat<T, S> f(42.); BOOST_CHECK_EQUAL(f, 42); BOOST_CHECK_EQUAL(f, 42.); } { floating_point_emulation::tfloat<T, S> f(42.42); BOOST_CHECK_NE(f, 42); BOOST_CHECK_EQUAL(f, 42.42); } }
BOOST_FIXTURE_TEST_CASE(test_invalid_int, F) { BOOST_CHECK_NE(egen::invalid<int>(), egen::invalid<unsigned int>()); BOOST_REQUIRE(egen::valid(42)); BOOST_REQUIRE(!egen::invalid(0)); BOOST_REQUIRE(egen::invalid(egen::invalid<int>())); }
BOOST_FIXTURE_TEST_CASE(test_invalid_double, F) { BOOST_CHECK_NE(egen::invalid<float>(), egen::invalid<double>()); BOOST_REQUIRE(egen::valid(42.0)); BOOST_REQUIRE(!egen::invalid(0.0)); BOOST_REQUIRE(egen::invalid(egen::invalid<double>())); }
int test_main(int, char*[]) { uuid_class u1; uuid_class u2; BOOST_CHECK_NE(u1, u2); BOOST_CHECK_EQUAL(u1.is_nil(), false); BOOST_CHECK_EQUAL(u2.is_nil(), false); u2 = u1; BOOST_CHECK_EQUAL(u1, u2); return 0; }
void checkFiles( const std::string& filenameA, const std::string& filenameB, bool same ) { const lunchbox::MemoryMap fileA( BRAYNS_TESTDATA + filenameA ); const lunchbox::MemoryMap fileB( BRAYNS_TESTDATA + filenameB ); BOOST_REQUIRE_EQUAL( fileA.getSize(), fileB.getSize( )); if( same ) BOOST_CHECK_EQUAL( memcmp( fileA.getAddress(), fileB.getAddress(), fileA.getSize( )), 0 ); else BOOST_CHECK_NE( memcmp( fileA.getAddress(), fileB.getAddress(), fileA.getSize( )), 0 ); }
BOOST_FIXTURE_TEST_CASE(CreateMulticastFaceV6, UdpFactoryMcastFixture) { #ifdef __linux__ // need superuser privileges to create multicast faces on Linux SKIP_IF_NOT_SUPERUSER(); #endif // __linux__ SKIP_IF_UDP_MCAST_V6_NETIF_COUNT_LT(1); auto multicastFace1 = createMulticastFace("::1", "ff02::114", 20070); auto multicastFace1a = createMulticastFace("::1", "ff02::114", 20070); auto multicastFace2 = createMulticastFace("::1", "ff02::114", 20030); BOOST_CHECK_EQUAL(multicastFace1, multicastFace1a); BOOST_CHECK_NE(multicastFace1, multicastFace2); auto address = findNonLoopbackAddressForMulticastFace(ndn::net::AddressFamily::V6); if (!address.is_unspecified()) { auto multicastFace3 = createMulticastFace(address.to_string(), "ff02::114", 20070); BOOST_CHECK_NE(multicastFace1, multicastFace3); BOOST_CHECK_NE(multicastFace2, multicastFace3); } // create with a local endpoint already used by a channel auto channel = createChannel("::1", 20071); BOOST_CHECK_EXCEPTION(createMulticastFace("::1", "ff02::114", 20071), UdpFactory::Error, [] (const UdpFactory::Error& e) { return strcmp(e.what(), "Cannot create UDP multicast face on [::1]:20071, " "endpoint already allocated for a UDP channel") == 0; }); // create with a local endpoint already used by a multicast face on a different multicast group BOOST_CHECK_EXCEPTION(createMulticastFace("::1", "ff02::42", 20070), UdpFactory::Error, [] (const UdpFactory::Error& e) { return strcmp(e.what(), "Cannot create UDP multicast face on [::1]:20070, " "endpoint already allocated for a different UDP multicast face") == 0; }); }
static void test_unary() { { floating_point_emulation::tfloat<T, S> f(42), g(0); BOOST_CHECK_EQUAL(!f, false); BOOST_CHECK_EQUAL(!!f, true); BOOST_CHECK_EQUAL(!g, true); BOOST_CHECK_EQUAL(!!g, false); } { floating_point_emulation::tfloat<T, S> f(42), g(-42); BOOST_CHECK_NE(f, g); BOOST_CHECK_EQUAL(f, -g); BOOST_CHECK_EQUAL(-f, -42); BOOST_CHECK_EQUAL(-f, -42.); BOOST_CHECK_EQUAL(-42, -f); BOOST_CHECK_EQUAL(-42., -f); BOOST_CHECK_EQUAL(-f == g, true); BOOST_CHECK_EQUAL(f == -g, true); BOOST_CHECK_EQUAL(-g == f, true); BOOST_CHECK_EQUAL(g == -f, true); BOOST_CHECK_EQUAL(-f == -42, true); BOOST_CHECK_EQUAL(-f == -42., true); BOOST_CHECK_EQUAL(-42 == -f, true); BOOST_CHECK_EQUAL(-42. == -f, true); } { floating_point_emulation::tfloat<T, S> f(42); BOOST_CHECK_EQUAL(+f == f, true); BOOST_CHECK_EQUAL(f == +f, true); BOOST_CHECK_EQUAL(+f == 42, true); BOOST_CHECK_EQUAL(+f == 42., true); BOOST_CHECK_EQUAL(42 == +f, true); BOOST_CHECK_EQUAL(42. == +f, true); } }
BOOST_FIXTURE_TEST_CASE_TEMPLATE( operator_mult_coxeter_test, F, PermFixtures, F ) { for (uint64_t i=0; i<15; i++) { auto si = F::PermType::elementary_transposition(i); BOOST_CHECK_NE(si, F::id); BOOST_CHECK_EQUAL(si * si, F::id); if (i+1 < 15) { auto si1 = F::PermType::elementary_transposition(i+1); BOOST_CHECK_EQUAL(si * si1 * si, si1 * si * si1); } for (uint64_t j=i+2; j<15; j++) { auto sj = F::PermType::elementary_transposition(j); BOOST_CHECK_EQUAL(sj * si, si * sj); } } }
BOOST_FIXTURE_TEST_CASE (Common__GenericLogger_newLog_general, GenericLogger_TestClass) { Common__GenericLogger_TestTraits::reset(); // Anything but debug must be here, otherwise, we have troubles with the NULL // pointers... std::stringstream f_str; f_str << "thread:" << ThreadTraits::get_id() << _separator(); // Check test initial conditions. Actual log level cannot be debug level // (we test the non-debug case, and we must ensure that it really changed // to a new value after newlog. _actLogLevel = Common__GenericLogger_TestTraits::INFO; BOOST_CHECK_NE (_logLine, f_str); // Start real test... GenericLogger_TestClass& returnedClass = newLog<Common__GenericLogger_TestTraits::ERR> (NULL, NULL, 0); // Check if syslog was written with old content BOOST_CHECK ( Common__GenericLogger_TestTraits::syslogCalled ); // New log level stored? BOOST_CHECK_EQUAL (_actLogLevel, static_cast<int>(Common__GenericLogger_TestTraits::ERR)); // Initial log line is the required one? BOOST_CHECK_EQUAL (_logLine.str(), f_str.str()); // Check if the returned class contains the same data than this one BOOST_CHECK_EQUAL (this, &returnedClass); }
BOOST_FIXTURE_TEST_CASE(testKey, PlayerTest) { // Key has to be unique Player tmp("Tmp", ""); BOOST_CHECK_NE(p1.getKey(), tmp.getKey()); }
static void test_subtract() { { floating_point_emulation::tfloat<T, S> f; f -= 42; BOOST_CHECK_EQUAL(f, -42); BOOST_CHECK_EQUAL(f, -42.); } { floating_point_emulation::tfloat<T, S> f; f += -42.; BOOST_CHECK_EQUAL(f, -42); BOOST_CHECK_EQUAL(f, -42.); } { floating_point_emulation::tfloat<T, S> f; f -= 42.4; BOOST_CHECK_EQUAL(f, -42.4); } { floating_point_emulation::tfloat<T, S> f, g(42); f -= g; BOOST_CHECK_EQUAL(f, -42); BOOST_CHECK_EQUAL(f, -42.); } { floating_point_emulation::tfloat<T, S> f, g(42.42); f -= g; BOOST_CHECK_NE(f, -42); BOOST_CHECK_EQUAL(f, -42.42); } { floating_point_emulation::tfloat<T, S> f(-142); f -= -42; BOOST_CHECK_EQUAL(f, -100); BOOST_CHECK_EQUAL(f, -100.); } { floating_point_emulation::tfloat<T, S> f(-142); f -= -42.; BOOST_CHECK_EQUAL(f, -100); BOOST_CHECK_EQUAL(f, -100.); } { floating_point_emulation::tfloat<T, S> f(-142), g(42); f -= -g; BOOST_CHECK_EQUAL(f, -100); BOOST_CHECK_EQUAL(f, -100.); } { floating_point_emulation::tfloat<T, S> f(-100), g(-42.4); f -= -g; BOOST_CHECK_NE(f, -142); BOOST_CHECK_EQUAL(f, -142.4); } }
BOOST_FIXTURE_TEST_CASE(MultipleAccepts, EndToEndFixture) { Interest interest1("ndn:/TpnzGvW9R"); Interest interest2("ndn:/QWiIMfj5sL"); UdpFactory factory; shared_ptr<UdpChannel> channel1 = factory.createChannel("127.0.0.1", "20070"); shared_ptr<UdpChannel> channel2 = factory.createChannel("127.0.0.1", "20071"); channel1->listen(bind(&EndToEndFixture::channel_onFaceCreated, this, _1), bind(&EndToEndFixture::channel_onConnectFailed, this, _1)); channel2->connect("127.0.0.1", "20070", bind(&EndToEndFixture::channel2_onFaceCreated, this, _1), bind(&EndToEndFixture::channel_onConnectFailed, this, _1)); BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(4)) == LimitedIo::EXCEED_OPS, "UdpChannel error: cannot connect or cannot accept connection"); BOOST_CHECK_EQUAL(faces.size(), 1); shared_ptr<UdpChannel> channel3 = factory.createChannel("127.0.0.1", "20072"); channel3->connect("127.0.0.1", "20070", bind(&EndToEndFixture::channel3_onFaceCreated, this, _1), bind(&EndToEndFixture::channel_onConnectFailed, this, _1)); shared_ptr<UdpChannel> channel4 = factory.createChannel("127.0.0.1", "20073"); BOOST_CHECK_NE(channel3, channel4); scheduler::schedule(time::milliseconds(500), bind(&UdpChannel::connect, channel4, "127.0.0.1", "20070", // does not work without static_cast static_cast<UdpChannel::FaceCreatedCallback>( bind(&EndToEndFixture::channel_onFaceCreated, this, _1)), static_cast<UdpChannel::ConnectFailedCallback>( bind(&EndToEndFixture::channel_onConnectFailed, this, _1)))); scheduler::schedule(time::milliseconds(400), bind(&EndToEndFixture::checkFaceList, this, 2)); BOOST_CHECK_MESSAGE(limitedIo.run(2,// 2 connects time::seconds(4)) == LimitedIo::EXCEED_OPS, "UdpChannel error: cannot connect or cannot accept multiple connections"); BOOST_CHECK_EQUAL(faces.size(), 3); face2->sendInterest(interest1); BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS, "UdpChannel error: cannot send or receive Interest/Data packets"); BOOST_CHECK_EQUAL(faces.size(), 4); face3->sendInterest(interest2); BOOST_CHECK_MESSAGE(limitedIo.run(1, time::seconds(1)) == LimitedIo::EXCEED_OPS, "UdpChannel error: cannot send or receive Interest/Data packets"); //channel1 should have created 2 faces, one when face2 sent an interest, one when face3 sent an interest BOOST_CHECK_EQUAL(faces.size(), 5); BOOST_CHECK_THROW(channel1->listen(bind(&EndToEndFixture::channel_onFaceCreated, this, _1), bind(&EndToEndFixture::channel_onConnectFailedOk, this, _1)), UdpChannel::Error); }