| 1 | #include "test.h" |
|---|---|
| 2 | |
| 3 | #include <base/math.h> |
| 4 | |
| 5 | #include <gtest/gtest.h> |
| 6 | |
| 7 | TEST(Math, FixedPointRoundtrip) |
| 8 | { |
| 9 | for(int i = 0; i < 100000; ++i) |
| 10 | { |
| 11 | const float Number = i / 1000.0f; |
| 12 | EXPECT_NEAR(Number, fx2f(f2fx(Number)), 0.0005f); |
| 13 | EXPECT_EQ(i, f2fx(fx2f(i))); |
| 14 | } |
| 15 | } |
| 16 |