Пример #1
0
void try_lock_twice()
{
    boost::fibers::mutex mtx;
    boost::unique_lock< boost::fibers::mutex > lk( mtx);

    BOOST_CHECK_THROW( lk.try_lock(), boost::lock_error);
}
Пример #2
0
inline void testReadUntilFiltered(const char* format)
{
    TemporaryData data{format};

    brion::SpikeReport reportWrite(brion::URI(data.tmpFileName),
                                   brion::MODE_WRITE);
    reportWrite.write(data.spikes);
    reportWrite.close();

    brion::SpikeReport reportRead(brion::URI(data.tmpFileName),
                                  brion::GIDSet{22, 25});

    auto spikes = reportRead.readUntil(0.4).get();
    BOOST_CHECK_EQUAL(spikes.size(), 1);
    BOOST_CHECK(reportRead.getCurrentTime() >= 0.4f);
    BOOST_CHECK(spikes.rbegin()->first < 0.4);
    BOOST_CHECK_EQUAL(reportRead.getState(), brion::SpikeReport::State::ok);

    spikes = reportRead.readUntil(brion::UNDEFINED_TIMESTAMP).get();
    BOOST_CHECK_EQUAL(spikes.size(), 1);
    BOOST_CHECK_EQUAL(reportRead.getCurrentTime(), brion::UNDEFINED_TIMESTAMP);
    BOOST_CHECK_EQUAL(reportRead.getState(), brion::SpikeReport::State::ended);

    BOOST_CHECK_THROW(reportRead.read(reportRead.getCurrentTime()),
                      std::logic_error);
}
BOOST_FIXTURE_TEST_CASE( test_suite_loop5, _2suites_4_cases )
{
    tc1->depends_on( s1 );

    master->p_default_status.value = ut::test_unit::RS_ENABLED;
    BOOST_CHECK_THROW( ut::framework::finalize_setup_phase( master->p_id ),
                       ut::framework::setup_error );
}
Пример #4
0
inline void testInvalidWrite(const char* format)
{
    TemporaryData data{format};
    brion::SpikeReport reportWrite(brion::URI(data.tmpFileName),
                                   brion::MODE_WRITE);
    reportWrite.write(data.spikes);

    BOOST_CHECK_THROW(reportWrite.write({{0.0, 0}}), std::logic_error);

    BOOST_CHECK_THROW(reportWrite.write(
                          {{10.0, 0}, {10.0, 1}, {11.0, 0}, {0.5, 1}}),
                      std::logic_error);

    brion::SpikeReport reportRead{brion::URI(data.tmpFileName),
                                  brion::MODE_READ};
    BOOST_CHECK_THROW(reportRead.write({{100.0, 0}}), std::runtime_error);
}
    void operator()() const
    {
        Mutex m;
        Lock lock(m);
        lock.unlock();

        BOOST_CHECK_THROW( lock.unlock(), boost::lock_error );
    }
