Esempio n. 1
0
BOOST_FIXTURE_TEST_CASE_TEMPLATE( operator_less_test, F, Fixtures, F )
{
  for (unsigned i = 0; i<F::Plist.size(); i++)
    for (unsigned j = 0; j<F::Plist.size(); j++)
      if (i < j) BOOST_CHECK_PREDICATE(F::less,     (F::Plist[i])(F::Plist[j]) );
      else       BOOST_CHECK_PREDICATE(F::not_less, (F::Plist[i])(F::Plist[j]) );
}
Esempio n. 2
0
BOOST_FIXTURE_TEST_CASE_TEMPLATE( constructor_is_permutation_test, F, PermFixtures, F )
{
  //for (auto x : Plist) {
  for (auto it = F::Plist.begin(); it != F::Plist.end(); ++it) {
    auto x = *it;
    BOOST_CHECK_PREDICATE(F::is_perm, (x));
  }
  BOOST_CHECK_PREDICATE(F::is_perm, (typename F::PermType()));
  BOOST_CHECK_PREDICATE(F::is_perm, (typename F::PermType({1,0})));
  BOOST_CHECK_PREDICATE(F::is_perm, (typename F::PermType({1,2,0})));
  BOOST_CHECK_PREDICATE(F::is_not_perm, (typename F::PermType({1,2})));
}
Esempio n. 3
0
BOOST_FIXTURE_TEST_CASE_TEMPLATE( is_permutation_test, F, Fixtures, F )
{
  BOOST_CHECK_PREDICATE(F::is_not_perm, (F::zero));
  BOOST_CHECK_PREDICATE(F::is_perm2, (F::PPa)(16));
  BOOST_CHECK_PREDICATE(F::is_not_perm, (F::PPb));
  BOOST_CHECK_PREDICATE(F::is_perm, (F::RandPerm));
  BOOST_CHECK_PREDICATE(F::is_not_perm,
			(typename F::VectType({3,1,0,14,15,13,3,10,2,11,6,12,7,4,8,9})));
  BOOST_CHECK_PREDICATE(F::is_not_perm2, (F::RandPerm)(4));
  BOOST_CHECK_PREDICATE(F::is_perm2, (F::PPa)(5));
  BOOST_CHECK_PREDICATE(F::is_not_perm2, (F::PPa)(4));
}
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);
}
Esempio n. 5
0
/**
 * Check a #SHAPE_ARC against a given set of geometric properties
 */
static void CheckArcGeom( const SHAPE_ARC& aArc, const ARC_PROPERTIES& aProps )
{
    // Angular error - not this can get quite large for very small arcs,
    // as the integral position rounding has a relatively greater effect
    const double angle_tol_deg = 0.01;

    // Position error - rounding to nearest integer
    const int pos_tol = 1;

    BOOST_CHECK_PREDICATE( KI_TEST::IsVecWithinTol<VECTOR2I>,
            ( aProps.m_start_point )( aProps.m_start_point )( pos_tol ) );
    BOOST_CHECK_PREDICATE(
            KI_TEST::IsVecWithinTol<VECTOR2I>, ( aArc.GetP1() )( aProps.m_end_point )( pos_tol ) );
    BOOST_CHECK_PREDICATE( KI_TEST::IsVecWithinTol<VECTOR2I>,
            ( aArc.GetCenter() )( aProps.m_center_point )( pos_tol ) );
    BOOST_CHECK_PREDICATE( KI_TEST::IsWithin<double>,
            ( aArc.GetCentralAngle() )( aProps.m_center_angle )( angle_tol_deg ) );
    BOOST_CHECK_PREDICATE( KI_TEST::IsWithin<double>,
            ( aArc.GetStartAngle() )( aProps.m_start_angle )( angle_tol_deg ) );
    BOOST_CHECK_PREDICATE( KI_TEST::IsWithin<double>,
            ( aArc.GetEndAngle() )( aProps.m_end_angle )( angle_tol_deg ) );
    BOOST_CHECK_PREDICATE(
            KI_TEST::IsWithin<double>, ( aArc.GetRadius() )( aProps.m_radius )( pos_tol ) );

    /// Check the chord agrees
    const auto chord = aArc.GetChord();

    BOOST_CHECK_PREDICATE(
            KI_TEST::IsVecWithinTol<VECTOR2I>, ( chord.A )( aProps.m_start_point )( pos_tol ) );
    BOOST_CHECK_PREDICATE(
            KI_TEST::IsVecWithinTol<VECTOR2I>, ( chord.B )( aProps.m_end_point )( pos_tol ) );

    /// All arcs are solid
    BOOST_CHECK_EQUAL( aArc.IsSolid(), true );

    BOOST_CHECK_PREDICATE(
            KI_TEST::IsBoxWithinTol<BOX2I>, ( aArc.BBox() )( aProps.m_bbox )( pos_tol ) );

    /// Collisions will be checked elsewhere.
}
Esempio n. 6
0
void do_check_pred()
{
    BOOST_CHECK_PREDICATE( some_pred, (Foo( 1 ))(Foo( 4 ))(Foo( 2 ))(Foo( 3 )) );
    BOOST_CHECK_EQUAL( Foo::copy_counter, 0 );
}