BOOST_FIXTURE_TEST_CASE(UnregisterWithoutConnection, RemoteRegistratorFixture) { connectToHub(); disconnectToHub(); Name indentity("/remote/register"); remoteRegistrator->m_regEntries.insert( nfd::rib::RemoteRegistrator::RegisteredEntry(indentity, scheduler::EventId())); eraseEntryWithIdentity(indentity); BOOST_REQUIRE_EQUAL(face->sentInterests.size(), 0); }
BOOST_FIXTURE_TEST_CASE( previous, previous_fixture ) { it_u8 = enc_u8_end; for (size_t i = dec.size( ); i > 0; --i) { std::string::const_iterator last = it_u8; BOOST_TEST_CHECKPOINT( "i=" << i << " cp=U+" << std::hex << (uint32_t)dec[i - 1] ); char32_t cp = lib::previous( it_u8 ); BOOST_REQUIRE_EQUAL( cp, dec[i - 1] ); BOOST_REQUIRE( it_u8 == last - enc_u8_cp_size[i - 1] ); } }
BOOST_FIXTURE_TEST_CASE(BlockedPaths, WorldFixtureEmpty0P) { MapPoint startPt(10, 10); // Create a circle of stones so the path is completely blocked std::vector<MapPoint> surroundingPts = world.GetPointsInRadius(startPt, 1); BOOST_FOREACH(const MapPoint& pt, surroundingPts) world.SetNO(pt, new noGranite(GT_1, 1)); std::vector<MapPoint> surroundingPts2; for(unsigned i=0; i<12; i++) surroundingPts2.push_back(world.GetNeighbour2(startPt, i)); BOOST_FOREACH(const MapPoint& pt, surroundingPts2) BOOST_REQUIRE_EQUAL(world.FindHumanPath(startPt, pt), INVALID_DIR); // Allow left exit world.DestroyNO(surroundingPts[0]); BOOST_REQUIRE_EQUAL(world.FindHumanPath(startPt, surroundingPts2[0]), 0); BOOST_REQUIRE(checkWalkOnTerrain(world, startPt, surroundingPts2[0], Direction::WEST, TT_WATER, true)); BOOST_REQUIRE(checkWalkOnTerrain(world, startPt, surroundingPts2[0], Direction::WEST, TT_SWAMPLAND, true)); BOOST_REQUIRE(checkWalkOnTerrain(world, startPt, surroundingPts2[0], Direction::WEST, TT_LAVA, false)); BOOST_REQUIRE(checkWalkOnTerrain(world, startPt, surroundingPts2[0], Direction::WEST, TT_SNOW, false)); BOOST_REQUIRE(checkWalkOnPoint(world, startPt, surroundingPts2[0], Direction::WEST, TT_WATER)); BOOST_REQUIRE(checkWalkOnPoint(world, startPt, surroundingPts2[0], Direction::WEST, TT_SWAMPLAND)); }
BOOST_FIXTURE_TEST_CASE(read_by_two_bits, Fixture) { v_t shift_results = {0x0, 0x0, 0x3, 0x3, 0x3, 0x3, 0x0, 0x0, 0x3, 0x3, 0x3, 0x3}; v_t deref_results = {0xf0, 0xf3, 0xff, 0xcf, 0x0f, 0x0f, 0x0f, 0x3f, 0xff, 0xfc, 0xf0, 0xc0}; for (size_t i = 0; i < shift_results.size(); ++i) { BOOST_TEST_CHECKPOINT("Shifted " << i << " times so far"); BOOST_CHECK_EQUAL(*bit, deref_results[i]); unsigned char shifted = bit.shift(2); BOOST_REQUIRE_EQUAL(bit.shift(), ((i+1)*2)%8); BOOST_REQUIRE_LT(shifted, 4); BOOST_CHECK_EQUAL(shifted, shift_results[i]); } }
void checkGet(const openfluid::utils::RESTClient& Client) { openfluid::utils::RESTClient::Reply Reply; Reply = Client.getResource("/users"); std::cout << "GET /users : " << Reply.getStatusCode() << std::endl; BOOST_REQUIRE(Reply.isOK()); BOOST_REQUIRE_EQUAL(Reply.getStatusCode(),200); BOOST_REQUIRE_NE(Reply.getContent().indexOf("\"username\": \"Bret\""),-1); Reply = Client.getResource("/users/23"); std::cout << "GET /users/23 : " << Reply.getStatusCode() << std::endl; std::cout << " - " << Reply.getNetworkErrorCode() << ": " << Reply.getNetworkErrorString().toStdString() << std::endl; BOOST_REQUIRE(!Reply.isOK()); BOOST_REQUIRE_EQUAL(Reply.getStatusCode(),404); Reply = Client.getResource("/users/2"); std::cout << "GET /users/2 : " << Reply.getStatusCode() << std::endl; BOOST_REQUIRE(Reply.isOK()); BOOST_REQUIRE_EQUAL(Reply.getStatusCode(),200); BOOST_REQUIRE_NE(Reply.getContent().indexOf("\"username\": \"Antonette\""),-1); }
void * msg_alloc3(size_t msg_i ,size_t total_msg, size_t total_p, size_t i, size_t ri, void * ptr) { openfpm::vector<openfpm::vector<unsigned char>> * v = static_cast<openfpm::vector<openfpm::vector<unsigned char>> *>(ptr); v->add(); prc_recv.add(); BOOST_REQUIRE_EQUAL(msg_i, global_step); v->last().resize(msg_i); prc_recv.last() = i; return &(v->last().get(0)); }
static void test_set_backend_ids_for_enabled(session &sess) { server_node &node = global_data->nodes.back(); auto ids = generate_ids(16); ELLIPTICS_REQUIRE(async_set_result, sess.set_backend_ids(node.remote(), 4, ids)); backend_status_result_entry result = async_set_result.get_one(); BOOST_REQUIRE(result.is_valid()); BOOST_REQUIRE_EQUAL(result.count(), 1); dnet_backend_status *status = result.backend(0); BOOST_REQUIRE_EQUAL(status->backend_id, 4); BOOST_REQUIRE_EQUAL(status->state, DNET_BACKEND_ENABLED); // Wait 0.1 secs to ensure that route list was changed usleep(100 * 1000); auto route_ids = backend_ids(sess, node.remote(), 4); BOOST_REQUIRE_EQUAL(ids.size(), route_ids.size()); BOOST_REQUIRE(compare_ids(ids, route_ids)); }
void * msg_alloc2(size_t msg_i ,size_t total_msg, size_t total_p, size_t i, size_t ri, void * ptr) { openfpm::vector<openfpm::vector<unsigned char>> * v = static_cast<openfpm::vector<openfpm::vector<unsigned char>> *>(ptr); v->resize(total_p); prc_recv.resize(total_p); BOOST_REQUIRE_EQUAL(msg_i, global_step); id++; v->get(id-1).resize(msg_i); prc_recv.get(id-1) = i; return &(v->get(id-1).get(0)); }
static void test_backend_status(session &sess) { server_node &node = global_data->nodes[0]; ELLIPTICS_REQUIRE(async_status_result, sess.request_backends_status(node.remote())); sync_backend_status_result result = async_status_result; BOOST_REQUIRE_EQUAL(result.size(), 1); backend_status_result_entry entry = result.front(); BOOST_REQUIRE_EQUAL(entry.count(), backends_count); for (size_t i = 0; i < backends_count; ++i) { dnet_backend_status *status = entry.backend(i); BOOST_REQUIRE_EQUAL(status->backend_id, i); if (i < 2 || i == 3) { BOOST_REQUIRE_EQUAL(status->state, DNET_BACKEND_ENABLED); } else { BOOST_REQUIRE_EQUAL(status->state, DNET_BACKEND_DISABLED); } } }
static void test_make_backend_readonly(session &sess) { server_node &node = global_data->nodes.back(); const key id = std::string("read_only_key"); const std::string data = "read_only_data"; ELLIPTICS_REQUIRE(async_readonly_result, sess.make_readonly(node.remote(), 4)); backend_status_result_entry result = async_readonly_result.get_one(); BOOST_REQUIRE(result.is_valid()); BOOST_REQUIRE_EQUAL(result.count(), 1); dnet_backend_status *status = result.backend(0); BOOST_REQUIRE_EQUAL(status->backend_id, 4); BOOST_REQUIRE_EQUAL(status->read_only, true); session new_sess = sess.clone(); new_sess.set_direct_id(node.remote(), 4); ELLIPTICS_REQUIRE_ERROR(write_result, new_sess.write_data(id, data, 0), -EROFS); ELLIPTICS_REQUIRE_ERROR(second_async_readonly_result, sess.make_readonly(node.remote(), 4), -EALREADY); }
static void test_check_initial_config(session &sess) { auto &node = get_setup()->nodes.back(); static const uint32_t backend_id = 4; ELLIPTICS_REQUIRE(result, sess.monitor_stat(node.remote(), DNET_MONITOR_BACKEND)); BOOST_REQUIRE_EQUAL(result.get().size(), 1); auto monitor_initial_config = [&] () { std::istringstream stream(result.get().front().statistics()); auto monitor_statistics = kora::dynamic::read_json(stream); return monitor_statistics.as_object()["backends"] .as_object()[std::to_string(backend_id)] .as_object()["backend"] .as_object()["initial_config"]; } (); auto config_initial_config = [&] () { std::ifstream stream(node.config_path()); auto config = kora::dynamic::read_json(stream); return config.as_object()["backends"].as_array()[backend_id]; } (); BOOST_REQUIRE_EQUAL(monitor_initial_config, config_initial_config); }
void assert_output_equals(const std::string& file, const std::string& output, const std::string& param1, const std::string& param2, const std::string& param3){ auto configuration = parse_options("test/cases/" + file, param1, param2, param3); eddic::Compiler compiler; int code = compiler.compile("test/cases/" + file, configuration); BOOST_REQUIRE_EQUAL (code, 0); std::string out = eddic::execCommand("./" + param3); BOOST_CHECK_EQUAL (output, out); remove("./" + param3); }
/** * Check the column count of a bound statement before and after adding a * column to a table. * * @param expected_column_count_after_update */ void prepared_check_column_count_after_alter(size_t expected_column_count_after_update) { test_utils::CassSessionPtr session(test_utils::create_session(cluster)); test_utils::execute_query(session.get(), str(boost::format("USE %s") % keyspace)); test_utils::CassFuturePtr future(cass_session_prepare(session.get(), "SELECT * FROM test WHERE k = 'key1'")); BOOST_REQUIRE_EQUAL(cass_future_error_code(future.get()), CASS_OK); test_utils::CassPreparedPtr prepared(cass_future_get_prepared(future.get())); BOOST_REQUIRE(prepared); test_utils::CassStatementPtr bound_statement(cass_prepared_bind(prepared.get())); BOOST_REQUIRE(bound_statement); // Verify that the table has two columns in the metadata { test_utils::CassFuturePtr result_future(cass_session_execute(session.get(), bound_statement.get())); BOOST_REQUIRE_EQUAL(cass_future_error_code(result_future.get()), CASS_OK); test_utils::CassResultPtr result(cass_future_get_result(result_future.get())); BOOST_CHECK_EQUAL(cass_result_column_count(result.get()), 2u); } // Add a column to the table test_utils::execute_query(session.get(), "ALTER TABLE test ADD v2 int"); // The column count shouldn't have changed { test_utils::CassFuturePtr result_future(cass_session_execute(session.get(), bound_statement.get())); BOOST_REQUIRE_EQUAL(cass_future_error_code(result_future.get()), CASS_OK); test_utils::CassResultPtr result(cass_future_get_result(result_future.get())); BOOST_CHECK_EQUAL(cass_result_column_count(result.get()), expected_column_count_after_update); } }
void run_test_6(void) { typedef nova::dsp_thread_queue_item<dummy_runnable, Alloc> dsp_thread_queue_item; typedef nova::dsp_thread_queue<dummy_runnable, Alloc> dsp_thread_queue; typedef nova::dsp_threads<dummy_runnable, nova::nop_thread_init, Alloc> dsp_threads; typedef std::auto_ptr<dsp_thread_queue> dsp_thread_queue_ptr; dsp_threads t(2); t.start_threads(); dsp_thread_queue_ptr q (new dsp_thread_queue(20)); std::vector<dsp_thread_queue_item*> items; for (int i = 0; i != 20; ++i) { items.push_back(q->allocate_queue_item(dummy, typename dsp_thread_queue_item::successor_list(), 0)); q->add_initially_runnable(items.back()); } t.reset_queue(MOVE(q)); const int iterations = 10000; for (int i = 0; i != iterations; ++i) { for (int item = 0; item != 20; ++item) BOOST_REQUIRE_EQUAL(items[item]->get_job().i, i); t.run(); } t.terminate_threads(); for (int i = 0; i != 20; ++i) BOOST_REQUIRE_EQUAL(items[i]->get_job().i, iterations); }
/* Run two small non-overlapping rings with different delays */ void runDoubleRing(backend_t backend) { /* Make sure we go around the ring at least a couple of times */ const unsigned ncount = 512; const unsigned duration = ncount * 5 / 2; nemo::Configuration conf = configuration(false, 1024); setBackend(backend, conf); boost::scoped_ptr<nemo::Network> net(new nemo::Network); createRing(net.get(), ncount, 0, false, 1, 1); createRing(net.get(), ncount, ncount, false, 1, 2); boost::scoped_ptr<nemo::Simulation> sim(nemo::simulation(*net, conf)); /* Stimulate a single neuron in each ring to get them going */ std::vector<unsigned> fstim; fstim.push_back(0); fstim.push_back(ncount); sim->step(fstim); for(unsigned ms=1; ms < duration; ++ms) { const std::vector<unsigned>& fired = sim->step(); if(ms % 2 == 0) { BOOST_CHECK_EQUAL(fired.size(), 2U); BOOST_REQUIRE_EQUAL(fired[0], ms % ncount); BOOST_REQUIRE_EQUAL(fired[1], ncount + (ms / 2) % ncount); } else { BOOST_CHECK_EQUAL(fired.size(), 1U); BOOST_REQUIRE_EQUAL(fired.front(), ms % ncount); } } }
//----------------------------------------------------------------------------- BOOST_AUTO_TEST_CASE_TEMPLATE( eventTestShouldBeFalseWhileInQueueAndTrueAfterBeingProcessed, TDevStream, TestStreams) { using Fixture = alpaka::test::stream::StreamTestFixture<TDevStream>; using Stream = typename Fixture::Stream; using Dev = typename Fixture::Dev; Fixture f1; auto s1 = f1.m_stream; alpaka::event::Event<Stream> e1(f1.m_dev); alpaka::test::event::EventHostManualTrigger<Dev> k1(f1.m_dev); if(!alpaka::test::stream::IsSyncStream<Stream>::value) { alpaka::stream::enqueue(s1, k1); } alpaka::stream::enqueue(s1, e1); if(!alpaka::test::stream::IsSyncStream<Stream>::value) { BOOST_REQUIRE_EQUAL( false, alpaka::event::test(e1)); k1.trigger(); alpaka::wait::wait(s1); } BOOST_REQUIRE_EQUAL( true, alpaka::event::test(e1)); }
void ExpectActionSucceeds(Fn && action, bool expectEngineIsOn, CCar::Gear expectedGear, int expectedSpeed) { BOOST_REQUIRE_NO_THROW(action()); BOOST_REQUIRE_EQUAL(car.IsEngineOn(), expectEngineIsOn); if (expectEngineIsOn) { BOOST_CHECK(car.GetGear() == expectedGear); BOOST_CHECK_EQUAL(car.GetSpeed(), expectedSpeed); auto expectedDirection = (expectedSpeed > 0) ? Direction::Forward : (expectedSpeed < 0) ? Direction::Backward : Direction::StandStill; BOOST_CHECK(car.GetDirection() == expectedDirection); } }
BOOST_FIXTURE_TEST_CASE(read_by_seven_bits, Fixture) { v_t shift_results = {0x70, 0x1f, 0x7c}; v_t deref_results = {0xf0, 0x8f, 0x3f}; for (size_t i = 0; i < shift_results.size(); ++i) { BOOST_TEST_CHECKPOINT("Shifted " << i << " times so far"); if (i < deref_results.size()) BOOST_CHECK_EQUAL(*bit, deref_results[i]); unsigned char shifted = bit.shift(7); BOOST_REQUIRE_LT(shifted, 128); BOOST_REQUIRE_EQUAL(bit.shift(), ((i+1)*7)%8); BOOST_CHECK_EQUAL(shifted, shift_results[i]); } }
BOOST_FIXTURE_TEST_CASE(read_by_five_bits, Fixture) { v_t shift_results = {0x10, 0x1f, 0x03, 0x1e}; v_t deref_results = {0xf0, 0xef, 0x0f, 0x7f}; for (size_t i = 0; i < shift_results.size(); ++i) { BOOST_TEST_CHECKPOINT("Shifted " << i << " times so far"); if (i < deref_results.size()) BOOST_CHECK_EQUAL(*bit, deref_results[i]); unsigned char shifted = bit.shift(5); BOOST_REQUIRE_LT(shifted, 32); BOOST_REQUIRE_EQUAL(bit.shift(), ((i+1)*5)%8); BOOST_CHECK_EQUAL(shifted, shift_results[i]); } }
/** * Verify the address UDT field names * * @param value The address UDT value to iterate over */ void verify_address_udt_field_names(const CassValue* value) { // Ensure the value is a UDT and create the iterator for the validation BOOST_REQUIRE_EQUAL(cass_value_type(value), CASS_VALUE_TYPE_UDT); BOOST_REQUIRE_EQUAL(cass_value_item_count(value), 3); test_utils::CassIteratorPtr iterator(cass_iterator_from_user_type(value)); // Verify street field name BOOST_REQUIRE(cass_iterator_next(iterator.get())); CassString street_field_name; BOOST_REQUIRE_EQUAL(cass_iterator_get_user_type_field_name(iterator.get(), &street_field_name.data, &street_field_name.length), CASS_OK); BOOST_REQUIRE(test_utils::Value<CassString>::equal("street", street_field_name)); // Verify zip field name BOOST_REQUIRE(cass_iterator_next(iterator.get())); CassString zip_field_name; BOOST_REQUIRE_EQUAL(cass_iterator_get_user_type_field_name(iterator.get(), &zip_field_name.data, &zip_field_name.length), CASS_OK); BOOST_REQUIRE(test_utils::Value<CassString>::equal("ZIP", zip_field_name)); // Verify phone numbers field name BOOST_REQUIRE(cass_iterator_next(iterator.get())); CassString phone_numbers_field_name; BOOST_REQUIRE_EQUAL(cass_iterator_get_user_type_field_name(iterator.get(), &phone_numbers_field_name.data, &phone_numbers_field_name.length), CASS_OK); BOOST_REQUIRE(test_utils::Value<CassString>::equal("phone_numbers", phone_numbers_field_name)); }
BOOST_FIXTURE_TEST_CASE(read_by_three_bits, Fixture) { v_t shift_results = {0x0, 0x6, 0x7, 0x7, 0x0, 0x6, 0x7, 0x7}; v_t deref_results = {0xf0, 0xf7, 0xcf, 0x0f, 0x0f, 0x7f}; // undefined, undefined}; for (size_t i = 0; i < shift_results.size(); ++i) { BOOST_TEST_CHECKPOINT("Shifted " << i << " times so far"); if (i < deref_results.size()) BOOST_CHECK_EQUAL(*bit, deref_results[i]); unsigned char shifted = bit.shift(3); BOOST_REQUIRE_LT(shifted, 8); BOOST_REQUIRE_EQUAL(bit.shift(), ((i+1)*3)%8); BOOST_CHECK_EQUAL(shifted, shift_results[i]); } }
//----------------------------------------------------------------------------- BOOST_AUTO_TEST_CASE_TEMPLATE( eventTestShouldInitiallyBeTrue, TDevStream, alpaka::test::stream::TestStreams) { using Fixture = alpaka::test::stream::StreamTestFixture<TDevStream>; using Stream = typename Fixture::Stream; Fixture f; alpaka::event::Event<Stream> event(f.m_dev); BOOST_REQUIRE_EQUAL( true, alpaka::event::test(event)); }
void checkContainersSize(const JPetParamBank& bank) { JPetDBParamGetter::clearParamCache(); BOOST_REQUIRE_EQUAL(bank.getScintillatorsSize(), 2); BOOST_REQUIRE_EQUAL(bank.getPMsSize(), 4); BOOST_REQUIRE_EQUAL(bank.getFEBsSize(), 1); BOOST_REQUIRE_EQUAL(bank.getTRBsSize(), 1); BOOST_REQUIRE_EQUAL(bank.getBarrelSlotsSize(), 2); BOOST_REQUIRE_EQUAL(bank.getTOMBChannelsSize(), 4); }
BOOST_FIXTURE_TEST_CASE(Triple, Fixture) { ValidatorNull nullValidator; SegmentFetcher::fetch(face, Interest("/hello/world", time::seconds(1000)), nullValidator, bind(&Fixture::onComplete, this, _1), bind(&Fixture::onError, this, _1)); advanceClocks(time::milliseconds(1), 10); face.receive(*makeDataSegment("/hello/world/version0", 0, false)); advanceClocks(time::milliseconds(1), 10); face.receive(*makeDataSegment("/hello/world/version0", 1, false)); advanceClocks(time::milliseconds(1), 10); face.receive(*makeDataSegment("/hello/world/version0", 2, true)); advanceClocks(time::milliseconds(1), 10); BOOST_CHECK_EQUAL(nErrors, 0); BOOST_CHECK_EQUAL(nDatas, 1); BOOST_CHECK_EQUAL(dataSize, 42); BOOST_REQUIRE_EQUAL(face.sentInterests.size(), 3); BOOST_CHECK_EQUAL(face.sentData.size(), 0); { const Interest& interest = face.sentInterests[0]; BOOST_CHECK_EQUAL(interest.getName(), "/hello/world"); BOOST_CHECK_EQUAL(interest.getMustBeFresh(), true); BOOST_CHECK_EQUAL(interest.getChildSelector(), 1); } { const Interest& interest = face.sentInterests[1]; BOOST_CHECK_EQUAL(interest.getName(), "/hello/world/version0/%00%01"); BOOST_CHECK_EQUAL(interest.getMustBeFresh(), false); BOOST_CHECK_EQUAL(interest.getChildSelector(), 0); } { const Interest& interest = face.sentInterests[2]; BOOST_CHECK_EQUAL(interest.getName(), "/hello/world/version0/%00%02"); BOOST_CHECK_EQUAL(interest.getMustBeFresh(), false); BOOST_CHECK_EQUAL(interest.getChildSelector(), 0); } }
static void test_cache_lru_eviction(session &sess, const nodes_data *setup) { dnet_node *node = setup->nodes[0].get_native(); dnet_backend_io *backend_io = dnet_get_backend_io(node->io, 0); ioremap::cache::cache_manager *cache = reinterpret_cast<ioremap::cache::cache_manager *>(backend_io->cache); const size_t cache_size = cache->cache_size(); const size_t cache_pages_number = cache->cache_pages_number(); BOOST_REQUIRE_MESSAGE(cache_pages_number == 1, "Can't run cache_lru_eviction test with more then one cache page"); lru_list_emulator_t lru_list_emulator; argument_data data("0"); size_t current_objects_number = 0; cache->clear(); size_t record_size = 0; { cache_write_check_lru(sess, current_objects_number++, data, 3000, lru_list_emulator, cache); auto stats = cache->get_total_cache_stats(); record_size = stats.size_of_objects; } // Fill cache to full capacity with keys size_t max_records_number = (cache_size / cache_pages_number / record_size) - 1; for (size_t recordNumber = 1; recordNumber < max_records_number; ++recordNumber) { cache_write_check_lru(sess, current_objects_number++, data, 3000, lru_list_emulator, cache); } auto stats = cache->get_total_cache_stats(); BOOST_REQUIRE_EQUAL(stats.number_of_objects, current_objects_number); int removed_key = current_objects_number; cache_write_check_lru(sess, current_objects_number++, data, 3000, lru_list_emulator, cache); // Check that 0 record is evicted cache_read_check_lru(sess, 0, lru_list_emulator, cache); // Check that all keys are in list for (size_t recordNumber = 1; recordNumber < max_records_number; ++recordNumber) { cache_read_check_lru(sess, recordNumber, lru_list_emulator, cache); cache_write_check_lru(sess, recordNumber, data, 3000, lru_list_emulator, cache); } // Add one more new key, check that removed_key, which was not updated is removed cache_write_check_lru(sess, current_objects_number++, data, 3000, lru_list_emulator, cache); cache_read_check_lru(sess, removed_key, lru_list_emulator, cache); }
template<typename T> void test_single_all_gather_primitives(Vcluster & vcl) { //! [allGather numbers] openfpm::vector<T> clt; T data = vcl.getProcessUnitID(); vcl.allGather(data,clt); vcl.execute(); for (size_t i = 0 ; i < vcl.getProcessingUnits() ; i++) BOOST_REQUIRE_EQUAL(i,(size_t)clt.get(i)); //! [allGather numbers] }
static void test_args(const std::string& arg1, const std::string& arg2, const std::string& arg3){ auto configuration = parse_options("test/cases/args.eddi", arg1, arg2, arg3); eddic::Compiler compiler; int code = compiler.compile("test/cases/args.eddi", configuration); BOOST_REQUIRE_EQUAL (code, 0); std::string out = eddic::execCommand("./" + arg3); BOOST_CHECK_EQUAL ("./" + arg3 + "|", out); out = eddic::execCommand("./" + arg3 + " arg1 arg2 arg3"); BOOST_CHECK_EQUAL ("./" + arg3 + "|arg1|arg2|arg3|", out); remove("./" + arg3); }
BOOST_FIXTURE_TEST_CASE(Move, Fixture) { dcmtkpp::MoveSCU scu; scu.set_network(&this->network); scu.set_association(&this->association); scu.set_move_destination("LOCAL"); scu.set_affected_sop_class(UID_MOVEPatientRootQueryRetrieveInformationModel); auto const results = scu.move(&this->query); BOOST_REQUIRE_EQUAL(results.size(), 1); BOOST_CHECK_EQUAL( dcmtkpp::ElementAccessor<EVR_UI>::get(*results[0], DCM_SOPInstanceUID), "2.25.95090344942250266709587559073467305647"); delete results[0]; }
BOOST_FIXTURE_TEST_CASE_TEMPLATE(ReceiveTooLarge, T, StreamTransportFixtures, T) { this->initialize(); std::vector<uint8_t> bytes(ndn::MAX_NDN_PACKET_SIZE, 0); Block pkt1 = ndn::encoding::makeBinaryBlock(300, bytes.data(), bytes.size() - 6); ndn::Buffer buf1(pkt1.begin(), pkt1.end()); BOOST_REQUIRE_EQUAL(buf1.size(), ndn::MAX_NDN_PACKET_SIZE); Block pkt2 = ndn::encoding::makeBinaryBlock(301, bytes.data(), bytes.size()); ndn::Buffer buf2(pkt2.begin(), pkt2.end()); BOOST_REQUIRE_GT(buf2.size(), ndn::MAX_NDN_PACKET_SIZE); this->remoteWrite(buf1); // this should succeed BOOST_CHECK_EQUAL(this->transport->getCounters().nInPackets, 1); BOOST_CHECK_EQUAL(this->transport->getCounters().nInBytes, buf1.size()); BOOST_CHECK_EQUAL(this->receivedPackets->size(), 1); BOOST_CHECK_EQUAL(this->transport->getState(), TransportState::UP); int nStateChanges = 0; this->transport->afterStateChange.connect( [this, &nStateChanges] (TransportState oldState, TransportState newState) { switch (nStateChanges) { case 0: BOOST_CHECK_EQUAL(oldState, TransportState::UP); BOOST_CHECK_EQUAL(newState, TransportState::FAILED); break; case 1: BOOST_CHECK_EQUAL(oldState, TransportState::FAILED); BOOST_CHECK_EQUAL(newState, TransportState::CLOSED); break; default: BOOST_CHECK(false); } nStateChanges++; }); this->remoteWrite(buf2, false); // this should fail BOOST_CHECK_EQUAL(nStateChanges, 2); BOOST_CHECK_EQUAL(this->transport->getCounters().nInPackets, 1); BOOST_CHECK_EQUAL(this->transport->getCounters().nInBytes, buf1.size()); BOOST_CHECK_EQUAL(this->receivedPackets->size(), 1); }
BOOST_FIXTURE_TEST_CASE(MetalWorkerStopped, WorldWithGCExecution1P) { rttr::test::LogAccessor logAcc; ggs.setSelection(AddonId::TOOL_ORDERING, 1); ggs.setSelection(AddonId::METALWORKSBEHAVIORONZERO, 1); Inventory goods; goods.goods[GD_IRON] = 10; world.GetSpecObj<nobBaseWarehouse>(hqPos)->AddGoods(goods, true); MapPoint bldPos = hqPos + MapPoint(2, 0); BuildingFactory::CreateBuilding(world, BLD_METALWORKS, bldPos, curPlayer, NAT_AFRICANS); this->BuildRoad(world.GetNeighbour(bldPos, Direction::SOUTHEAST), false, std::vector<Direction>(2, Direction::WEST)); MapPoint bldPos2 = hqPos - MapPoint(2, 0); BuildingFactory::CreateBuilding(world, BLD_METALWORKS, bldPos2, curPlayer, NAT_AFRICANS); this->BuildRoad(world.GetNeighbour(bldPos2, Direction::SOUTHEAST), false, std::vector<Direction>(2, Direction::EAST)); std::array<signed char, NUM_TOOLS> toolOrder; ToolSettings toolSettings; std::fill(toolOrder.begin(), toolOrder.end(), 0); std::fill(toolSettings.begin(), toolSettings.end(), 0); this->ChangeTools(toolSettings, toolOrder.data()); // Get wares and workers in RTTR_SKIP_GFS(1000); toolOrder[0] = 1; toolOrder[1] = 1; toolOrder[2] = 1; PostBox* postbox = world.GetPostMgr().AddPostBox(0); postbox->Clear(); const Inventory& curInventory = world.GetPlayer(curPlayer).GetInventory(); Inventory expectedInventory = curInventory; expectedInventory.Add(TOOLS[0], toolOrder[0]); expectedInventory.Add(TOOLS[1], toolOrder[1]); expectedInventory.Add(TOOLS[2], toolOrder[2]); // Place order this->ChangeTools(toolSettings, toolOrder.data()); RTTR_REQUIRE_LOG_CONTAINS("Committing an order", true); // Wait for completion message RTTR_EXEC_TILL(3000, postbox->GetNumMsgs() == 1u); BOOST_REQUIRE_EQUAL(postbox->GetMsg(0)->GetCategory(), PostCategory::Economy); // Stop it and wait till goods are produced this->SetProductionEnabled(bldPos, false); this->SetProductionEnabled(bldPos2, false); RTTR_EXEC_TILL(2000, curInventory[TOOLS[0]] == expectedInventory[TOOLS[0]] && curInventory[TOOLS[1]] == expectedInventory[TOOLS[1]] && curInventory[TOOLS[2]] == expectedInventory[TOOLS[2]]); }