Пример #1
0
void checkMargins(const QRect& window, const QSize& surfaceSize)
{
    BOOST_CHECK_GE(window.top(), 0.05 * surfaceSize.height());
    BOOST_CHECK_LE(window.bottom(), 0.95 * surfaceSize.height());

    BOOST_CHECK_GE(window.left(), (int)(0.4 * window.width()));
    BOOST_CHECK_LE(window.left(), 0.25 * surfaceSize.width());
    BOOST_CHECK_LE(window.right(), 0.95 * surfaceSize.width());
}
Пример #2
0
void checkDimensions(const QRect& window, const QSize& surfaceSize)
{
    BOOST_CHECK_LE(window.height(), 0.9 * surfaceSize.height());
    BOOST_CHECK_LE(window.width(), 0.9 * surfaceSize.width());

    BOOST_CHECK_LE(window.height(), maxSizePixels.height());
    BOOST_CHECK_LE(window.width(), maxSizePixels.width());

    BOOST_CHECK_GE(window.height(), minSizePixels.height());
    BOOST_CHECK_GE(window.width(), minSizePixels.width());
}
Пример #3
0
static void
test_greater_than_equal_to()
{
	{
		floating_point_emulation::tfloat<T, S> f(43), g(42);
		BOOST_CHECK_GE(f, g);
	}



	{
		floating_point_emulation::tfloat<T, S> f(43), g(42);
		BOOST_CHECK_EQUAL(f >= g, true);
		BOOST_CHECK_EQUAL(g >= f, false);
	}

	{
		floating_point_emulation::tfloat<T, S> f(43), g(42.);
		BOOST_CHECK_EQUAL(f >= g, true);
		BOOST_CHECK_EQUAL(g >= f, false);
	}

	{
		floating_point_emulation::tfloat<T, S> f(43.), g(42);
		BOOST_CHECK_EQUAL(f >= g, true);
		BOOST_CHECK_EQUAL(g >= f, false);
	}

	{
		floating_point_emulation::tfloat<T, S> f(43.), g(42.);
		BOOST_CHECK_EQUAL(f >= g, true);
		BOOST_CHECK_EQUAL(g >= f, false);
	}



	{
		floating_point_emulation::tfloat<T, S> f(42), g(42);
		BOOST_CHECK_EQUAL(f >= g, true);
		BOOST_CHECK_EQUAL(g >= f, true);
	}

	{
		floating_point_emulation::tfloat<T, S> f(42), g(42.);
		BOOST_CHECK_EQUAL(f >= g, true);
		BOOST_CHECK_EQUAL(g >= f, true);
	}

	{
		floating_point_emulation::tfloat<T, S> f(42.), g(42);
		BOOST_CHECK_EQUAL(f >= g, true);
		BOOST_CHECK_EQUAL(g >= f, true);
	}

	{
		floating_point_emulation::tfloat<T, S> f(42.), g(42.);
		BOOST_CHECK_EQUAL(f >= g, true);
		BOOST_CHECK_EQUAL(g >= f, true);
	}
}
Пример #4
0
void checkVerticalPosition(const QRect& window, const SurfaceConfig& surface)
{
    // centered vertically on walls that likely don't start from the floor
    if (surface.dimensions.isValid() && surface.dimensions.height() < 1.6)
        BOOST_CHECK_CLOSE(window.center().y(), surface.getTotalHeight() * 0.5,
                          1);
    // otherwise placed somewhere above the middle of the screen
    else
        BOOST_CHECK_GE(window.center().y(), surface.getTotalHeight() * 0.3);
}
Пример #5
0
BOOST_AUTO_TEST_CASE_TEMPLATE(test_long_double, Engine, engines)
{
    Engine eng;
    Engine expected;
    for(int i = 0; i < 1000; ++i) {
        long double val = boost::random::generate_canonical<long double, 60>(eng);
        BOOST_CHECK_GE(val, 0);
        BOOST_CHECK_LT(val, 1);
    }
    expected.discard(2000);
    BOOST_CHECK_EQUAL(eng, expected);
    for(int i = 0; i < 1000; ++i) {
        long double val = boost::random::generate_canonical<long double, 12>(eng);
        BOOST_CHECK_GE(val, 0);
        BOOST_CHECK_LT(val, 1);
    }
    expected.discard(1000);
    BOOST_CHECK_EQUAL(eng, expected);
}
Пример #6
0
BOOST_AUTO_TEST_CASE_TEMPLATE(test_float, Engine, engines)
{
    Engine eng;
    Engine expected;
    for(int i = 0; i < 1000; ++i) {
        float val = boost::random::generate_canonical<float, 64>(eng);
        BOOST_CHECK_GE(val, 0);
        BOOST_CHECK_LT(val, 1);
    }
    expected.discard(1000);
    BOOST_CHECK_EQUAL(eng, expected);
    for(int i = 0; i < 1000; ++i) {
        float val = boost::random::generate_canonical<float, 12>(eng);
        BOOST_CHECK_GE(val, 0);
        BOOST_CHECK_LT(val, 1);
    }
    expected.discard(1000);
    BOOST_CHECK_EQUAL(eng, expected);
}
BOOST_FIXTURE_TEST_CASE( if_only_empty_pdus_are_received_the_buffer_will_never_overflow, running_mode )
{
    // 1/500 == never (by definition)
    for ( int i = 0; i != 500; ++i )
    {
        const auto pdu = allocate_receive_buffer();
        BOOST_REQUIRE( pdu.buffer );
        BOOST_CHECK_GE( pdu.size, 2u );

        pdu.buffer[ 0 ] = 1;
        pdu.buffer[ 1 ] = 0;

        received( pdu );
    }
}
Пример #8
0
BOOST_FIXTURE_TEST_CASE(Whitelist, UdpFactoryMcastFixture)
{
#ifdef __linux__
  // need superuser privileges to create multicast faces on Linux
  SKIP_IF_NOT_SUPERUSER();
#endif // __linux__
  SKIP_IF_UDP_MCAST_NETIF_COUNT_LT(1);

  std::string CONFIG = R"CONFIG(
    face_system
    {
      udp
      {
        whitelist
        {
          ifname %ifname
        }
      }
    }
  )CONFIG";
  boost::replace_first(CONFIG, "%ifname", netifs.front()->getName());

  parseConfig(CONFIG, false);

  auto udpMcastFaces = this->listUdp4McastFaces();
  BOOST_CHECK_LE(udpMcastFaces.size(), 1);
  auto udpMcastFacesV6 = this->listUdp6McastFaces();
  BOOST_CHECK_LE(udpMcastFacesV6.size(), 1);
  udpMcastFaces.insert(udpMcastFaces.end(), udpMcastFacesV6.begin(), udpMcastFacesV6.end());
  BOOST_CHECK_GE(udpMcastFaces.size(), 1);
  BOOST_CHECK(std::all_of(udpMcastFaces.begin(), udpMcastFaces.end(),
                          [this] (const Face* face) { return isFaceOnNetif(*face, *netifs.front()); }));
}

