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());
}
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());
}
Exemple #3
0
static void streaming_up_down_test(const SRCParams &params)
{
  // Source noise
  Samples noise(noise_size);
  RNG(seed).fill_samples(noise, noise_size);
  // Upsampled buffer
  Samples buf1(size_t(double(noise_size + 1) * params.fd / params.fs) + 1);
  // Downsampled buffer
  Samples buf2(noise_size + 100);

  StreamingSRC src;

  BOOST_REQUIRE(src.open(params));
  size_t buf1_data = resample(src, noise, noise_size, buf1, buf1.size());

  BOOST_REQUIRE(src.open(SRCParams(params.fd, params.fs, params.a, params.q)));
  size_t buf2_data = resample(src, buf1, buf1_data, buf2, buf2.size());

  BOOST_CHECK(abs(int(buf2_data) - int(noise_size)) <= 1);

  // Resample introduces not more than -A dB of noise.
  // 2 resamples introduces twice more noise, -A + 6dB
  sample_t diff = diff_resampled(params, noise, buf2, MIN(noise_size, buf2_data));
  BOOST_MESSAGE("Transform: " << params.fs << "Hz <-> " << params.fd << "Hz Diff: " << value2db(diff) << " dB");
  BOOST_CHECK_LE(value2db(diff), -params.a + 7);
}
static void
test_less_than_equal_to()
{
	{
		floating_point_emulation::tfloat<T, S> f(42), g(43);
		BOOST_CHECK_LE(f, g);
	}



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

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

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

	{
		floating_point_emulation::tfloat<T, S> f(42.), g(43.);
		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);
	}
}
void DiskFixture::testPosition(std::array<float,3> p)
{
	// check that point lies in plane
	BOOST_CHECK_SMALL(dot(m_normal,p-m_centre),1e-5f);

	// check that point is sufficiently close to centre
	BOOST_CHECK_LE(norm2(p-m_centre), m_radiusSquared);
}
Exemple #6
0
static void equivalence_test(const SRCParams &params)
{
  // Source noise
  Samples noise(noise_size);
  RNG(seed).fill_samples(noise, noise_size);
  // Upsampled buffer
  Samples buf1(size_t(double(noise_size + 1) * params.fd / params.fs) + 1);
  // Downsampled buffer
  Samples buf2(noise_size + 100);

  StreamingSRC src;
  BufferSRC test;
  BOOST_MESSAGE("Transform: " << params.fs << "Hz <-> " << params.fd);

  /////////////////////////////////////////////////////////
  // Resample using StreamingSRC

  BOOST_REQUIRE(src.open(params));
  size_t buf1_data = resample(src, noise, noise_size, buf1, buf1.size());

  BOOST_REQUIRE(src.open(SRCParams(params.fd, params.fs, params.a, params.q)));
  size_t buf2_data = resample(src, buf1, buf1_data, buf2, buf2.size());

  /////////////////////////////////////////////////////////
  // Resample using BufferSRC and check the difference

  BOOST_REQUIRE(test.open(params));
  test.process(noise, noise_size);
  BOOST_REQUIRE_EQUAL(test.size(), buf1_data);
  sample_t diff = peak_diff(test.result(), buf1, buf1_data);
  BOOST_CHECK_LE(diff, SAMPLE_THRESHOLD);

  BOOST_REQUIRE(test.open(SRCParams(params.fd, params.fs, params.a, params.q)));
  test.process(buf1, buf1_data);
  BOOST_REQUIRE_EQUAL(test.size(), buf2_data);
  diff = peak_diff(test.result(), buf2, buf2_data);
  BOOST_CHECK_LE(diff, SAMPLE_THRESHOLD);
}
Exemple #7
0
BOOST_AUTO_TEST_CASE_TEMPLATE
( test_mapping_increment, Tp, int2_sets )
{
  { // test the invarient of the increment
    Tp fix(100, randomize(-3, 3));
    for (dimension_type mapping_dim = 0; mapping_dim < 2;
         ++mapping_dim)
      {
        mapping_iterator<typename Tp::container_type>
          iter = mapping_begin(fix.container, mapping_dim),
          end = mapping_end(fix.container, mapping_dim);
        int count = 0;
        double tmp = (*iter)[mapping_dim];
        for (; iter != end; ++iter)
          {
            BOOST_CHECK_LE(tmp, (*iter)[mapping_dim]);
            tmp = (*iter)[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)
      {
        mapping_iterator<typename Tp::container_type>
          iter = mapping_begin(fix.container, mapping_dim),
          end = mapping_end(fix.container, mapping_dim);
        int count = 0;
        for (; iter != end; ++iter)
          {
            BOOST_CHECK_EQUAL(100, (*iter)[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_cbegin(fix.container, mapping_dim),
          post = mapping_cbegin(fix.container, mapping_dim),
          end = mapping_cend(fix.container, mapping_dim);
        BOOST_CHECK(pre != end);
        BOOST_CHECK(++pre != post++);
        BOOST_CHECK(pre == post);
        BOOST_CHECK(post++ != end);
        BOOST_CHECK(++pre == end);
        BOOST_CHECK(post == end);
      }
  }
  { // 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)
      {
        mapping_iterator<typename Tp::container_type>
          iter = mapping_begin(fix.container, mapping_dim),
          end = mapping_end(fix.container, mapping_dim);
        int count = 0;
        double tmp = (*iter)[mapping_dim];
        for (; iter != end; ++iter)
          {
            BOOST_CHECK_LE(tmp, (*iter)[mapping_dim]);
            tmp = (*iter)[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)
      {
        mapping_iterator<typename Tp::container_type>
          iter = mapping_begin(fix.container, mapping_dim),
          end = mapping_end(fix.container, mapping_dim);
        int count = 0;
        double tmp = (*iter)[mapping_dim];
        for (; iter != end; iter++)
          {
            BOOST_CHECK_LE(tmp, (*iter)[mapping_dim]);
            tmp = (*iter)[mapping_dim];
            if (++count > 100) break;
          }
        BOOST_CHECK_EQUAL(count, 100);
      }
  }
}
BOOST_AUTO_TEST_CASE_TEMPLATE(cmp_le4, mp_int_type, mp_int_types)
{
  const mp_int_type x("11");
  const mp_int_type y("49941");
  BOOST_CHECK_LE(x, y);
}
BOOST_AUTO_TEST_CASE_TEMPLATE(cmp_le3, mp_int_type, mp_int_types)
{
  const mp_int_type x("-123456789");
  const mp_int_type y("-123456789");
  BOOST_CHECK_LE(x, y);
}
Exemple #10
0
BOOST_AUTO_TEST_CASE_TEMPLATE(cmp_le2, mp_int_type, mp_int_types)
{
  const mp_int_type x("-1");
  const mp_int_type y("0");
  BOOST_CHECK_LE(x, y);
}
BOOST_AUTO_TEST_CASE_TEMPLATE
( test_neighbor_decrement, Tp, int2_maps )
{
  // Prove that you can iterate N nodes, down to 1 node
  {
    Tp fix(100, randomize(-20, 20));
    int2 target;
    typedef typename neighbor_iterator<typename Tp::container_type>
      ::distance_type distance_type;
    while (!fix.container.empty())
      {
        randomize(-22, 22)(target, 0, 0);
        size_t countdown = fix.container.size();
        std::reverse_iterator<neighbor_iterator<typename Tp::container_type> >
          iter(--neighbor_end(fix.container, target)),
          end(neighbor_begin(fix.container, target));
        distance_type max_dist = distance(iter.base());
        for(; --countdown != 0 && iter != end; ++iter)
          {
            distance_type tmp = distance(iter.base());
            BOOST_CHECK_LE(tmp, max_dist);
            max_dist = tmp;
          }
        BOOST_CHECK_EQUAL(countdown, 0u);
        BOOST_CHECK(iter == end);
        fix.container.erase(fix.container.begin());
      }
  }
  // Prove that you can iterate a very unbalanced tree
  {
    Tp fix(40, increase());
    int2 target;
    typedef typename neighbor_iterator<typename Tp::container_type>
      ::distance_type distance_type;
    while (!fix.container.empty())
      {
        randomize(0, 40)(target, 0, 0);
        size_t countdown = fix.container.size();
        std::reverse_iterator<neighbor_iterator<typename Tp::container_type> >
          iter(--neighbor_end(fix.container, target)),
          end(neighbor_begin(fix.container, target));
        distance_type max_dist = distance(iter.base());
        for(; --countdown != 0 && iter != end; ++iter)
          {
            distance_type tmp = distance(iter.base());
            BOOST_CHECK_LE(tmp, max_dist);
            max_dist = tmp;
          }
        BOOST_CHECK_EQUAL(countdown, 0u);
        BOOST_CHECK(iter == end);
        fix.container.erase(fix.container.begin());
      }
  }
  // Prove that you can iterate an opposite unbalanced tree
  {
    Tp fix(40, decrease());
    int2 target;
    typedef typename neighbor_iterator<typename Tp::container_type>
      ::distance_type distance_type;
    while (!fix.container.empty())
      {
        randomize(0, 40)(target, 0, 0);
        size_t countdown = fix.container.size();
        std::reverse_iterator<neighbor_iterator<typename Tp::container_type> >
          iter(--neighbor_end(fix.container, target)),
          end(neighbor_begin(fix.container, target));
        distance_type max_dist = distance(iter.base());
        for(; --countdown != 0 && iter != end; ++iter)
          {
            distance_type tmp = distance(iter.base());
            BOOST_CHECK_LE(tmp, max_dist);
            max_dist = tmp;
          }
        BOOST_CHECK_EQUAL(countdown, 0u);
        BOOST_CHECK(iter == end);
        fix.container.erase(fix.container.begin());
      }
  }
  // Prove that you can iterate equivalent nodes
  {
    int2 target;
    same()(target, 0, 100);
    Tp fix(100, same());
    std::reverse_iterator<neighbor_iterator<typename Tp::container_type> >
      iter(neighbor_end(fix.container, target)),
      end(neighbor_begin(fix.container, target));
    size_t count = 1;
    ++iter;
    for(; iter != end && count < fix.container.size(); ++iter, ++count)
      {
        BOOST_CHECK_CLOSE(distance(iter.base()), 0.0, 0.000000001);
      }
    BOOST_CHECK(iter == end);
    BOOST_CHECK_EQUAL(count, fix.container.size());
  }
}
Exemple #12
0
BOOST_AUTO_TEST_CASE_TEMPLATE(cmp_mp_int_le_unsigned_integral_type, mp_int_type, mp_int_types)
{
  const mp_int_type x("0");
  BOOST_CHECK_LE(x, 32101U);
}
Exemple #13
0
BOOST_AUTO_TEST_CASE_TEMPLATE(cmp_mp_int_le_integral_type1, mp_int_type, mp_int_types)
{
  const mp_int_type x("0");
  BOOST_CHECK_LE(x, 123456789);
}
Exemple #14
0
BOOST_AUTO_TEST_CASE_TEMPLATE(cmp_mp_int_lt_integral_type2, mp_int_type, mp_int_types)
{
  const mp_int_type x("0x100000000");
  BOOST_CHECK_LE(1, x);
}
typename bg::default_area_result<G1>::type
check_result(
    std::vector<OutputType> const& intersection_output,
    std::string const& caseid,
    std::size_t expected_count = 0, int expected_point_count = 0,
    double expected_length_or_area = 0,
    double percentage = 0.0001,
    bool debug = false)
{
    bool const is_line = bg::geometry_id<OutputType>::type::value == 2;

    typename bg::default_area_result<G1>::type length_or_area = 0;
    int n = 0;
    for (typename std::vector<OutputType>::const_iterator it = intersection_output.begin();
            it != intersection_output.end();
            ++it)
    {
        if (expected_point_count > 0)
        {
            // here n should rather be of type std::size_t, but expected_point_count
            // is set to -1 in some test cases so type int was left for now
            n += static_cast<int>(bg::num_points(*it, true));
        }

        // instead of specialization we check it run-time here
        length_or_area += is_line
            ? bg::length(*it)
            : bg::area(*it);

        if (debug)
        {
            std::cout << std::setprecision(20) << bg::wkt(*it) << std::endl;
        }
    }

#if ! defined(BOOST_GEOMETRY_NO_BOOST_TEST)
#if ! defined(BOOST_GEOMETRY_NO_ROBUSTNESS)
    if (expected_point_count > 0)
    {
        BOOST_CHECK_MESSAGE(bg::math::abs(n - expected_point_count) < 3,
                "intersection: " << caseid
                << " #points expected: " << expected_point_count
                << " detected: " << n
                << " type: " << (type_for_assert_message<G1, G2>())
                );
    }
#endif

    if (expected_count > 0)
    {
        BOOST_CHECK_MESSAGE(intersection_output.size() == expected_count,
                "intersection: " << caseid
                << " #outputs expected: " << expected_count
                << " detected: " << intersection_output.size()
                << " type: " << (type_for_assert_message<G1, G2>())
                );
    }

    double const detected_length_or_area = boost::numeric_cast<double>(length_or_area);
    if (percentage > 0.0)
    {
        BOOST_CHECK_CLOSE(detected_length_or_area, expected_length_or_area, percentage);
    }
    else
    {
        // In some cases (geos_2) the intersection is either 0, or a tiny rectangle,
        // depending on compiler/settings. That cannot be tested by CLOSE
        BOOST_CHECK_LE(detected_length_or_area, expected_length_or_area);
    }
#endif

    return length_or_area;
}
void do_check_le()
{
    int i = 62;
    BOOST_CHECK_LE( i, 16 );
}
Exemple #17
0
BOOST_AUTO_TEST_CASE_TEMPLATE(cmp_integral_type_le_mp_int, mp_int_type, mp_int_types)
{
  const mp_int_type x("32101");
  BOOST_CHECK_LE(x, 32102);
}
BOOST_AUTO_TEST_CASE_TEMPLATE
( test_neighbor_upper_bound, Tp, quad_sets )
{
  typedef quadrance<typename Tp::container_type, int, quad_diff> metric_type;
  typedef typename metric_type::distance_type distance_type;
  typedef neighbor_iterator<typename Tp::container_type, metric_type>
    neighbor_iterator_type;
  // Prove that you can find lower bound with N nodes, down to 1 node
  {
    Tp fix(100, randomize(-20, 20));
    metric_type metric;
    quad target;
    while (!fix.container.empty())
      {
        randomize(-22, 22)(target, 0, 0);
        // Find min and max dist first
        distance_type min_dist;
        distance_type max_dist;
        typename Tp::container_type::iterator it = fix.container.begin();
        min_dist = max_dist
          = metric.distance_to_key(fix.container.rank()(), *it, target);
        ++it;
        for (; it != fix.container.end(); ++it)
          {
            distance_type tmp
              = metric.distance_to_key(fix.container.rank()(), *it, target);
            if (tmp < min_dist) min_dist = tmp;
            if (tmp > max_dist) max_dist = tmp;
          }
        distance_type avg_dist = (min_dist + max_dist) / 2;
        // use this knowledge to test the upper bound
        neighbor_iterator_type i
          = neighbor_upper_bound(fix.container, metric, target, min_dist);
        BOOST_CHECK(i != neighbor_begin(fix.container, metric, target));
        if (i != neighbor_end(fix.container, metric, target))
          { BOOST_CHECK_LT(min_dist, distance(i)); }
        BOOST_CHECK_EQUAL(min_dist, distance(--i));
        i = neighbor_upper_bound(fix.container, metric, target, max_dist);
        BOOST_CHECK(i == neighbor_end(fix.container, metric, target));
        i = neighbor_upper_bound(fix.container, metric, target, avg_dist);
        if (i != neighbor_end(fix.container, metric, target))
          { BOOST_CHECK_GT(distance(i), avg_dist); }
        if (i == neighbor_end(fix.container, metric, target))
          { BOOST_CHECK_LE(distance(--i), avg_dist); }
        fix.container.erase(i);
      }
  }
  // Prove that you can find the upper bound when node and target are same
  {
    Tp fix(100, same());
    metric_type metric;
    quad target;
    same()(target, 0, 100);
    // All points and targets are the same.
    while (!fix.container.empty())
      {
        neighbor_iterator_type i
          = neighbor_upper_bound(fix.container, metric, target, 1);
        BOOST_CHECK(i == neighbor_end(fix.container, metric, target));
        i = neighbor_upper_bound(fix.container, metric, target, 0);
        BOOST_CHECK(i == neighbor_end(fix.container, metric, target));
        fix.container.erase(--i);
      }
  }
  // Prove that you can find the upper bound in an unbalanced tree
  {
    Tp fix(100, increase());
    metric_type metric;
    quad target;
    while (!fix.container.empty())
      {
        randomize(0, 100)(target, 0, 0);
        // Find min and max dist first
        distance_type min_dist;
        distance_type max_dist;
        typename Tp::container_type::iterator it = fix.container.begin();
        min_dist = max_dist
          = metric.distance_to_key(fix.container.rank()(), *it, target);
        ++it;
        for (; it != fix.container.end(); ++it)
          {
            distance_type tmp
              = metric.distance_to_key(fix.container.rank()(), *it, target);
            if (tmp < min_dist) min_dist = tmp;
            if (tmp > max_dist) max_dist = tmp;
          }
        distance_type avg_dist = (min_dist + max_dist) / 2;
        // Use this knowledge to test the upper bound
        neighbor_iterator_type i
          = neighbor_upper_bound(fix.container, metric, target, min_dist);
        BOOST_CHECK(i != neighbor_begin(fix.container, metric, target));
        if (i != neighbor_end(fix.container, metric, target))
          { BOOST_CHECK_LT(min_dist, distance(i)); }
        BOOST_CHECK_EQUAL(min_dist, distance(--i));
        i = neighbor_upper_bound(fix.container, metric, target, max_dist);
        BOOST_CHECK(i == neighbor_end(fix.container, metric, target));
        i = neighbor_upper_bound(fix.container, metric, target, avg_dist);
        if (i != neighbor_end(fix.container, metric, target))
          { BOOST_CHECK_GT(distance(i), avg_dist); }
        if (i == neighbor_end(fix.container, metric, target))
          { BOOST_CHECK_LE(distance(--i), avg_dist); }
        fix.container.erase(i);
      }
  }
  // Prove that you can find the upper bound in an unbalanced tree
  {
    Tp fix(100, decrease());
    metric_type metric;
    quad target;
    while (!fix.container.empty())
      {
        randomize(0, 100)(target, 0, 0);
        // Find min and max dist first
        distance_type min_dist;
        distance_type max_dist;
        typename Tp::container_type::iterator it = fix.container.begin();
        min_dist = max_dist
          = metric.distance_to_key(fix.container.rank()(), *it, target);
        ++it;
        for (; it != fix.container.end(); ++it)
          {
            distance_type tmp
              = metric.distance_to_key(fix.container.rank()(), *it, target);
            if (tmp < min_dist) min_dist = tmp;
            if (tmp > max_dist) max_dist = tmp;
          }
        distance_type avg_dist = (min_dist + max_dist) / 2;
        // Use this knowledge to test the upper bound
        neighbor_iterator_type i
          = neighbor_upper_bound(fix.container, metric, target, min_dist);
        BOOST_CHECK(i != neighbor_begin(fix.container, metric, target));
        if (i != neighbor_end(fix.container, metric, target))
          { BOOST_CHECK_LT(min_dist, distance(i)); }
        BOOST_CHECK_EQUAL(min_dist, distance(--i));
        i = neighbor_upper_bound(fix.container, metric, target, max_dist);
        BOOST_CHECK(i == neighbor_end(fix.container, metric, target));
        i = neighbor_upper_bound(fix.container, metric, target, avg_dist);
        if (i != neighbor_end(fix.container, metric, target))
          { BOOST_CHECK_GT(distance(i), avg_dist); }
        if (i == neighbor_end(fix.container, metric, target))
          { BOOST_CHECK_LE(distance(--i), avg_dist); }
        fix.container.erase(i);
      }
  }
}