Пример #6
0
void test_unlock_twice()
{
	boost::fibers::spin::mutex mtx;
	boost::unique_lock< boost::fibers::spin::mutex > lk( mtx);
	lk.unlock();

	BOOST_CHECK_THROW( lk.unlock(), boost::lock_error);
}
Пример #7
0
BOOST_AUTO_TEST_CASE_TEMPLATE(members, T, float_types) {
	vmath::core::Matrix<T, 3> M;
	M[0] = vmath::core::Vector<T, 3>(static_cast<T>(1.0), static_cast<T>(2.0), static_cast<T>(3.0));
	M[1] = vmath::core::Vector<T, 3>(static_cast<T>(4.0), static_cast<T>(5.0), static_cast<T>(6.0));
	M[2] = vmath::core::Vector<T, 3>(static_cast<T>(7.0), static_cast<T>(8.0), static_cast<T>(9.0));
	BOOST_CHECK_CLOSE(M[0][0], static_cast<T>(1.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[0][1], static_cast<T>(2.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[0][2], static_cast<T>(3.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[1][0], static_cast<T>(4.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[1][1], static_cast<T>(5.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[1][2], static_cast<T>(6.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[2][0], static_cast<T>(7.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[2][1], static_cast<T>(8.0), 1e-4f);
	BOOST_CHECK_CLOSE(M[2][2], static_cast<T>(9.0), 1e-4f);
	// invalid index
	BOOST_CHECK_THROW(M[3], std::out_of_range);
	BOOST_CHECK_THROW((M[3] = vmath::core::Vector<T, 3>()), std::out_of_range);
}
Пример #8
0
void const_test_f( json::value const & value )
{
   BOOST_CHECK(value.has_key("cafe"));

   BOOST_CHECK_THROW(value["sam"], std::out_of_range);

   BOOST_CHECK_EQUAL(value["cafe"], "open");
   BOOST_CHECK_EQUAL(value["bar"][2], 1234.5);
}
Пример #9
0
 void C2STestSocketListener::runTest()
 {
   C2STestSocketListener testSocketListener;
   BOOST_CHECK_THROW( testSocketListener.sendTestMessageThroughSocket() , C2SSocketException );
   testSocketListener.startSocketListener();
   testSocketListener.sendTestMessageThroughSocket();
   testSocketListener.sendTestMessageThroughSocket();
   testSocketListener.shutdownSocketListener();
 }
BOOST_FIXTURE_TEST_CASE( test_simple_loop2, _3cases )
{
    tc1->depends_on( tc2 );
    tc2->depends_on( tc3 );
    tc3->depends_on( tc1 );

    master->p_default_status.value = ut::test_unit::RS_ENABLED;
    BOOST_CHECK_THROW( ut::framework::finalize_setup_phase( master->p_id ),
                       ut::framework::setup_error );
}
WESNOTH_PARAMETERIZED_TEST_CASE( test_multi_sendfile, sendfile_param, sendfile_sizes, size )
{
	auto_resetter<std::string> path("", game_config::path);
	network::set_raw_data_only();
	std::string file = create_random_sendfile(size.size_);
	network_worker_pool::set_use_system_sendfile(size.system_);

	network::connection cl_client1, se_client1;
	network::connection cl_client2, se_client2;
	network::connection cl_client3, se_client3;

	BOOST_CHECK_MESSAGE((cl_client1 = network::connect(LOCALHOST, TEST_PORT)) > 0, "Can't connect to server!");
	BOOST_CHECK_MESSAGE((se_client1 = network::accept_connection()) > 0, "Coulnd't accept new connection");
	BOOST_CHECK_MESSAGE((cl_client2 = network::connect(LOCALHOST, TEST_PORT)) > 0, "Can't connect to server!");
	BOOST_CHECK_MESSAGE((se_client2 = network::accept_connection()) > 0, "Coulnd't accept new connection");
	BOOST_CHECK_MESSAGE((cl_client3 = network::connect(LOCALHOST, TEST_PORT)) > 0, "Can't connect to server!");
	BOOST_CHECK_MESSAGE((se_client3 = network::accept_connection()) > 0, "Coulnd't accept new connection");

	network::send_file(file, cl_client1);
	network::send_file(file, cl_client2);
	network::send_file(file, cl_client3);

	std::vector<char> data;

	BOOST_CHECK_PREDICATE(test_utils::one_of<network::connection> , (receive(data,500))(3)(se_client1)(se_client2)(se_client3));
	BOOST_CHECK_EQUAL(data.size(), static_cast<size_t>(file_size(file)));
	BOOST_CHECK_PREDICATE(test_utils::one_of<network::connection> , (receive(data,500))(3)(se_client1)(se_client2)(se_client3));
	BOOST_CHECK_EQUAL(data.size(), static_cast<size_t>(file_size(file)));
	BOOST_CHECK_PREDICATE(test_utils::one_of<network::connection> , (receive(data,500))(3)(se_client1)(se_client2)(se_client3));

	BOOST_CHECK_EQUAL(data.size(), static_cast<size_t>(file_size(file)));

	network::disconnect(cl_client1);
	network::disconnect(cl_client2);
	network::disconnect(cl_client3);

	BOOST_CHECK_THROW(receive(data),network::error);
	BOOST_CHECK_THROW(receive(data),network::error);
	BOOST_CHECK_THROW(receive(data),network::error);

	delete_random_sendfile(file);
}
 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 );
 }
Пример #13
0
 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);
   }
 }
Пример #14
0
static void RunCreate(const int64_t& num)
{
    CheckCreateInt(num);
    CScriptNum scriptnum(num);
    if (scriptnum.getvch().size() <= CScriptNum::nMaxNumSize)
        CheckCreateVch(num);
    else
    {
        BOOST_CHECK_THROW (CheckCreateVch(num), scriptnum_error);
    }
}
Пример #15
0
BOOST_FIXTURE_TEST_CASE(FullName, DataIdentityFixture)
{
  // Encoding pipeline

  ndn::Data d(ndn::Name("/local/ndn/prefix"));
  d.setContentType(tlv::ContentType_Blob);
  d.setFreshnessPeriod(time::seconds(10));

  d.setContent(Content1, sizeof(Content1));

  BOOST_CHECK_THROW(d.getFullName(), Data::Error);

  keyChain.sign(d, security::SigningInfo(security::SigningInfo::SIGNER_TYPE_CERT, certName));

  Name fullName;
  BOOST_REQUIRE_NO_THROW(fullName = d.getFullName());

  BOOST_CHECK_EQUAL(d.getName().hasWire(), true);
  BOOST_CHECK_EQUAL(fullName.hasWire(), false);

  // check if name was properly cached
  BOOST_CHECK_EQUAL(fullName.get(-1).value(), d.getFullName().get(-1).value());

  // check FullName content
  BOOST_REQUIRE_EQUAL(d.getName().size() + 1, fullName.size());
  BOOST_CHECK_EQUAL_COLLECTIONS(d.getName().begin(), d.getName().end(),
                                fullName.begin(), fullName.end() - 1);
  BOOST_CHECK_EQUAL(fullName.get(-1).value_size(), 32);

  // FullName should be reset after the next line
  d.setFreshnessPeriod(time::seconds(100));
  BOOST_CHECK_THROW(d.getFullName(), Data::Error);

  // Decoding pipeline
  d.wireDecode(Block(Data1, sizeof(Data1)));
  BOOST_REQUIRE_NO_THROW(fullName = d.getFullName());

  BOOST_CHECK_EQUAL(fullName.toUri(),
    "/local/ndn/prefix/"
    "sha256digest=28bad4b5275bd392dbb670c75cf0b66f13f7942b21e80f55c0e86b374753a548");
}
 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 );
 }
