diff options
author | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-07-12 14:16:39 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <tmpsantos@gmail.com> | 2017-07-12 15:13:33 +0300 |
commit | 32bef80eec204c22a2b37bb6534bc02d24fa68c7 (patch) | |
tree | 261676e1df324a39b105ba2ead6e680c8bee32fb /test | |
parent | 06719ae42f10d4152780b75173e32fb6f4bb7633 (diff) | |
download | qtlocation-mapboxgl-32bef80eec204c22a2b37bb6534bc02d24fa68c7.tar.gz |
[test] Add utest to assert our dtoa implementation precision
Diffstat (limited to 'test')
-rw-r--r-- | test/util/dtoa.test.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/util/dtoa.test.cpp b/test/util/dtoa.test.cpp new file mode 100644 index 0000000000..8d2fba1877 --- /dev/null +++ b/test/util/dtoa.test.cpp @@ -0,0 +1,24 @@ +#include <mbgl/test/util.hpp> + +#include <mbgl/util/dtoa.hpp> + +#include <cfloat> +#include <cmath> + +using namespace mbgl; + +TEST(Dtoa, Precision) { + EXPECT_EQ(M_E, std::stod(util::dtoa(M_E))); + EXPECT_EQ(M_LOG2E, std::stod(util::dtoa(M_LOG2E))); + EXPECT_EQ(M_LOG10E, std::stod(util::dtoa(M_LOG10E))); + EXPECT_EQ(M_LN2, std::stod(util::dtoa(M_LN2))); + EXPECT_EQ(M_LN10, std::stod(util::dtoa(M_LN10))); + EXPECT_EQ(M_PI, std::stod(util::dtoa(M_PI))); + EXPECT_EQ(M_PI_2, std::stod(util::dtoa(M_PI_2))); + EXPECT_EQ(M_PI_4, std::stod(util::dtoa(M_PI_4))); + EXPECT_EQ(M_1_PI, std::stod(util::dtoa(M_1_PI))); + EXPECT_EQ(M_2_PI, std::stod(util::dtoa(M_2_PI))); + EXPECT_EQ(M_2_SQRTPI, std::stod(util::dtoa(M_2_SQRTPI))); + EXPECT_EQ(M_SQRT2, std::stod(util::dtoa(M_SQRT2))); + EXPECT_EQ(M_SQRT1_2, std::stod(util::dtoa(M_SQRT1_2))); +} |