Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r76657 - in sandbox/gtl: boost/polygon boost/polygon/detail libs/polygon/test
From: sydorchuk.andriy_at_[hidden]
Date: 2012-01-23 18:19:33


Author: asydorchuk
Date: 2012-01-23 18:19:31 EST (Mon, 23 Jan 2012)
New Revision: 76657
URL: http://svn.boost.org/trac/boost/changeset/76657

Log:
Updating tests after moving to voronoi_ctypes.
Added:
   sandbox/gtl/libs/polygon/test/voronoi_ctypes_test.cpp (contents, props changed)
Text files modified:
   sandbox/gtl/boost/polygon/detail/voronoi_ctypes.hpp | 5
   sandbox/gtl/boost/polygon/voronoi_diagram.hpp | 2
   sandbox/gtl/libs/polygon/test/Jamfile.v2 | 1
   sandbox/gtl/libs/polygon/test/voronoi_builder_test.cpp | 59 +++++---
   sandbox/gtl/libs/polygon/test/voronoi_predicates_test.cpp | 5
   sandbox/gtl/libs/polygon/test/voronoi_robust_fpt_test.cpp | 254 ---------------------------------------
   6 files changed, 45 insertions(+), 281 deletions(-)

Modified: sandbox/gtl/boost/polygon/detail/voronoi_ctypes.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/detail/voronoi_ctypes.hpp (original)
+++ sandbox/gtl/boost/polygon/detail/voronoi_ctypes.hpp 2012-01-23 18:19:31 EST (Mon, 23 Jan 2012)
@@ -224,7 +224,7 @@
             val *= 2.0;
             --exp;
         }
- return extended_exponent_fpt(get_sqrt(val), exp >> 1);
+ return extended_exponent_fpt(std::sqrt(val), exp >> 1);
     }
 
     fpt_type d() const {
@@ -736,9 +736,8 @@
     typedef type_converter_fpt to_fpt_converter_type;
     typedef type_converter_efpt to_efpt_converter_type;
 };
-
 } // detail
 } // polygon
 } // boost
 
-#endif
\ No newline at end of file
+#endif

Modified: sandbox/gtl/boost/polygon/voronoi_diagram.hpp
==============================================================================
--- sandbox/gtl/boost/polygon/voronoi_diagram.hpp (original)
+++ sandbox/gtl/boost/polygon/voronoi_diagram.hpp 2012-01-23 18:19:31 EST (Mon, 23 Jan 2012)
@@ -16,7 +16,7 @@
 #include <vector>
 
 #include "polygon.hpp"