Пример #17
0
		void ExpectActionFailure(Fn && action)
		{
			CCar clone(car);
			BOOST_CHECK_THROW(action(), std::exception);
			BOOST_REQUIRE_EQUAL(clone.IsEngineOn(), car.IsEngineOn());
			if (clone.IsEngineOn())
			{
				BOOST_CHECK(clone.GetDirection() == car.GetDirection());
				BOOST_CHECK(clone.GetGear() == car.GetGear());
				BOOST_CHECK(clone.GetSpeed() == car.GetSpeed());
			}
		}
Пример #18
0
    BrokerPtr createBroker(zeroeq::Subscriber& subscriber) override
    {
        BOOST_CHECK_THROW(new zeroeq::connection::Broker(
                              "zeroeq::connection::test_named_broker",
                              subscriber,
                              zeroeq::connection::Broker::PORT_FIXED),
                          std::runtime_error);

        return BrokerPtr(new zeroeq::connection::Broker(
            "zeroeq::connection::test_named_broker", subscriber,
            zeroeq::connection::Broker::PORT_FIXED_OR_RANDOM));
    }
Пример #19
0
BOOST_AUTO_TEST_CASE_TEMPLATE(members, T, float_types) {
	vmath::core::Quaternion<T> H;
	H.x = static_cast<T>(20.12);
	H.y = static_cast<T>(100.89);
	H.z = static_cast<T>(-18.2);
	H.w = static_cast<T>(35.62);
	BOOST_CHECK_CLOSE(H[0], H.x, 1e-4f);
	BOOST_CHECK_CLOSE(H[1], H.y, 1e-4f);
	BOOST_CHECK_CLOSE(H[2], H.z, 1e-4f);
	BOOST_CHECK_CLOSE(H[3], H.w, 1e-4f);
	H[0] = static_cast<T>(100.89);
	H[1] = static_cast<T>(-18.2);
	H[2] = static_cast<T>(35.62);
	H[3] = static_cast<T>(20.12);
	BOOST_CHECK_CLOSE(H[0], H.x, 1e-4f);
	BOOST_CHECK_CLOSE(H[1], H.y, 1e-4f);
	BOOST_CHECK_CLOSE(H[2], H.z, 1e-4f);
	BOOST_CHECK_CLOSE(H[3], H.w, 1e-4f);
	// invalid index
	BOOST_CHECK_THROW(H[4], std::out_of_range);
	BOOST_CHECK_THROW(H[4] = static_cast<T>(0.0), std::out_of_range);
}
BOOST_AUTO_TEST_CASE_TEMPLATE( DeleteUnsupported, SorterT, sorter_types )
{
  keyvi::dictionary::compiler_param_t params = {};

  keyvi::dictionary::DictionaryCompiler<
            fsa::internal::SparseArrayPersistence<uint16_t>,
            fsa::internal::JsonValueStore,
            SorterT> compiler(10485760, params);

  // add, delete, add again
  compiler.Add("aa", "1");
  BOOST_CHECK_THROW( compiler.Delete("aa"), compiler_exception);
}
  void MotorDriverCardDummyTest::testGetMotorControler() {
    boost::shared_ptr<MotorControler> controler0 = _motorDriverCardDummy.getMotorControler(0);

    BOOST_CHECK(controler0->getID() == 0);

    // check that we actually get a MotorControlerDummy
    boost::shared_ptr<MotorControlerDummy> controler1 =
        boost::dynamic_pointer_cast<MotorControlerDummy>(_motorDriverCardDummy.getMotorControler(1));

    // this will cause an exception if the cast failed
    BOOST_CHECK(controler1->getID() == 1);

    BOOST_CHECK_THROW(_motorDriverCardDummy.getMotorControler(2), MotorDriverException);
  }