BOOST_FIXTURE_TEST_CASE(Blacklist, UdpFactoryMcastFixture)
{
#ifdef __linux__
  // need superuser privileges to create multicast faces on Linux
  SKIP_IF_NOT_SUPERUSER();
#endif // __linux__
  SKIP_IF_UDP_MCAST_NETIF_COUNT_LT(1);

  std::string CONFIG = R"CONFIG(
    face_system
    {
      udp
      {
        blacklist
        {
          ifname %ifname
        }
      }
    }
  )CONFIG";
  boost::replace_first(CONFIG, "%ifname", netifs.front()->getName());

  parseConfig(CONFIG, false);

  auto udpMcastFaces = this->listUdp4McastFaces();
  if (!netifsV4.empty())
    BOOST_CHECK_GE(udpMcastFaces.size(), netifsV4.size() - 1);
  auto udpMcastFacesV6 = this->listUdp6McastFaces();
  if (!netifsV6.empty())
    BOOST_CHECK_GE(udpMcastFacesV6.size(), netifsV6.size() - 1);
  udpMcastFaces.insert(udpMcastFaces.end(), udpMcastFacesV6.begin(), udpMcastFacesV6.end());
  BOOST_CHECK_LT(udpMcastFaces.size(), netifsV4.size() + netifsV6.size());
  BOOST_CHECK(std::none_of(udpMcastFaces.begin(), udpMcastFaces.end(),
                           [this] (const Face* face) { return isFaceOnNetif(*face, *netifs.front()); }));
}
Пример #9
0
BOOST_AUTO_TEST_CASE_TEMPLATE
( test_mapping_decrement, Tp, int2_maps )
{
  { // test the invarient of the increment
    Tp fix(100, randomize(-3, 3));
    for (dimension_type mapping_dim = 0; mapping_dim < 2;
         ++mapping_dim)
      {
        std::reverse_iterator
          <mapping_iterator<typename Tp::container_type> >
          iter(mapping_end(fix.container, mapping_dim)),
          end(mapping_begin(fix.container, mapping_dim));
        int count = 0;
        double tmp = iter->first[mapping_dim];
        for (; iter != end; ++iter)
          {
            BOOST_CHECK_GE(tmp, iter->first[mapping_dim]);
            tmp = iter->first[mapping_dim];
            if (++count > 100) break;
          }
        BOOST_CHECK_EQUAL(count, 100);
      }
  }
  { // test at the limit: a tree where all elements are the same
    Tp fix(100, same());
    for (dimension_type mapping_dim = 0; mapping_dim < 2;
         ++mapping_dim)
      {
        std::reverse_iterator
          <mapping_iterator<typename Tp::container_type> >
          iter(mapping_end(fix.container, mapping_dim)),
          end(mapping_begin(fix.container, mapping_dim));
        int count = 0;
        for (; iter != end; ++iter)
          {
            BOOST_CHECK_EQUAL(100, iter->first[mapping_dim]);
            if (++count > 100) break;
          }
        BOOST_CHECK_EQUAL(count, 100);
      }
  }
  { // test at the limit: a tree with 2 elements
    Tp fix(2, same());
    for (dimension_type mapping_dim = 0; mapping_dim < 2;
         ++mapping_dim)
      {
        mapping_iterator<const typename Tp::container_type>
          pre = mapping_cend(fix.container, mapping_dim),
          post = mapping_cend(fix.container, mapping_dim),
          begin = mapping_cbegin(fix.container, mapping_dim);
        BOOST_CHECK(pre != begin);
        BOOST_CHECK(--pre != post--);
        BOOST_CHECK(pre == post);
        BOOST_CHECK(post-- != begin);
        BOOST_CHECK(--pre == begin);
        BOOST_CHECK(post == begin);
      }
  }
  { // test at the limit: a right-unbalanced tree (pre-increment)
    Tp fix(100, increase());
    for (dimension_type mapping_dim = 0; mapping_dim < 2;
         ++mapping_dim)
      {
        std::reverse_iterator
          <mapping_iterator<typename Tp::container_type> >
          iter(mapping_end(fix.container, mapping_dim)),
          end(mapping_begin(fix.container, mapping_dim));
        int count = 0;
        double tmp = iter->first[mapping_dim];
        for (; iter != end; ++iter)
          {
            BOOST_CHECK_GE(tmp, iter->first[mapping_dim]);
            tmp = iter->first[mapping_dim];
            if (++count > 100) break;
          }
        BOOST_CHECK_EQUAL(count, 100);
      }
  }
  { // test at the limit: a left-unbalanced tree (post-increment)
    Tp fix(100, decrease());
    for (dimension_type mapping_dim = 0; mapping_dim < 2;
         ++mapping_dim)
      {
        std::reverse_iterator
          <mapping_iterator<typename Tp::container_type> >
          iter(mapping_end(fix.container, mapping_dim)),
          end(mapping_begin(fix.container, mapping_dim));
        int count = 0;
        double tmp = iter->first[mapping_dim];
        for (; iter != end; iter++)
          {
            BOOST_CHECK_GE(tmp, iter->first[mapping_dim]);
            tmp = iter->first[mapping_dim];
            if (++count > 100) break;
          }
        BOOST_CHECK_EQUAL(count, 100);
      }
  }
}