-#include "detail/voronoi_robust_fpt.hpp"
+#include "detail/voronoi_ctypes.hpp"
 
 namespace boost {
 namespace polygon {

Modified: sandbox/gtl/libs/polygon/test/Jamfile.v2
==============================================================================
--- sandbox/gtl/libs/polygon/test/Jamfile.v2 (original)
+++ sandbox/gtl/libs/polygon/test/Jamfile.v2 2012-01-23 18:19:31 EST (Mon, 23 Jan 2012)
@@ -30,6 +30,7 @@
     :
         [ run voronoi_builder_test.cpp ]
         [ run voronoi_clipping_test.cpp ]
+ [ run voronoi_ctypes_test.cpp ]
         [ run voronoi_predicates_test.cpp ]
         [ run voronoi_robust_fpt_test.cpp ]
         [ run voronoi_structures_test.cpp ]

Modified: sandbox/gtl/libs/polygon/test/voronoi_builder_test.cpp
==============================================================================
--- sandbox/gtl/libs/polygon/test/voronoi_builder_test.cpp (original)
+++ sandbox/gtl/libs/polygon/test/voronoi_builder_test.cpp 2012-01-23 18:19:31 EST (Mon, 23 Jan 2012)
@@ -1,6 +1,6 @@
 // Boost.Polygon library voronoi_builder_test.cpp file
 
-// Copyright Andrii Sydorchuk 2010-2011.
+// Copyright Andrii Sydorchuk 2010-2012.
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
@@ -63,7 +63,7 @@
     std::vector< point_data<T> > points;
     points.push_back(point_data<T>(0, 0));
     vd_type test_output;
- construct_voronoi_points<T>(points, test_output);
+ construct_voronoi_points(points, &test_output);
     VERIFY_OUTPUT(test_output);
 
     CHECK_BRECT(test_output.bounding_rectangle(), 0, 0, 0, 0);
@@ -80,7 +80,7 @@
     points.push_back(point_data<T>(0, 0));
     points.push_back(point_data<T>(0, 1));
     vd_type test_output;
- construct_voronoi_points<T>(points, test_output);
+ construct_voronoi_points(points, &test_output);
     VERIFY_OUTPUT(test_output);
 
     CHECK_BRECT(test_output.bounding_rectangle(), 0, 0, 0, 1);
@@ -115,7 +115,7 @@
     points.push_back(point_data<T>(1, 1));
     points.push_back(point_data<T>(2, 2));
     vd_type test_output;
- construct_voronoi_points<T>(points, test_output);
+ construct_voronoi_points(points, &test_output);
     VERIFY_OUTPUT(test_output);
 
     CHECK_BRECT(test_output.bounding_rectangle(), 0, 0, 2, 2);
@@ -156,7 +156,7 @@
     points.push_back(point2);
     points.push_back(point3);
     vd_type test_output;
- construct_voronoi_points<T>(points, test_output);
+ construct_voronoi_points(points, &test_output);
     VERIFY_OUTPUT(test_output);
 
     CHECK_BRECT(test_output.bounding_rectangle(), 0, 0, 2, 4);
@@ -208,7 +208,7 @@
     points.push_back(point2);
     points.push_back(point3);
     vd_type test_output;
- construct_voronoi_points<T>(points, test_output);
+ construct_voronoi_points(points, &test_output);
     VERIFY_OUTPUT(test_output);
 
     CHECK_BRECT(test_output.bounding_rectangle(), 0, 0, 2, 4);
@@ -262,7 +262,7 @@
     points.push_back(point3);
     points.push_back(point4);
     vd_type test_output;
- construct_voronoi_points<T>(points, test_output);
+ construct_voronoi_points(points, &test_output);
     VERIFY_OUTPUT(test_output);
 
     CHECK_BRECT(test_output.bounding_rectangle(), 0, 0, 1, 1);
@@ -323,6 +323,8 @@
     int max_value[4] = {10, 33, 101, 163};
     int array_length = sizeof(grid_size) / sizeof(int);
     for (int k = 0; k < array_length; k++) {
+ test_output_small.clear();
+ test_output_large.clear();
         point_vec_small.clear();
         point_vec_large.clear();
         int koef = std::numeric_limits<int>::max() / max_value[k];
@@ -331,8 +333,8 @@
                 point_vec_small.push_back(point_data<T>(i, j));
                 point_vec_large.push_back(point_data<T>(koef * i, koef * j));
             }
- construct_voronoi_points<T>(point_vec_small, test_output_small);
- construct_voronoi_points<T>(point_vec_large, test_output_large);
+ construct_voronoi_points(point_vec_small, &test_output_small);
+ construct_voronoi_points(point_vec_large, &test_output_large);
         VERIFY_OUTPUT(test_output_small);
         VERIFY_OUTPUT(test_output_large);
         int num_cells = grid_size[k] * grid_size[k];
@@ -357,6 +359,8 @@
     for (int k = 0; k < array_length; k++) {
         int koef = std::numeric_limits<int>::max() / max_value[k];
         for (int i = 0; i < num_runs[k]; i++) {
+ test_output_small.clear();
+ test_output_large.clear();
             point_vec_small.clear();
             point_vec_large.clear();
             for (int j = 0; j < num_points[k]; j++) {
@@ -365,8 +369,8 @@
                 point_vec_small.push_back(point_data<T>(x, y));
                 point_vec_large.push_back(point_data<T>(koef * x, koef * y));
             }
- construct_voronoi_points<T>(point_vec_small, test_output_small);
- construct_voronoi_points<T>(point_vec_large, test_output_large);
+ construct_voronoi_points(point_vec_small, &test_output_small);
+ construct_voronoi_points(point_vec_large, &test_output_large);
             VERIFY_OUTPUT(test_output_small);
             VERIFY_OUTPUT(test_output_large);
             BOOST_CHECK_EQUAL(test_output_small.num_cell_records(),
@@ -387,7 +391,7 @@
     std::vector< point_data<T> > point_vec;
     for (int i = 0; i < 1000000; i++)
         point_vec.push_back(point_data<T>(gen() % 10000 - 5000, gen() % 10000 - 5000));
- construct_voronoi_points<T>(point_vec, test_output);
+ construct_voronoi_points(point_vec, &test_output);
     BOOST_CHECK_EQUAL(voronoi_test_helper::verify_output(test_output,
         voronoi_test_helper::FAST_VERIFICATION), true);
 }
@@ -399,7 +403,7 @@
     point_data<T> point1(0, 0);
     point_data<T> point2(1, 1);
     segments.insert(directed_line_segment_data<T>(point1, point2));
- construct_voronoi_segments<T>(segments, test_output);
+ construct_voronoi_segments(segments, &test_output);
     CHECK_OUTPUT_SIZE(test_output, 3, 0, 2);
     VERIFY_NO_HALF_EDGE_INTERSECTIONS(test_output);
 }
@@ -415,7 +419,7 @@
     segments.insert(directed_line_segment_data<T>(point1, point2));
     points.push_back(point3);
     points.push_back(point4);
- construct_voronoi<T>(points, segments, test_output);
+ construct_voronoi(points, segments, &test_output);
     CHECK_OUTPUT_SIZE(test_output, 5, 4, 8);
     VERIFY_NO_HALF_EDGE_INTERSECTIONS(test_output);
 }
@@ -431,7 +435,7 @@
     segments.insert(directed_line_segment_data<T>(point1, point2));
     points.push_back(point3);
     points.push_back(point4);
- construct_voronoi<T>(points, segments, test_output);
+ construct_voronoi(points, segments, &test_output);
     CHECK_OUTPUT_SIZE(test_output, 5, 4, 8);
     VERIFY_NO_HALF_EDGE_INTERSECTIONS(test_output);
 }
@@ -447,7 +451,7 @@
     segments.insert(directed_line_segment_data<T>(point1, point2));
     points.push_back(point3);
     points.push_back(point4);
- construct_voronoi<T>(points, segments, test_output);
+ construct_voronoi(points, segments, &test_output);
     CHECK_OUTPUT_SIZE(test_output, 5, 3, 7);
     VERIFY_NO_HALF_EDGE_INTERSECTIONS(test_output);
 }
@@ -465,7 +469,7 @@
     points.push_back(point3);
     points.push_back(point4);
     points.push_back(point5);
- construct_voronoi<T>(points, segments, test_output);
+ construct_voronoi(points, segments, &test_output);
     CHECK_OUTPUT_SIZE(test_output, 6, 4, 9);
     VERIFY_NO_HALF_EDGE_INTERSECTIONS(test_output);
 }
@@ -479,7 +483,7 @@
     point_data<T> point3(1, 2);
     segments.insert(directed_line_segment_data<T>(point2, point3));
     points.push_back(point1);
- construct_voronoi<T>(points, segments, test_output);
+ construct_voronoi(points, segments, &test_output);
     CHECK_OUTPUT_SIZE(test_output, 4, 2, 5);
     VERIFY_NO_HALF_EDGE_INTERSECTIONS(test_output);
 }
@@ -494,7 +498,7 @@
     segments.insert(directed_line_segment_data<T>(point1, point2));
     segments.insert(directed_line_segment_data<T>(point2, point3));
     segments.insert(directed_line_segment_data<T>(point3, point4));