Пример #22
0
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);
}
	void CDatabaseFixedPointTest::TestCase_FixedPointAddition()
	{
		CLogger::LogInfo( StringStream() << "**** Start TestCase_FixedPointAddition ****" );

		CFixedPoint a, b, c;
		CLogger::LogInfo( StringStream() << "    No overflow" );
		a = CFixedPoint( 996, 3, 0 );
		b = CFixedPoint( 3, 3, 0 );
		BOOST_CHECK_EQUAL( a + b, CFixedPoint( 999, 3, 0 ) );
		CLogger::LogInfo( StringStream() << "    Precision overflow" );
		b = CFixedPoint( 4, 3, 0 );
		BOOST_CHECK_THROW( a + b, CDatabaseException );
		CLogger::LogInfo( StringStream() << "    Integer overflow" );
		c = CFixedPoint( 3, CFixedPoint::GetMaxPrecision(), 0 );
		b = CFixedPoint( std::numeric_limits< int64_t >::max() - 2, CFixedPoint::GetMaxPrecision(), 0 );
		BOOST_CHECK_THROW( c + b, CDatabaseException );
		CLogger::LogInfo( StringStream() << "    Different precisions" );
		b = CFixedPoint( 55, 5, 2 );
		a = CFixedPoint( 334, 3, 1 );
		BOOST_CHECK_EQUAL( a + b, CFixedPoint( 339, 3, 1 ) );

		CLogger::LogInfo( StringStream() << "**** End TestCase_FixedPointAddition ****" );
	}
Пример #24
0
	void test_identifier() {
		// TODO: Check for correct message.
		BOOST_CHECK_THROW(TileIdentifier::Create((const string&)"", ssm), excp::MalformedURLException);
		BOOST_CHECK_THROW(TileIdentifier::Create((const string&)"/stylesheet/a/0/0.png", ssm), excp::MalformedURLException);
		BOOST_CHECK_THROW(TileIdentifier::Create((const string&)"/stylesheet/0/-2/0.png", ssm), excp::MalformedURLException);
		BOOST_CHECK_THROW(TileIdentifier::Create((const string&)"/stylesheet/0/0/a.png", ssm), excp::MalformedURLException);
		BOOST_CHECK_THROW(TileIdentifier::Create((const string&)"/stylesheet/0/0/apng", ssm), excp::MalformedURLException);
		BOOST_CHECK_THROW(TileIdentifier::Create((const string&)"/stylesheet/0/0/0.wrong", ssm), excp::UnknownImageFormatException);
	}
