mirror of
https://github.com/ddnet/ddnet.git
synced 2024-10-20 07:48:18 +00:00
15 lines
262 B
C++
15 lines
262 B
C++
|
#include "test.h"
|
||
|
#include <gtest/gtest.h>
|
||
|
|
||
|
#include <base/math.h>
|
||
|
|
||
|
TEST(Math, FixedPointRoundtrip)
|
||
|
{
|
||
|
for(int i = 0; i < 100000; ++i)
|
||
|
{
|
||
|
const float Number = i / 1000.0f;
|
||
|
EXPECT_NEAR(Number, fx2f(f2fx(Number)), 0.0005f);
|
||
|
EXPECT_EQ(i, f2fx(fx2f(i)));
|
||
|
}
|
||
|
}
|