diff options
author | Alex Zolotarev <deathbaba@gmail.com> | 2011-04-06 19:10:06 +0400 |
---|---|---|
committer | Alex Zolotarev <alex@maps.me> | 2015-09-23 01:15:18 +0300 |
commit | a8ab31109383c531447fd72486413dbc6db070d8 (patch) | |
tree | 068f6da8c58ee32f412d89295fb7046a4d69b9f5 /yg | |
parent | 6bb117ebfd004af71c6005855bd577ddb928e6b1 (diff) |
@TODO failed unit test in yg
Diffstat (limited to 'yg')
-rw-r--r-- | yg/shape_renderer.hpp | 2 | ||||
-rw-r--r-- | yg/yg_tests/shape_renderer_test.cpp | 50 | ||||
-rw-r--r-- | yg/yg_tests/yg_tests.pro | 3 |
3 files changed, 53 insertions, 2 deletions
diff --git a/yg/shape_renderer.hpp b/yg/shape_renderer.hpp index 9770e20fbc..49aaaca5cd 100644 --- a/yg/shape_renderer.hpp +++ b/yg/shape_renderer.hpp @@ -14,7 +14,7 @@ namespace yg ShapeRenderer(base_t::Params const & params); - void approximateArc(m2::PointF const & center, double startA, double endA, double r, vector<m2::PointF> & pts); + static void approximateArc(m2::PointF const & center, double startA, double endA, double r, vector<m2::PointF> & pts); void drawArc(m2::PointD const & center, double startA, double endA, double r, yg::Color const & c, double depth); void drawSector(m2::PointD const & center, double startA, double endA, double r, yg::Color const & c, double depth); void fillSector(m2::PointD const & center, double startA, double endA, double r, yg::Color const & c, double depth); diff --git a/yg/yg_tests/shape_renderer_test.cpp b/yg/yg_tests/shape_renderer_test.cpp new file mode 100644 index 0000000000..e926d72323 --- /dev/null +++ b/yg/yg_tests/shape_renderer_test.cpp @@ -0,0 +1,50 @@ +#include "../../testing/testing.hpp" +#include "../shape_renderer.hpp" +#include "../../base/math.hpp" + +using namespace yg::gl; + +namespace +{ + void TestPoints(m2::PointF const & center, float r, vector<m2::PointF> const & points) + { + for (size_t i = 0; i < points.size(); ++i) + { + TEST_LESS(fabs(center.Length(points[i]) - r), 0.0001, ()); + /* + TEST(my::AlmostEqual(center.Length(points[i]), static_cast<double>(r), 1024), + (center.Length(points[i]), r)); + */ + } + } +} + +UNIT_TEST(ApproximateArc_Smoke) +{ + m2::PointF const center(1, 2); + float r = 10; + vector<m2::PointF> points; + ShapeRenderer::approximateArc(center, 0, math::pi / 4, r, points); + TestPoints(center, r, points); +} + +UNIT_TEST(ApproximateArc_Crash) +{ + // this test gives only two result points on the device, + // and the second one is NAN inside ShapeRenderer::fillSector() + m2::PointD const center(511.7547811565455, 511.84095156751573); + double const startA = -1.5707963267948966; + double const endA = -1.6057029118347832; + double const r = 127.99998027132824; + vector<m2::PointF> points; + ShapeRenderer::approximateArc(center, startA, endA, r, points); + TestPoints(center, r, points); +} + +UNIT_TEST(ApproximateArc_TooManyPoints) +{ + m2::PointD const center(10, 10); + double const startA = 10; + double const endA = 0.1; + double const r = 10; +} diff --git a/yg/yg_tests/yg_tests.pro b/yg/yg_tests/yg_tests.pro index f5764a83fe..289c3c9758 100644 --- a/yg/yg_tests/yg_tests.pro +++ b/yg/yg_tests/yg_tests.pro @@ -24,4 +24,5 @@ SOURCES += \ thread_render.cpp \ opengl_test.cpp \ screenglglobal_test.cpp \ - glyph_cache_test.cpp + glyph_cache_test.cpp \ + shape_renderer_test.cpp \ |