Пример #25
0
BOOST_AUTO_TEST_CASE_TEMPLATE( adjacent_difference, DeviceType,
                               DTK_SEARCH_DEVICE_TYPES )
{
    Kokkos::View<int[5], DeviceType> v( "v" );
    auto v_host = Kokkos::create_mirror_view( v );
    v_host( 0 ) = 2;
    v_host( 1 ) = 4;
    v_host( 2 ) = 6;
    v_host( 3 ) = 8;
    v_host( 4 ) = 10;
    Kokkos::deep_copy( v, v_host );
    // In-place operation is not allowed
    BOOST_CHECK_THROW( ArborX::adjacentDifference( v, v ),
                       ArborX::SearchException );
    auto w = Kokkos::create_mirror( DeviceType(), v );
    BOOST_CHECK_NO_THROW( ArborX::adjacentDifference( v, w ) );
    auto w_host = Kokkos::create_mirror_view( w );
    Kokkos::deep_copy( w_host, w );
    std::vector<int> w_ref( 5, 2 );
    BOOST_TEST( w_host == w_ref, tt::per_element() );

    Kokkos::View<float *, DeviceType> x( "x", 10 );
    Kokkos::deep_copy( x, 3.14 );
    BOOST_CHECK_THROW( ArborX::adjacentDifference( x, x ),
                       ArborX::SearchException );
    Kokkos::View<float[10], DeviceType> y( "y" );
    BOOST_CHECK_NO_THROW( ArborX::adjacentDifference( x, y ) );
    std::vector<float> y_ref( 10 );
    y_ref[0] = 3.14;
    auto y_host = Kokkos::create_mirror_view( y );
    Kokkos::deep_copy( y_host, y );
    BOOST_TEST( y_host == y_ref, tt::per_element() );

    Kokkos::resize( x, 5 );
    BOOST_CHECK_THROW( ArborX::adjacentDifference( y, x ),
                       ArborX::SearchException );
}
Пример #26
0
void task4_6::tests_::solution_constructor_tests()
{
    task4_6::lines lines;

    BOOST_CHECK_NO_THROW( solution s( lines ) );

    {
        lines.push_back( "A = 5 + ( 45 - 54 * 23 ) * C ");
        BOOST_CHECK_THROW( solution s( lines ), std::logic_error );
        lines.clear();
    }
    {
        lines.push_back( "A = 5 + ( 45 - 54 * 23 )");
        lines.push_back( "B = 15 / 23 )");
        BOOST_CHECK_THROW( solution s( lines ), std::logic_error );
        lines.clear();
    }
    {
        lines.push_back( "A = 5 + ( 45 - 54 * 23 )");
        lines.push_back( "B = 15 / 15");
        lines.push_back( "C = A + B");
        lines.push_back( "C = 45 + 65");
        BOOST_CHECK_THROW( solution s( lines ), std::logic_error );
        lines.clear();
    }
    {
        lines.push_back( "A = 56 / 0 ");
        BOOST_CHECK_THROW( solution s( lines ), std::logic_error );
        lines.clear();
    }
    {
        lines.push_back( "A = 45 + + 76");
        BOOST_CHECK_THROW( solution s( lines ), std::logic_error );
        lines.clear();
    }
}
Пример #27
0
BOOST_AUTO_TEST_CASE_TEMPLATE( last_element, DeviceType,
                               DTK_SEARCH_DEVICE_TYPES )
{
    Kokkos::View<int *, DeviceType> v( "v", 2 );
    auto v_host = Kokkos::create_mirror_view( v );
    v_host( 0 ) = 33;
    v_host( 1 ) = 24;
    Kokkos::deep_copy( v, v_host );
    BOOST_TEST( ArborX::lastElement( v ) == 24 );
    Kokkos::View<int *, DeviceType> w( "w", 0 );
    BOOST_CHECK_THROW( ArborX::lastElement( w ), ArborX::SearchException );
    Kokkos::View<double[1], DeviceType> u( "u", 1 );
    Kokkos::deep_copy( u, 3.14 );
    BOOST_TEST( ArborX::lastElement( u ) == 3.14 );
}
void test_case_1()
{
	tsk::spin::unbounded_channel< int > buf;
	BOOST_CHECK_EQUAL( true, buf.empty() );
	BOOST_CHECK_EQUAL( true, buf.active() );
	int n = 1;
	buf.put( n);
	BOOST_CHECK_EQUAL( false, buf.empty() );
	boost::optional< int > res;
	BOOST_CHECK_EQUAL( true, buf.take( res) );
	BOOST_CHECK( res);
	BOOST_CHECK_EQUAL( n, res.get() );
	buf.deactivate();
	BOOST_CHECK_EQUAL( false, buf.active() );
	BOOST_CHECK_THROW( buf.put( 1), std::runtime_error);
}
Пример #29
0
void task4_4::tests_::a_message_constructor_tests()
{
	std::stringstream test_stream;

	BOOST_CHECK_THROW( a_message::create_message( test_stream ), std::logic_error );
	test_stream.clear();

	test_stream << "0123456789123456";
	BOOST_CHECK_NO_THROW( a_message::create_message( test_stream ) );

	test_stream << "0123456789123456";
	message_ptr message = a_message::create_message( test_stream );
	
	BOOST_CHECK_EQUAL( message->type(), 'A' );
	BOOST_CHECK_EQUAL( message->str(), "a_message(0123456789123456)" );
}
void multicast_communication::tests_::quote_message_tests()
{
	quote_message_ptr msg_ptr( new quote_message( &quote_callback ) );

	std::ifstream test_input( SOURCE_DIR "/tests/data/quote_tests.txt" );
	std::string msg;
	std::getline( test_input, msg );
	test_input.close();
	std::stringstream stream( msg.substr( 1 ) );

	BOOST_CHECK_NO_THROW( msg_ptr->parse( stream ) );

	std::stringstream error_stream( "Error message" );

	BOOST_CHECK_THROW( msg_ptr->parse( error_stream ), std::exception );
}