- construct_voronoi_segments<T>(segments, test_output);
+ construct_voronoi_segments(segments, &test_output);
     CHECK_OUTPUT_SIZE(test_output, 7, 6, 12);
     VERIFY_NO_HALF_EDGE_INTERSECTIONS(test_output);
 }
@@ -510,7 +514,7 @@
     segments.insert(directed_line_segment_data<T>(point2, point3));
     segments.insert(directed_line_segment_data<T>(point3, point4));
     segments.insert(directed_line_segment_data<T>(point4, point1));
- construct_voronoi_segments<T>(segments, test_output);
+ construct_voronoi_segments(segments, &test_output);
     CHECK_OUTPUT_SIZE(test_output, 8, 5, 12);
     VERIFY_NO_HALF_EDGE_INTERSECTIONS(test_output);
 }
@@ -523,6 +527,8 @@
     int max_value[] = {100, 330, 1000};
     int array_length = sizeof(grid_size) / sizeof(int);
     for (int k = 0; k < array_length; k++) {
+ test_output_small.clear();
+ test_output_large.clear();
         segments_small.clear();
         segments_large.clear();
         int cur_sz = grid_size[k];
@@ -542,8 +548,8 @@
                 segments_small.insert(directed_line_segment_data<T>(point3_1, point4_1));
                 segments_large.insert(directed_line_segment_data<T>(point3_2, point4_2));
             }
- construct_voronoi_segments<T>(segments_small, test_output_small);
- construct_voronoi_segments<T>(segments_large, test_output_large);
+ construct_voronoi_segments(segments_small, &test_output_small);
+ construct_voronoi_segments(segments_large, &test_output_large);
         VERIFY_NO_HALF_EDGE_INTERSECTIONS(test_output_small);
         VERIFY_NO_HALF_EDGE_INTERSECTIONS(test_output_large);
         BOOST_CHECK_EQUAL(test_output_small.num_cell_records(), test_output_large.num_cell_records());
@@ -566,6 +572,7 @@
     points.push_back(point_data<T>(100, -100));
     points.push_back(point_data<T>(100, 100));
     for (int i = 0; i < num_runs; i++) {
+ test_output.clear();
         segments.clear();
         for (int j = 0; j < num_segments; j++) {
             T x1 = 0, y1 = 0, x2 = 0, y2 = 0;
@@ -580,7 +587,7 @@
             segments.insert(directed_line_segment_data<T>(point1, point2));
         }
         segments.clean();
- construct_voronoi<T>(points, segments, test_output);
+ construct_voronoi(points, segments, &test_output);
         VERIFY_NO_HALF_EDGE_INTERSECTIONS(test_output);
     }
 }
