void signal_vector_unit_tests() { class signal_vector_test_class : public signal_vector< double > { }; signal_vector_test_class svtc; signal_vector_test_class svtc2( svtc ); common::bar_type b1; BOOST_CHECK_NO_THROW( svtc.insert( &b1, new double( 1.5 ) ) ); common::bar_type b2; BOOST_CHECK_NO_THROW( svtc.insert( &b2, new double( 1.3 ) ) ); { const double* throw_double( new double( 1.3 ) ); BOOST_CHECK_THROW( svtc.insert( &b2, throw_double ), std::exception ); } const double* e = svtc.at( &b2 ); BOOST_CHECK_EQUAL( *e, 1.3 ); BOOST_CHECK_EQUAL( *svtc2.at( &b1 ), 1.5 ); BOOST_CHECK_EQUAL( *svtc.at( &b1 ), 1.5 ); BOOST_CHECK_NO_THROW( svtc2.clear() ); BOOST_CHECK_NO_THROW( svtc.at( &b1 ) ); BOOST_CHECK_EQUAL( svtc.at( &b1 ) == NULL, true ); BOOST_CHECK_NO_THROW( svtc.subscription_check( typeid( double ) ) ); BOOST_CHECK_THROW( svtc2.subscription_check( typeid( float ) ), std::exception ); }
// // Constructor test cases // void SecurityFileTestCases::TestCase_Constructor() { TIdent configuredCustomers(5000); TIdent activeCustomers(5000); TPCE::TextFileSplitter* splitter = new TPCE::TextFileSplitter("../../../flat_in/Security.txt"); TPCE::SecurityDataFile_t* df = new TPCE::SecurityDataFile_t(*splitter); TPCE::CSecurityFile* file; // Construct the object. BOOST_CHECK_NO_THROW( file = new TPCE::CSecurityFile(*df, configuredCustomers, activeCustomers, TPCE::iBaseCompanyCount) ); CleanUp(&file); CleanUp(&df); CleanUp(&splitter); // Change the scale. configuredCustomers = 10000; activeCustomers = 10000; splitter = new TPCE::TextFileSplitter("../../../flat_in/Security.txt"); df = new TPCE::SecurityDataFile_t(*splitter); // Construct the object. BOOST_CHECK_NO_THROW( file = new TPCE::CSecurityFile(*df, configuredCustomers, activeCustomers, TPCE::iBaseCompanyCount) ); CleanUp(&file); CleanUp(&df); CleanUp(&splitter); }
/// \brief TODOCUMENT void operator()() { constexpr std_classn_rate_stat to_test = get<0>( get<I>( properties_of_classn_rate_stat::numerator_and_denominator_of_stat ) ); BOOST_CHECK_NO_THROW( classn_rate_stat<to_test>() ); classn_rate_stat<to_test> stat; BOOST_CHECK_NO_THROW( stat.get_name() ); BOOST_CHECK_GT( stat.get_name().length(), 0 ); }
void queue_logger_constructor_tests() { std::stringstream str; queue_logger<>::tasker task_processor( 4 ); BOOST_CHECK_NO_THROW( queue_logger<> first_logger( str, task_processor ) ); BOOST_CHECK_NO_THROW( queue_logger<> second_logger( str, task_processor ) ); }
void test_image_formats() { BOOST_CHECK_NO_THROW(TileIdentifier::Create((const string&)"/stylesheet/0/0/0.png", ssm)); BOOST_CHECK_NO_THROW(TileIdentifier::Create((const string&)"/stylesheet/0/0/0.svg", ssm)); BOOST_CHECK_THROW(TileIdentifier::Create((const string&)"/stylesheet/0/0/0.jpg", ssm), excp::UnknownImageFormatException); BOOST_CHECK_THROW(TileIdentifier::Create((const string&)"/stylesheet/0/0/0.jpeg", ssm), excp::UnknownImageFormatException); BOOST_CHECK_THROW(TileIdentifier::Create((const string&)"/stylesheet/0/0/0.gif", ssm), excp::UnknownImageFormatException); BOOST_CHECK_THROW(TileIdentifier::Create((const string&)"/stylesheet/0/0/0.svgz", ssm), excp::UnknownImageFormatException); }
void logger_constructor_tests() { std::stringstream str; BOOST_CHECK_NO_THROW( (logger< false >( str )) ); BOOST_CHECK_NO_THROW( (logger< true >( str )) ); BOOST_CHECK_NO_THROW( (logger< true, false >( str )) ); BOOST_CHECK_NO_THROW( (logger< true, false, false >( str )) ); BOOST_CHECK_NO_THROW( (logger< true, true, false >( str )) ); }
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_auto_ptr_value, mock_error_fixture ) { { mock::detail::function< std::auto_ptr< int >() > f; std::auto_ptr< int > ptr( new int( 3 ) ); f.expect().returns( boost::ref( ptr ) ); BOOST_CHECK_EQUAL( 3, *ptr ); BOOST_CHECK_EQUAL( 3, *f() ); BOOST_CHECK( ! ptr.get() ); BOOST_CHECK( ! f().get() ); CHECK_CALLS( 2 ); } { mock::detail::function< std::auto_ptr< int >() > f; std::auto_ptr< int > ptr( new int( 3 ) ); f.expect().returns( ptr ); BOOST_CHECK( ! ptr.get() ); BOOST_CHECK_EQUAL( 3, *f() ); BOOST_CHECK( ! f().get() ); CHECK_CALLS( 2 ); } { mock::detail::function< std::auto_ptr< int >() > f; f.expect().returns( new int( 3 ) ); BOOST_CHECK_EQUAL( 3, *f() ); BOOST_CHECK( ! f().get() ); CHECK_CALLS( 2 ); } { mock::detail::function< std::auto_ptr< int >() > f; f.expect().returns( std::auto_ptr< int >( new int( 3 ) ) ); BOOST_CHECK_EQUAL( 3, *f() ); BOOST_CHECK( ! f().get() ); CHECK_CALLS( 2 ); } { mock::detail::function< std::auto_ptr< base >() > f; f.expect().returns( new derived ); BOOST_CHECK_NO_THROW( f() ); CHECK_CALLS( 1 ); } { mock::detail::function< std::auto_ptr< base >() > f; f.expect().returns( std::auto_ptr< base >( new derived ) ); BOOST_CHECK_NO_THROW( f() ); CHECK_CALLS( 1 ); } { mock::detail::function< std::auto_ptr< base >() > f; f.expect().returns( std::auto_ptr< derived >( new derived ) ); BOOST_CHECK_NO_THROW( f() ); CHECK_CALLS( 1 ); } }
void test_delete_tiles() { char* argv[] = {(char*)"ala.carte", (char*)"ala.carte"}; ConfigMockup* mock = new ConfigMockup(); shared_ptr<Configuration> config = mock->Config(argv, 2); shared_ptr<Cache> cache = shared_ptr<Cache>(new Cache(config)); // Delete not existing cache. BOOST_CHECK_NO_THROW(cache->deleteTiles("nothing")); shared_ptr<TileIdentifier> ti = boost::make_shared<TileIdentifier>(0, 0, 0, "default", TileIdentifier::Format::PNG); BOOST_CHECK_NO_THROW(cache->getTile(ti)); // Delete existing cache. BOOST_CHECK_NO_THROW(cache->deleteTiles("/default")); }
static void Copy( std::random_device & generator ) { String connectionString; DatabaseConnectionSPtr connection = std::make_shared< CDatabaseTestConnection >( TEST_GOOD_SERVER, TEST_GOOD_USER, TEST_GOOD_PASSWORD, connectionString ); connection->SelectDatabase( TEST_GOOD_DATABASE ); CDatabaseValue< ValueType > valueA( connection ); BOOST_CHECK_NO_THROW( valueA.SetValue( DatabaseUtils::Helpers< ValueType >::GetRandomValue( generator ) ) ); CDatabaseValue< ValueType > valueB( connection ); BOOST_CHECK_NO_THROW( valueB.SetValue( DatabaseUtils::Helpers< ValueType >::GetRandomValue( generator ) ) ); BOOST_CHECK_NO_THROW( valueA.SetValue( valueB ) ); BOOST_CHECK_EQUAL( valueA.GetValue(), valueB.GetValue() ); }
void async_tests_work() { // this test dependent on tcp port availability, please be sure that 50000 port is free static const unsigned short port = 50000; detail::tcp_client_manager_test tcp_manager; { detail::async_tcp_helper helper( port ); boost::this_thread::sleep( boost::posix_time::milliseconds( 10 ) ); tcp_client client( tcp_manager, "127.0.0.1", port ); boost::this_thread::sleep( boost::posix_time::milliseconds( 10 ) ); BOOST_CHECK_NO_THROW( helper.check_connection() ); BOOST_CHECK_NO_THROW( helper.close_socket() ); } { detail::async_tcp_helper helper( port ); boost::this_thread::sleep( boost::posix_time::milliseconds( 10 ) ); tcp_client client( tcp_manager, "127.0.0.1", port ); boost::this_thread::sleep( boost::posix_time::milliseconds( 10 ) ); BOOST_CHECK_NO_THROW( helper.send() ); BOOST_CHECK_NO_THROW( helper.check_connection() ); boost::this_thread::sleep( boost::posix_time::milliseconds( 10 ) ); BOOST_CHECK_NO_THROW( helper.close_socket() ); } { detail::async_tcp_helper helper( port ); boost::this_thread::sleep( boost::posix_time::milliseconds( 10 ) ); tcp_client client( tcp_manager, "127.0.0.1", port ); boost::this_thread::sleep( boost::posix_time::milliseconds( 10 ) ); BOOST_CHECK_NO_THROW( client.write( "test", 4 ) ); BOOST_CHECK_NO_THROW( helper.check_connection() ); boost::this_thread::sleep( boost::posix_time::milliseconds( 10 ) ); BOOST_CHECK_NO_THROW( helper.close_socket() ); } }
void test_base() { Range16 r(0, 5); BOOST_CHECK(r.length() == 6); BOOST_CHECK(r.begin() == 0); BOOST_CHECK(r.end() == 5); BOOST_CHECK(r.contains(0)); BOOST_CHECK(r.contains(3)); BOOST_CHECK(r.contains(5)); BOOST_CHECK(!r.contains(6)); BOOST_CHECK(!r.contains(100)); BOOST_CHECK_THROW(r.begin(6), std::exception); BOOST_CHECK_NO_THROW(r.begin(5)); BOOST_CHECK(r.length() == 1); BOOST_CHECK_NO_THROW(r.end(10)); BOOST_CHECK(r.begin() == 5); BOOST_CHECK(r.end() == 10); BOOST_CHECK(r.length() == 6); Range16 r1(0, 5); Range16 r2(0, 2); BOOST_CHECK(r1.contains(r2)); BOOST_CHECK(r1.contains(0, 0)); BOOST_CHECK(r1.contains(Range16(5, 5))); BOOST_CHECK(r1.contains(5, 6)); BOOST_CHECK(!r1.contains(6, 6)); BOOST_CHECK(r1.containsFull(r2)); BOOST_CHECK(r1.containsFull(0, 4)); BOOST_CHECK(r1.containsFull(0, 5)); BOOST_CHECK(!r1.containsFull(0, 6)); BOOST_CHECK(r1.containsFull(5, 5)); BOOST_CHECK(r1.containsFull(Range16(1, 5))); BOOST_CHECK(!r1.containsFull(Range16(6, 6))); BOOST_CHECK(!r1.containsFull(5, 10)); Range16 r3(20, 30); Range16 r4( 3, 10); BOOST_CHECK(!r3.contains(r4)); BOOST_CHECK(!r3.borders(r4)); // test comparison operators BOOST_CHECK(r1 != r2); BOOST_CHECK(r2 != r1); BOOST_CHECK(r3 != r4); // BOOST_CHECK(r3 > r4); // BOOST_CHECK(r4 < r3); }
// // Constructor test cases // void StringSplitterTestCases::TestCase_Constructor_Default() { // Construct the object. BOOST_CHECK_NO_THROW( splitter1 = new TPCE::StringSplitter(defaultTestString) ); CleanUp(&splitter1); // Construct the object. BOOST_CHECK_NO_THROW( splitter1 = new TPCE::StringSplitter(mixedTestString, '_') ); CleanUp(&splitter1); // Construct the object. BOOST_CHECK_NO_THROW( splitter1 = new TPCE::StringSplitter(customTestString, '_', '-') ); CleanUp(&splitter1); }
BOOST_AUTO_TEST_CASE_TEMPLATE(InstanceName, T, Tests) { BOOST_REQUIRE(T::Strategy::getStrategyName().at(-1).isVersion()); uint64_t maxVersion = T::Strategy::getStrategyName().at(-1).toVersion(); BOOST_REQUIRE_LE(T::getMinVersion(), maxVersion); Forwarder forwarder; for (uint64_t version = T::getMinVersion(); version <= maxVersion; ++version) { Name versionedName = T::getVersionedStrategyName(version); unique_ptr<typename T::Strategy> instance; BOOST_CHECK_NO_THROW(instance = make_unique<typename T::Strategy>(forwarder, versionedName)); BOOST_CHECK_EQUAL(instance->getInstanceName(), versionedName); if (!T::canAcceptParameters()) { Name nameWithParameters = Name(versionedName).append("param"); BOOST_CHECK_THROW(typename T::Strategy(forwarder, nameWithParameters), std::invalid_argument); } } if (T::getMinVersion() > 0) { Name version0Name = T::getVersionedStrategyName(0); BOOST_CHECK_THROW(typename T::Strategy(forwarder, version0Name), std::invalid_argument); Name earlyVersionName = T::getVersionedStrategyName(T::getMinVersion() - 1); BOOST_CHECK_THROW(typename T::Strategy(forwarder, earlyVersionName), std::invalid_argument); } if (maxVersion < std::numeric_limits<uint64_t>::max()) { Name versionMaxName = T::getVersionedStrategyName(std::numeric_limits<uint64_t>::max()); BOOST_CHECK_THROW(typename T::Strategy(forwarder, versionMaxName), std::invalid_argument); Name lateVersionName = T::getVersionedStrategyName(maxVersion + 1); BOOST_CHECK_THROW(typename T::Strategy(forwarder, lateVersionName), std::invalid_argument); } }
void decodeFibEntryBlock(const Data& data) { Block payload = data.getContent(); m_buffer.appendByteArray(payload.value(), payload.value_size()); BOOST_CHECK_NO_THROW(data.getName()[-1].toSegment()); if (data.getFinalBlockId() != data.getName()[-1]) { return; } // wrap the FIB Entry blocks in a single Content TLV for easy parsing m_buffer.prependVarNumber(m_buffer.size()); m_buffer.prependVarNumber(ndn::Tlv::Content); ndn::Block parser(m_buffer.buf(), m_buffer.size()); parser.parse(); BOOST_REQUIRE_EQUAL(parser.elements_size(), m_referenceEntries.size()); for (Block::element_const_iterator i = parser.elements_begin(); i != parser.elements_end(); ++i) { if (i->type() != ndn::tlv::nfd::FibEntry) { BOOST_FAIL("expected fib entry, got type #" << i->type()); } validateFibEntry(*i); } m_finished = true; }
void test_correct() { shared_ptr<TileIdentifier> ti; BOOST_CHECK_NO_THROW(ti = TileIdentifier::Create((const string&)"/folder/stylesheet/2/1/0.svg", ssm)); BOOST_CHECK_EQUAL(ti->getX(), 1); BOOST_CHECK_EQUAL(ti->getY(), 0); BOOST_CHECK_EQUAL(ti->getZoom(), 2); BOOST_CHECK_EQUAL(ti->getImageFormat(), TileIdentifier::Format::SVG); BOOST_CHECK_EQUAL(ti->getStylesheetPath(), "folder/stylesheet"); BOOST_CHECK_NO_THROW(ti = TileIdentifier::CreateEmptyTID(ti->getStylesheetPath(), ti->getImageFormat())); BOOST_CHECK_EQUAL(ti->getX(), -2); BOOST_CHECK_EQUAL(ti->getY(), -2); BOOST_CHECK_EQUAL(ti->getZoom(), -2); BOOST_CHECK_EQUAL(ti->getImageFormat(), TileIdentifier::Format::SVG); BOOST_CHECK_EQUAL(ti->getStylesheetPath(), "folder/stylesheet"); BOOST_CHECK(ti->isNoneDataIdentifier()); }
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_moves_the_set_rvalue, mock_error_fixture ) { mock::detail::function< int() > f; f.expect().moves( 3 ); BOOST_CHECK_NO_THROW( f() ); CHECK_CALLS( 1 ); }
void check_requestTile(std::string url, HttpRequest::Reply::StatusType responseStatus = HttpRequest::Reply::ok) { int result = -2; BOOST_CHECK_NO_THROW((result = sendRequest(url))); BOOST_CHECK_EQUAL(result, (int)responseStatus); }
static void simple_work_tests() { const int lowest=-10, highest=10; const int range = ( highest-lowest ) + 1; int cents = lowest + int( range * rand() / ( RAND_MAX + 1.0 ) ); { typedef double number_type; const size_t window = 5; moving_median<number_type> median( window ); BOOST_CHECK_THROW( median.get_median(), std::logic_error ); const number_type value = 16; for ( int i = 0; i < 100; ++i) { cents = lowest + int( range * rand() / ( RAND_MAX + 1.0 ) ); const number_type value_to_add = ( i % 3 == 0 ) ? value + (double)cents / 100 : value; median.add_element( value_to_add ); if ( i < window - 1 ) { BOOST_CHECK_EQUAL( median.get_median(), value_to_add ); } else { BOOST_CHECK_EQUAL( median.get_median(), value ); } } } { typedef double number_type; const size_t window = 19; moving_median< number_type> median( window ); BOOST_CHECK_THROW( median.get_median(), std::logic_error ); const number_type value = 16; const double cents = 0.01; for ( int i = 0; i < 100; ++i) { const number_type value_to_add = ( i % 2 == 0 ) ? value + (double)cents / 100 : value; median.add_element( value_to_add ); if ( i < window - 1 ) { BOOST_CHECK_EQUAL( median.get_median(), value_to_add ); } else { BOOST_CHECK_EQUAL( median.get_median(), value_to_add ); } } } { /// simple adding the same value moving_median< double > median( 5 ); for ( size_t i = 0 ; i < 1000 ; ++i ) BOOST_CHECK_NO_THROW( median.add_element( 0.9999999990621 ) ); } }
static void All() { static const String FieldName = STR( "coin" ); DatabaseValuedObjectInfosSPtr infos; BOOST_CHECK_NO_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName ) ); BOOST_CHECK( infos ); BOOST_CHECK( infos->GetName() == FieldName ); BOOST_CHECK( infos->GetType() == EFieldType_NULL ); BOOST_CHECK_NO_THROW( infos->SetType( FieldType ) ); BOOST_CHECK( infos->GetType() == FieldType ); BOOST_CHECK_NO_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName, FieldType ) ); BOOST_CHECK( infos->GetType() == FieldType ); BOOST_CHECK_NO_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName, FieldType, 0 ) ); BOOST_CHECK( infos->GetType() == FieldType ); BOOST_CHECK_NO_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName, FieldType, std::make_pair( 0, 0 ) ) ); BOOST_CHECK( infos->GetType() == FieldType ); }
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_moves_the_set_unique_ptr_lvalue, mock_error_fixture ) { mock::detail::function< std::unique_ptr< int >() > f; std::unique_ptr< int > p( new int ); f.expect().moves( std::move( p ) ); BOOST_CHECK_NO_THROW( f() ); CHECK_CALLS( 1 ); }
void task4_5::tests_::solution_simple_tests() { task4_5::data_type data; BOOST_CHECK_NO_THROW( solution s( data ) ); solution s( data ); BOOST_CHECK_EQUAL( s.get_min(), 0 ); BOOST_CHECK_EQUAL( s.get_max(), 0 ); }
BOOST_FIXTURE_TEST_CASE(EcdsaSigningByIdentityNoCert, IdentityManagementFixture) { Data data("/test/data"); Name nonExistingIdentity = Name("/non-existing/identity").appendVersion(); BOOST_CHECK_NO_THROW(m_keyChain.sign(data, signingByIdentity(nonExistingIdentity))); BOOST_CHECK_EQUAL(data.getSignature().getType(), KeyChain::getSignatureType(KeyChain::DEFAULT_KEY_PARAMS.getKeyType(), DigestAlgorithm::SHA256)); BOOST_CHECK(nonExistingIdentity.isPrefixOf(data.getSignature().getKeyLocator().getName())); Name ecdsaIdentity = Name("/ndn/test/ecdsa").appendVersion(); Name ecdsaKeyName = m_keyChain.generateEcdsaKeyPairAsDefault(ecdsaIdentity, false, 256); BOOST_CHECK_NO_THROW(m_keyChain.sign(data, signingByIdentity(ecdsaIdentity))); BOOST_CHECK_EQUAL(data.getSignature().getType(), KeyChain::getSignatureType(EcdsaKeyParams().getKeyType(), DigestAlgorithm::SHA256)); BOOST_CHECK(ecdsaIdentity.isPrefixOf(data.getSignature().getKeyLocator().getName())); }
static void QueryValue( std::random_device & generator ) { String connectionString; DatabaseConnectionSPtr connection = std::make_shared< CDatabaseTestConnection >( TEST_GOOD_SERVER, TEST_GOOD_USER, TEST_GOOD_PASSWORD, connectionString ); connection->SelectDatabase( TEST_GOOD_DATABASE ); CDatabaseValue< ValueType > value( connection ); auto val = DatabaseUtils::Helpers< ValueType >::GetRandomValue( generator ); BOOST_CHECK_NO_THROW( value.SetValue( val ) ); ValueChecker< ValueType >::QueryValueCompare( connection, value, val ); }
void checkValidity(std::string parameters, bool isCorrect) { Name strategyName(Name(AsfStrategy::getStrategyName()).append(parameters)); if (isCorrect) { BOOST_CHECK_NO_THROW(make_unique<AsfStrategy>(forwarder, strategyName)); } else { BOOST_CHECK_THROW(make_unique<AsfStrategy>(forwarder, strategyName), std::invalid_argument); } }
static void All() { static const String FieldName = STR( "coin" ); static const std::pair< uint32_t, uint32_t > FieldPrecision = std::make_pair( 10, 5 ); DatabaseValuedObjectInfosSPtr infos; BOOST_CHECK_NO_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName ) ); BOOST_CHECK( infos ); BOOST_CHECK( infos->GetName() == FieldName ); BOOST_CHECK( infos->GetType() == EFieldType_NULL ); BOOST_CHECK_THROW( infos->SetType( FieldType ), CDatabaseException ); BOOST_CHECK_THROW( infos->SetType( FieldType, FieldPrecision.first ), CDatabaseException ); BOOST_CHECK_NO_THROW( infos->SetType( FieldType, FieldPrecision ) ); BOOST_CHECK( infos->GetType() == FieldType ); BOOST_CHECK( infos->GetPrecision() == FieldPrecision ); BOOST_CHECK_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName, FieldType ), CDatabaseException ); BOOST_CHECK_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName, FieldType, FieldPrecision.first ), CDatabaseException ); BOOST_CHECK_NO_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName, FieldType, FieldPrecision ) ); BOOST_CHECK( infos->GetType() == FieldType ); BOOST_CHECK( infos->GetPrecision() == FieldPrecision ); }
void multikey_tree_with_map_comparator_tests() { static const size_t test_size = 1000; { time_tracker tt; multikey_tree< size_t > mkt; for ( size_t i = 0 ; i < test_size ; ++i ) BOOST_CHECK_NO_THROW( (*mkt.get_for_edit( get_random_stock_name( 4 ) )) = i ); for ( size_t i = 0 ; i < test_size ; ++i ) BOOST_CHECK_NO_THROW( (*mkt.get_for_edit( get_random_stock_name( 4 ) )) = i ); } { time_tracker tt; std::map< std::string, size_t > mt; for ( size_t i = 0 ; i < test_size ; ++i ) mt[ get_random_stock_name( 4 ) ] = i; for ( size_t i = 0 ; i < test_size ; ++i ) mt[ get_random_stock_name( 4 ) ] = i; } }
BOOST_AUTO_TEST_CASE_TEMPLATE(http_client_get_test, client, client_types) { typename client::request request("http://www.boost.org"); client client_; typename client::response response; BOOST_CHECK_NO_THROW ( response = client_.get(request) ); typename net::headers_range<typename client::response>::type range = headers(response)["Content-Type"]; BOOST_CHECK ( !boost::empty(range) ); BOOST_CHECK ( body(response).size() != 0 ); BOOST_CHECK_EQUAL ( response.version().substr(0,7), std::string("HTTP/1.") ); BOOST_CHECK_EQUAL ( response.status(), 200u ); BOOST_CHECK_EQUAL ( response.status_message(), std::string("OK") ); }
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_the_set_shared_ptr_value, mock_error_fixture ) { { mock::detail::function< boost::shared_ptr< base >() > f; f.expect().returns( new derived ); BOOST_CHECK_NO_THROW( f() ); CHECK_CALLS( 1 ); } { mock::detail::function< const boost::shared_ptr< base >&() > f; f.expect().returns( new derived ); BOOST_CHECK_NO_THROW( f() ); CHECK_CALLS( 1 ); } { mock::detail::function< boost::shared_ptr< base >&() > f; f.expect().returns( new derived ); BOOST_CHECK_NO_THROW( f() ); CHECK_CALLS( 1 ); } }
static void All() { static const String FieldName = STR( "coin" ); static const uint32_t FieldLimits = 10; DatabaseValuedObjectInfosSPtr infos; BOOST_CHECK_NO_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName ) ); BOOST_CHECK( infos ); BOOST_CHECK( infos->GetName() == FieldName ); BOOST_CHECK( infos->GetType() == EFieldType_NULL ); BOOST_CHECK_THROW( infos->SetType( FieldType ), CDatabaseException ); BOOST_CHECK_NO_THROW( infos->SetType( FieldType, FieldLimits ) ); BOOST_CHECK( infos->GetType() == FieldType ); BOOST_CHECK( infos->GetLimits() == FieldLimits ); BOOST_CHECK_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName, FieldType ), CDatabaseException ); BOOST_CHECK_NO_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName, FieldType, FieldLimits ) ); BOOST_CHECK( infos->GetType() == FieldType ); BOOST_CHECK( infos->GetLimits() == FieldLimits ); BOOST_CHECK_NO_THROW( infos = std::make_shared< CDatabaseValuedObjectInfos >( FieldName, FieldType, std::make_pair( FieldLimits, 0 ) ) ); BOOST_CHECK( infos->GetType() == FieldType ); BOOST_CHECK( infos->GetLimits() == FieldLimits ); }
BOOST_FIXTURE_TEST_CASE( triggering_an_expectation_returns_by_reference, mock_error_fixture ) { { mock::detail::function< base&() > f; derived b; f.expect().returns( boost::ref( b ) ); BOOST_CHECK_NO_THROW( f() ); CHECK_CALLS( 1 ); } { mock::detail::function< base&() > f; derived b; f.expect().returns( b ); BOOST_CHECK_NO_THROW( f() ); CHECK_CALLS( 1 ); } { mock::detail::function< undefined&() > f; f.expect().returns( boost::ref( get_undefined() ) ); f.reset(); } }