@@ -600,6 +607,8 @@
     for (int k = 0; k < array_length; k++) {
         int koef = std::numeric_limits<int>::max() / max_value[k];
         for (int i = 0; i < num_runs[k]; i++) {
+ test_output_small.clear();
+ test_output_large.clear();
             segments_small.clear();
             segments_large.clear();
             for (int j = 0; j < num_segments[k]; j++) {
@@ -627,8 +636,8 @@
                 point_data<T> point2_large(x2, y2);
                 segments_large.insert(directed_line_segment_data<T>(point1_large, point2_large));
             }
- construct_voronoi_segments<T>(segments_small, test_output_small);
- construct_voronoi_segments<T>(segments_large, test_output_large);
+ construct_voronoi_segments(segments_small, &test_output_small);
+ construct_voronoi_segments(segments_large, &test_output_large);
             VERIFY_NO_HALF_EDGE_INTERSECTIONS(test_output_small);
             VERIFY_NO_HALF_EDGE_INTERSECTIONS(test_output_large);
             BOOST_CHECK_EQUAL(test_output_small.num_cell_records(), test_output_large.num_cell_records());

Added: sandbox/gtl/libs/polygon/test/voronoi_ctypes_test.cpp
==============================================================================
--- (empty file)
+++ sandbox/gtl/libs/polygon/test/voronoi_ctypes_test.cpp 2012-01-23 18:19:31 EST (Mon, 23 Jan 2012)
@@ -0,0 +1,280 @@
+// Boost.Polygon library voronoi_ctypes_test.cpp file
+
+// Copyright Andrii Sydorchuk 2010-2012.
+// Distributed under the Boost Software License, Version 1.0.
+// (See accompanying file LICENSE_1_0.txt or copy at
+// http://www.boost.org/LICENSE_1_0.txt)
+
+// See http://www.boost.org for updates, documentation, and revision history.
+
+#include <ctime>
+
+#define BOOST_TEST_MODULE voronoi_ctypes_test
+#include <boost/mpl/list.hpp>
+#include <boost/random/mersenne_twister.hpp>
+#include <boost/test/test_case_template.hpp>
+
+#include "boost/polygon/detail/voronoi_ctypes.hpp"
+using namespace boost::polygon::detail;
+
+type_converter_fpt to_fpt;
+
+BOOST_AUTO_TEST_CASE(fpt_exponent_accessor_test) {
+ typedef fpt_exponent_accessor<fpt64> fpt_ea;
+ fpt64 value = 15;
+ BOOST_CHECK_EQUAL(fpt_ea::set_exponent(value, 0), 3);
+ BOOST_CHECK_EQUAL(value, 1.875);
+ value = 0.0625;
+ BOOST_CHECK_EQUAL(fpt_ea::set_exponent(value, 0), -4);
+ BOOST_CHECK_EQUAL(value, 1.0);
+ value = -1.5;
+ BOOST_CHECK_EQUAL(fpt_ea::set_exponent(value, 4), 0);
+ BOOST_CHECK_EQUAL(value, -24.0);
+ value = 0.0;
+ BOOST_CHECK_EQUAL(fpt_ea::set_exponent(value, 4), fpt_ea::kMinExponent);
+ BOOST_CHECK_EQUAL(value, 16.0);
+ value = std::pow(2.0, 2000);
+ BOOST_CHECK_EQUAL(fpt_ea::set_exponent(value, 4), fpt_ea::kMaxExponent);
+ BOOST_CHECK_EQUAL(value, 16.0);
+}
+
+BOOST_AUTO_TEST_CASE(extended_exponent_fpt_test1) {
+ boost::mt19937_64 gen(static_cast<uint32>(time(NULL)));
+ fpt64 b = 0.0;
+ efpt64 eeb(b);
+ for (int i = 0; i < 1000; ++i) {
+ fpt64 a = static_cast<fpt64>(static_cast<int64>(gen()));
+ efpt64 eea(a);
+ efpt64 neg = -eea;
+ efpt64 sum = eea + eeb;
+ efpt64 dif = eea - eeb;
+ efpt64 mul = eea * eeb;
+ BOOST_CHECK_EQUAL(to_fpt(neg), -a);
+ BOOST_CHECK_EQUAL(to_fpt(sum), a + b);
+ BOOST_CHECK_EQUAL(to_fpt(dif), a - b);
+ BOOST_CHECK_EQUAL(to_fpt(mul), a * b);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(extended_exponent_fpt_test2) {
+ boost::mt19937_64 gen(static_cast<uint32>(time(NULL)));
+ fpt64 a = 0.0;
+ efpt64 eea(a);
+ for (int i = 0; i < 1000; ++i) {
+ fpt64 b = static_cast<fpt64>(static_cast<int64>(gen()));
+ if (b == 0.0) {
+ continue;
+ }
+ efpt64 eeb(b);
+ efpt64 neg = -eea;
+ efpt64 sum = eea + eeb;
+ efpt64 dif = eea - eeb;
+ efpt64 mul = eea * eeb;
+ efpt64 div = eea / eeb;
+ BOOST_CHECK_EQUAL(to_fpt(neg), -a);
+ BOOST_CHECK_EQUAL(to_fpt(sum), a + b);
+ BOOST_CHECK_EQUAL(to_fpt(dif), a - b);
+ BOOST_CHECK_EQUAL(to_fpt(mul), a * b);
+ BOOST_CHECK_EQUAL(to_fpt(div), a / b);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(extended_exponent_fpt_test3) {
+ boost::mt19937_64 gen(static_cast<uint32>(time(NULL)));
+ for (int i = 0; i < 1000; ++i) {
+ fpt64 a = static_cast<fpt64>(static_cast<int64>(gen()));
+ fpt64 b = static_cast<fpt64>(static_cast<int64>(gen()));
+ if (b == 0.0) {
+ continue;
+ }
+ efpt64 eea(a);
+ efpt64 eeb(b);
+ efpt64 neg = -eea;
+ efpt64 sum = eea + eeb;
+ efpt64 dif = eea - eeb;
+ efpt64 mul = eea * eeb;
+ efpt64 div = eea / eeb;
+ BOOST_CHECK_EQUAL(to_fpt(neg), -a);
+ BOOST_CHECK_EQUAL(to_fpt(sum), a + b);
+ BOOST_CHECK_EQUAL(to_fpt(dif), a - b);
+ BOOST_CHECK_EQUAL(to_fpt(mul), a * b);
+ BOOST_CHECK_EQUAL(to_fpt(div), a / b);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(extended_exponent_fpt_test4) {
+ for (int exp = 0; exp < 64; ++exp)
+ for (int i = 1; i < 100; ++i) {
+ fpt64 a = i;
+ fpt64 b = static_cast<fpt64>(1LL << exp);
+ efpt64 eea(a);
+ efpt64 eeb(b);
+ efpt64 neg = -eea;
+ efpt64 sum = eea + eeb;
+ efpt64 dif = eea - eeb;
+ efpt64 mul = eea * eeb;
+ efpt64 div = eea / eeb;
+ BOOST_CHECK_EQUAL(to_fpt(neg), -a);
+ BOOST_CHECK_EQUAL(to_fpt(sum), a + b);
+ BOOST_CHECK_EQUAL(to_fpt(dif), a - b);
+ BOOST_CHECK_EQUAL(to_fpt(mul), a * b);
+ BOOST_CHECK_EQUAL(to_fpt(div), a / b);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(extended_exponent_fpt_test5) {
+ for (int i = 0; i < 100; ++i) {
+ efpt64 a(static_cast<fpt64>(i * i));
+ efpt64 b = a.sqrt();
+ BOOST_CHECK_EQUAL(to_fpt(b), static_cast<fpt64>(i));
+ }
+}
+
+BOOST_AUTO_TEST_CASE(extended_int_test1) {
+ typedef extended_int<1> eint32;
+ eint32 e1(0), e2(32), e3(-32);
+ BOOST_CHECK_EQUAL(e1.count(), 0);
+ BOOST_CHECK_EQUAL(e1.chunks()[0], 0u);
+ BOOST_CHECK_EQUAL(e1.size(), 0u);
+ BOOST_CHECK_EQUAL(e2.count(), 1);
+ BOOST_CHECK_EQUAL(e2.chunks()[0], 32u);
+ BOOST_CHECK_EQUAL(e2.size(), 1u);
+ BOOST_CHECK_EQUAL(e3.count(), -1);
+ BOOST_CHECK_EQUAL(e3.chunks()[0], 32u);
+ BOOST_CHECK_EQUAL(e3.size(), 1u);
+}
+
+BOOST_AUTO_TEST_CASE(extended_int_test2) {
+ typedef extended_int<2> eint64;
+ int64 val64 = 0x7fffffffffffffffLL;
+ eint64 e1(0LL), e2(32LL), e3(-32LL), e4(val64), e5(-val64);
+ BOOST_CHECK_EQUAL(e1.count(), 0);
+ BOOST_CHECK_EQUAL(e1.chunks()[0], 0u);
+ BOOST_CHECK_EQUAL(e2.count(), 1);
+ BOOST_CHECK_EQUAL(e2.chunks()[0], 32u);
+ BOOST_CHECK_EQUAL(e3.count(), -1);
+ BOOST_CHECK_EQUAL(e3.chunks()[0], 32u);
+ BOOST_CHECK_EQUAL(e4.count(), 2);
+ BOOST_CHECK_EQUAL(e4.chunks()[0], 0xffffffff);
+ BOOST_CHECK_EQUAL(e4.chunks()[1], val64 >> 32);
+ BOOST_CHECK_EQUAL(e5.count(), -2);
+ BOOST_CHECK_EQUAL(e5.chunks()[0], 0xffffffff);
+ BOOST_CHECK_EQUAL(e5.chunks()[1], val64 >> 32);
+}
+
+BOOST_AUTO_TEST_CASE(extended_int_test3) {
+ typedef extended_int<2> eint64;
+ std::vector<uint32> chunks;
+ chunks.push_back(1);
+ chunks.push_back(2);
+ eint64 e1(chunks, true), e2(chunks, false);
+ BOOST_CHECK_EQUAL(e1.count(), 2);
+ BOOST_CHECK_EQUAL(e1.chunks()[0], 2u);
+ BOOST_CHECK_EQUAL(e1.chunks()[1], 1u);
+ BOOST_CHECK_EQUAL(e2.count(), -2);
+ BOOST_CHECK_EQUAL(e2.chunks()[0], 2u);
+ BOOST_CHECK_EQUAL(e2.chunks()[1], 1u);
+}
+
+BOOST_AUTO_TEST_CASE(extended_int_test4) {
+ typedef extended_int<2> eint64;
+ std::vector<uint32> chunks;
+ chunks.push_back(1);
+ chunks.push_back(2);
+ eint64 e1(chunks, true), e2(chunks, false);
+ BOOST_CHECK_EQUAL(e1 == e2, false);
+ BOOST_CHECK_EQUAL(e1 == -e2, true);
+ BOOST_CHECK_EQUAL(e1 != e2, true);
+ BOOST_CHECK_EQUAL(e1 != -e2, false);
+ BOOST_CHECK_EQUAL(e1 < e2, false);
+ BOOST_CHECK_EQUAL(e1 < -e2, false);
+ BOOST_CHECK_EQUAL(e1 <= e2, false);
+ BOOST_CHECK_EQUAL(e1 <= -e2, true);
+ BOOST_CHECK_EQUAL(e1 > e2, true);
+ BOOST_CHECK_EQUAL(e1 > -e2, false);
+ BOOST_CHECK_EQUAL(e1 >= e2, true);
+ BOOST_CHECK_EQUAL(e1 >= -e2, true);
+}
+
+BOOST_AUTO_TEST_CASE(extended_int_test5) {
+ typedef extended_int<2> eint64;
+ boost::mt19937_64 gen(static_cast<uint32>(time(NULL)));
+ for (int i = 0; i < 100; ++i) {
+ int64 i1 = static_cast<int64>(gen());
+ int64 i2 = static_cast<int64>(gen());
+ eint64 e1(i1), e2(i2);
+ BOOST_CHECK_EQUAL(e1 == e2, i1 == i2);
+ BOOST_CHECK_EQUAL(e1 != e2, i1 != i2);
+ BOOST_CHECK_EQUAL(e1 > e2, i1 > i2);
+ BOOST_CHECK_EQUAL(e1 >= e2, i1 >= i2);
+ BOOST_CHECK_EQUAL(e1 < e2, i1 < i2);
+ BOOST_CHECK_EQUAL(e1 <= e2, i1 <= i2);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(extended_int_test6) {
+ typedef extended_int<1> eint32;
+ eint32 e1(32);
+ eint32 e2 = -e1;
+ BOOST_CHECK_EQUAL(e2.count(), -1);
+ BOOST_CHECK_EQUAL(e2.size(), 1u);
+ BOOST_CHECK_EQUAL(e2.chunks()[0], 32u);
+}
+
+BOOST_AUTO_TEST_CASE(extended_int_test7) {
+ typedef extended_int<2> eint64;
+ boost::mt19937_64 gen(static_cast<uint32>(time(NULL)));
+ for (int i = 0; i < 100; ++i) {
+ int64 i1 = static_cast<int64>(gen()) >> 2;
+ int64 i2 = static_cast<int64>(gen()) >> 2;
+ eint64 e1(i1), e2(i2), e3(i1 + i2), e4(i1 - i2);
+ BOOST_CHECK(e1 + e2 == e3);
+ BOOST_CHECK(e1 - e2 == e4);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(extended_int_test8) {
+ typedef extended_int<2> eint64;
+ boost::mt19937 gen(static_cast<uint32>(time(NULL)));
+ for (int i = 0; i < 100; ++i) {
+ int64 i1 = static_cast<int32>(gen());
+ int64 i2 = static_cast<int32>(gen());
+ eint64 e1(i1), e2(i2), e3(i1 * i2);
+ BOOST_CHECK(e1 * e2 == e3);
+ }
+}
+
+BOOST_AUTO_TEST_CASE(exnteded_int_test9) {
+ typedef extended_int<1> eint32;
+ for (int i = -10; i <= 10; ++i) {
+ for (int j = -10; j <= 10; ++j) {
+ eint32 e1(i), e2(j), e3(i+j), e4(i-j), e5(i*j);
+ BOOST_CHECK(e1 + e2 == e3);
+ BOOST_CHECK(e1 - e2 == e4);
+ BOOST_CHECK(e1 * e2 == e5);
+ }
+ }
+}
+
+BOOST_AUTO_TEST_CASE(extended_int_test10) {
+ typedef extended_int<2> eint64;
+ boost::mt19937_64 gen(static_cast<uint32>(time(NULL)));
+ for (int i = 0; i < 100; ++i) {
+ int64 i1 = static_cast<int64>(gen()) >> 20;
+ int64 i2 = i1 >> 32;
+ eint64 e1(i1), e2(i2);
+ BOOST_CHECK(to_fpt(e1) == static_cast<fpt64>(i1));
+ BOOST_CHECK(to_fpt(e2) == static_cast<fpt64>(i2));
+ }
+}
+
+BOOST_AUTO_TEST_CASE(extened_int_test11) {
+ typedef extended_int<1> eint32;
+ typedef extended_int<64> eint2048;
+ eint32 two(2), one(1);
+ eint2048 value(1);
+ for (int i = 0; i < 1024; ++i) {
+ value = value * two;
+ }
+ BOOST_CHECK_EQUAL(value.count(), 33);
+}

Modified: sandbox/gtl/libs/polygon/test/voronoi_predicates_test.cpp
==============================================================================
--- sandbox/gtl/libs/polygon/test/voronoi_predicates_test.cpp (original)
+++ sandbox/gtl/libs/polygon/test/voronoi_predicates_test.cpp 2012-01-23 18:19:31 EST (Mon, 23 Jan 2012)
@@ -1,6 +1,6 @@
 // Boost.Polygon library voronoi_predicates_test.cpp file
 
-// Copyright Andrii Sydorchuk 2010-2011.
+// Copyright Andrii Sydorchuk 2010-2012.
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
@@ -12,13 +12,14 @@
 #define BOOST_TEST_MODULE voronoi_predicates_test
 #include <boost/test/test_case_template.hpp>
 
+#include "boost/polygon/detail/voronoi_ctypes.hpp"
 #include "boost/polygon/detail/voronoi_predicates.hpp"
 #include "boost/polygon/detail/voronoi_structures.hpp"
 using namespace boost::polygon::detail;
 
 ulp_comparison<double> ulp_cmp;
 
-typedef voronoi_predicates<int> VP;
+typedef voronoi_predicates< voronoi_ctype_traits<int> > VP;
 typedef point_2d<int> point_type;
 typedef site_event<int> site_type;
 typedef circle_event<double> circle_type;

Modified: sandbox/gtl/libs/polygon/test/voronoi_robust_fpt_test.cpp
==============================================================================
--- sandbox/gtl/libs/polygon/test/voronoi_robust_fpt_test.cpp (original)
+++ sandbox/gtl/libs/polygon/test/voronoi_robust_fpt_test.cpp 2012-01-23 18:19:31 EST (Mon, 23 Jan 2012)
@@ -1,6 +1,6 @@
 // Boost.Polygon library voronoi_robust_fpt_test.cpp file
 
-// Copyright Andrii Sydorchuk 2010-2011.
+// Copyright Andrii Sydorchuk 2010-2012.
 // Distributed under the Boost Software License, Version 1.0.
 // (See accompanying file LICENSE_1_0.txt or copy at
 // http://www.boost.org/LICENSE_1_0.txt)
@@ -9,13 +9,13 @@
 
 #include <cmath>
 #include <ctime>
-#include <vector>
 
 #define BOOST_TEST_MODULE voronoi_robust_fpt_test
 #include <boost/mpl/list.hpp>
 #include <boost/random/mersenne_twister.hpp>
 #include <boost/test/test_case_template.hpp>
 
+#include "boost/polygon/detail/voronoi_ctypes.hpp"
 #include "boost/polygon/detail/voronoi_robust_fpt.hpp"
 using namespace boost::polygon::detail;
 
@@ -227,254 +227,6 @@
     BOOST_CHECK_EQUAL(c4[3].dif() / b4[3].dif(), a4[3].dif());
 }
 
-BOOST_AUTO_TEST_CASE(fpt_exponent_accessor_test) {
- typedef fpt_exponent_accessor<fpt64> fpt_ea;
- fpt64 value = 15;
- BOOST_CHECK_EQUAL(fpt_ea::set_exponent(value, 0), 3);
- BOOST_CHECK_EQUAL(value, 1.875);
- value = 0.0625;
- BOOST_CHECK_EQUAL(fpt_ea::set_exponent(value, 0), -4);
- BOOST_CHECK_EQUAL(value, 1.0);
- value = -1.5;
- BOOST_CHECK_EQUAL(fpt_ea::set_exponent(value, 4), 0);
- BOOST_CHECK_EQUAL(value, -24.0);
- value = 0.0;
- BOOST_CHECK_EQUAL(fpt_ea::set_exponent(value, 4), fpt_ea::kMinExponent);
- BOOST_CHECK_EQUAL(value, 16.0);
- value = std::pow(2.0, 2000);
- BOOST_CHECK_EQUAL(fpt_ea::set_exponent(value, 4), fpt_ea::kMaxExponent);
- BOOST_CHECK_EQUAL(value, 16.0);
-}
-
-BOOST_AUTO_TEST_CASE(extended_exponent_fpt_test1) {
- boost::mt19937_64 gen(static_cast<uint32>(time(NULL)));
- fpt64 b = 0.0;
- efpt64 eeb(b);
- for (int i = 0; i < 1000; ++i) {
- fpt64 a = static_cast<fpt64>(static_cast<int64>(gen()));
- efpt64 eea(a);
- efpt64 neg = -eea;
- efpt64 sum = eea + eeb;
- efpt64 dif = eea - eeb;
- efpt64 mul = eea * eeb;
- BOOST_CHECK_EQUAL(to_fpt(neg), -a);
- BOOST_CHECK_EQUAL(to_fpt(sum), a + b);
- BOOST_CHECK_EQUAL(to_fpt(dif), a - b);
- BOOST_CHECK_EQUAL(to_fpt(mul), a * b);
- }
-}
-
-BOOST_AUTO_TEST_CASE(extended_exponent_fpt_test2) {
- boost::mt19937_64 gen(static_cast<uint32>(time(NULL)));
- fpt64 a = 0.0;
- efpt64 eea(a);
- for (int i = 0; i < 1000; ++i) {
- fpt64 b = static_cast<fpt64>(static_cast<int64>(gen()));
- if (b == 0.0) {
- continue;
- }
- efpt64 eeb(b);
- efpt64 neg = -eea;
- efpt64 sum = eea + eeb;
- efpt64 dif = eea - eeb;
- efpt64 mul = eea * eeb;
- efpt64 div = eea / eeb;
- BOOST_CHECK_EQUAL(to_fpt(neg), -a);
- BOOST_CHECK_EQUAL(to_fpt(sum), a + b);
- BOOST_CHECK_EQUAL(to_fpt(dif), a - b);
- BOOST_CHECK_EQUAL(to_fpt(mul), a * b);
- BOOST_CHECK_EQUAL(to_fpt(div), a / b);
- }
-}
-
-BOOST_AUTO_TEST_CASE(extended_exponent_fpt_test3) {
- boost::mt19937_64 gen(static_cast<uint32>(time(NULL)));
- for (int i = 0; i < 1000; ++i) {
- fpt64 a = static_cast<fpt64>(static_cast<int64>(gen()));
- fpt64 b = static_cast<fpt64>(static_cast<int64>(gen()));
- if (b == 0.0) {
- continue;
- }
- efpt64 eea(a);
- efpt64 eeb(b);
- efpt64 neg = -eea;
- efpt64 sum = eea + eeb;
- efpt64 dif = eea - eeb;
- efpt64 mul = eea * eeb;
- efpt64 div = eea / eeb;
- BOOST_CHECK_EQUAL(to_fpt(neg), -a);
- BOOST_CHECK_EQUAL(to_fpt(sum), a + b);
- BOOST_CHECK_EQUAL(to_fpt(dif), a - b);
- BOOST_CHECK_EQUAL(to_fpt(mul), a * b);
- BOOST_CHECK_EQUAL(to_fpt(div), a / b);
- }
-}
-
-BOOST_AUTO_TEST_CASE(extended_exponent_fpt_test4) {
- for (int exp = 0; exp < 64; ++exp)
- for (int i = 1; i < 100; ++i) {
- fpt64 a = i;
- fpt64 b = static_cast<fpt64>(1LL << exp);
- efpt64 eea(a);
- efpt64 eeb(b);
- efpt64 neg = -eea;
- efpt64 sum = eea + eeb;
- efpt64 dif = eea - eeb;
- efpt64 mul = eea * eeb;
- efpt64 div = eea / eeb;
- BOOST_CHECK_EQUAL(to_fpt(neg), -a);
- BOOST_CHECK_EQUAL(to_fpt(sum), a + b);
- BOOST_CHECK_EQUAL(to_fpt(dif), a - b);
- BOOST_CHECK_EQUAL(to_fpt(mul), a * b);
- BOOST_CHECK_EQUAL(to_fpt(div), a / b);
- }
-}
-
-BOOST_AUTO_TEST_CASE(extended_exponent_fpt_test5) {
- for (int i = 0; i < 100; ++i) {
- efpt64 a(static_cast<fpt64>(i * i));
- efpt64 b = a.sqrt();
- BOOST_CHECK_EQUAL(to_fpt(b), static_cast<fpt64>(i));
- }
-}
-
-BOOST_AUTO_TEST_CASE(extended_int_test1) {
- eint32 e1(0), e2(32), e3(-32);
- BOOST_CHECK_EQUAL(e1.count(), 0);
- BOOST_CHECK_EQUAL(e1.chunks()[0], 0u);
- BOOST_CHECK_EQUAL(e1.size(), 0u);
- BOOST_CHECK_EQUAL(e2.count(), 1);
- BOOST_CHECK_EQUAL(e2.chunks()[0], 32u);
- BOOST_CHECK_EQUAL(e2.size(), 1u);
- BOOST_CHECK_EQUAL(e3.count(), -1);
- BOOST_CHECK_EQUAL(e3.chunks()[0], 32u);
- BOOST_CHECK_EQUAL(e3.size(), 1u);
-}
-
-BOOST_AUTO_TEST_CASE(extended_int_test2) {
- int64 val64 = 0x7fffffffffffffffLL;
- eint64 e1(0LL), e2(32LL), e3(-32LL), e4(val64), e5(-val64);
- BOOST_CHECK_EQUAL(e1.count(), 0);
- BOOST_CHECK_EQUAL(e1.chunks()[0], 0u);
- BOOST_CHECK_EQUAL(e2.count(), 1);
- BOOST_CHECK_EQUAL(e2.chunks()[0], 32u);
- BOOST_CHECK_EQUAL(e3.count(), -1);
- BOOST_CHECK_EQUAL(e3.chunks()[0], 32u);
- BOOST_CHECK_EQUAL(e4.count(), 2);
- BOOST_CHECK_EQUAL(e4.chunks()[0], 0xffffffff);
- BOOST_CHECK_EQUAL(e4.chunks()[1], val64 >> 32);
- BOOST_CHECK_EQUAL(e5.count(), -2);
- BOOST_CHECK_EQUAL(e5.chunks()[0], 0xffffffff);
- BOOST_CHECK_EQUAL(e5.chunks()[1], val64 >> 32);
-}
-
-BOOST_AUTO_TEST_CASE(extended_int_test3) {
- std::vector<uint32> chunks;
- chunks.push_back(1);
- chunks.push_back(2);
- eint64 e1(chunks, true), e2(chunks, false);
- BOOST_CHECK_EQUAL(e1.count(), 2);
- BOOST_CHECK_EQUAL(e1.chunks()[0], 2u);
- BOOST_CHECK_EQUAL(e1.chunks()[1], 1u);
- BOOST_CHECK_EQUAL(e2.count(), -2);
- BOOST_CHECK_EQUAL(e2.chunks()[0], 2u);
- BOOST_CHECK_EQUAL(e2.chunks()[1], 1u);
-}
-
-BOOST_AUTO_TEST_CASE(extended_int_test4) {
- std::vector<uint32> chunks;
- chunks.push_back(1);
- chunks.push_back(2);
- eint64 e1(chunks, true), e2(chunks, false);
- BOOST_CHECK_EQUAL(e1 == e2, false);
- BOOST_CHECK_EQUAL(e1 == -e2, true);
- BOOST_CHECK_EQUAL(e1 != e2, true);
- BOOST_CHECK_EQUAL(e1 != -e2, false);
- BOOST_CHECK_EQUAL(e1 < e2, false);
- BOOST_CHECK_EQUAL(e1 < -e2, false);
- BOOST_CHECK_EQUAL(e1 <= e2, false);
- BOOST_CHECK_EQUAL(e1 <= -e2, true);
- BOOST_CHECK_EQUAL(e1 > e2, true);
- BOOST_CHECK_EQUAL(e1 > -e2, false);
- BOOST_CHECK_EQUAL(e1 >= e2, true);
- BOOST_CHECK_EQUAL(e1 >= -e2, true);
-}
-
-BOOST_AUTO_TEST_CASE(extended_int_test5) {
- boost::mt19937_64 gen(static_cast<uint32>(time(NULL)));
- for (int i = 0; i < 100; ++i) {
- int64 i1 = static_cast<int64>(gen());
- int64 i2 = static_cast<int64>(gen());
- eint64 e1(i1), e2(i2);
- BOOST_CHECK_EQUAL(e1 == e2, i1 == i2);
- BOOST_CHECK_EQUAL(e1 != e2, i1 != i2);
- BOOST_CHECK_EQUAL(e1 > e2, i1 > i2);
- BOOST_CHECK_EQUAL(e1 >= e2, i1 >= i2);
- BOOST_CHECK_EQUAL(e1 < e2, i1 < i2);
- BOOST_CHECK_EQUAL(e1 <= e2, i1 <= i2);
- }
-}
-
-BOOST_AUTO_TEST_CASE(extended_int_test6) {
- eint32 e1(32);
- eint32 e2 = -e1;
- BOOST_CHECK_EQUAL(e2.count(), -1);
- BOOST_CHECK_EQUAL(e2.size(), 1u);
- BOOST_CHECK_EQUAL(e2.chunks()[0], 32u);
-}
-
-BOOST_AUTO_TEST_CASE(extended_int_test7) {
- boost::mt19937_64 gen(static_cast<uint32>(time(NULL)));
- for (int i = 0; i < 100; ++i) {
- int64 i1 = static_cast<int64>(gen()) >> 2;
- int64 i2 = static_cast<int64>(gen()) >> 2;
- eint64 e1(i1), e2(i2), e3(i1 + i2), e4(i1 - i2);
- BOOST_CHECK(e1 + e2 == e3);
- BOOST_CHECK(e1 - e2 == e4);
- }
-}
-
-BOOST_AUTO_TEST_CASE(extended_int_test8) {
- boost::mt19937 gen(static_cast<uint32>(time(NULL)));
- for (int i = 0; i < 100; ++i) {
- int64 i1 = static_cast<int32>(gen());
- int64 i2 = static_cast<int32>(gen());
- eint64 e1(i1), e2(i2), e3(i1 * i2);
- BOOST_CHECK(e1 * e2 == e3);
- }
-}
-
-BOOST_AUTO_TEST_CASE(exnteded_int_test9) {
- for (int i = -10; i <= 10; ++i) {
- for (int j = -10; j <= 10; ++j) {
- eint32 e1(i), e2(j), e3(i+j), e4(i-j), e5(i*j);
- BOOST_CHECK(e1 + e2 == e3);
- BOOST_CHECK(e1 - e2 == e4);
- BOOST_CHECK(e1 * e2 == e5);
- }
- }
-}
-
-BOOST_AUTO_TEST_CASE(extended_int_test10) {
- boost::mt19937_64 gen(static_cast<uint32>(time(NULL)));
- for (int i = 0; i < 100; ++i) {
- int64 i1 = static_cast<int64>(gen()) >> 20;
- int64 i2 = i1 >> 32;
- eint64 e1(i1), e2(i2);
- BOOST_CHECK(to_fpt(e1) == static_cast<fpt64>(i1));
- BOOST_CHECK(to_fpt(e2) == static_cast<fpt64>(i2));
- }
-}
-
-BOOST_AUTO_TEST_CASE(extened_int_test11) {
- eint32 two(2), one(1);
- eint2048 value(1);
- for (int i = 0; i < 1024; ++i) {
- value = value * two;
- }
- BOOST_CHECK_EQUAL(value.count(), 33);
-}
-
 BOOST_AUTO_TEST_CASE(robust_sqrt_expr_test1) {
     robust_sqrt_expr<int32, fpt64, to_fpt_type> sqrt_expr;
     int32 A[1] = {10};
@@ -525,6 +277,7 @@
 }
 
 BOOST_AUTO_TEST_CASE(robust_sqrt_expr_test8) {
+ typedef extended_int<16> eint512;
     robust_sqrt_expr<eint512, efpt64, to_efpt_type> sqrt_expr;
     int32 A[4] = {1000, 3000, -2000, -500};
     int32 B[4] = {400, 100, 900, 1600};
@@ -582,6 +335,7 @@
 };
 
 BOOST_AUTO_TEST_CASE(mpz_sqrt_evaluator_test) {
+ typedef extended_int<32> eint1024;
     sqrt_expr_tester<eint1024, efpt64> tester;
     for (int i = 0; i < 2000; ++i) {
         BOOST_CHECK(tester.run());


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk