Skip to content

Commit e59f926

Browse files
committed
Fix bad c/p, actually try round with ints
1 parent 6db24f8 commit e59f926

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

tests/device/test_sw_arduino_math_overrides/test_sw_arduino_math_overrides.ino

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ TEST_CASE("abs works with ints", "[arduino-math]")
4646
CHECK(abs(b) == b);
4747
}
4848

49-
bool compare_floats(float a, float b) {
49+
template <typename T>
50+
bool compare_floats(T a, T b) {
51+
static_assert(std::is_floating_point<T>::value, "");
5052
return std::fabs(a - b) < std::numeric_limits<float>::epsilon();
5153
}
5254

@@ -60,17 +62,17 @@ TEST_CASE("abs works with floats", "[arduino-math]")
6062
CHECK(compare_floats(abs(b), b));
6163
}
6264

63-
TEST_CASE("round works with floats", "[arduino-math]")
65+
TEST_CASE("round works with ints", "[arduino-math]")
6466
{
65-
float a = 2.9;
66-
float b = 3.0;
67-
CHECK(TEST_MATH_IS_SAME(round(a), a));
68-
CHECK(TEST_MATH_IS_SAME(round(b), b));
69-
CHECK(compare_floats(round(a), b));
70-
CHECK(compare_floats(round(b), b));
67+
int a = 5;
68+
int b = 10;
69+
CHECK(TEST_MATH_IS_SAME(round(a), std::round(a)));
70+
CHECK(TEST_MATH_IS_SAME(round(b), std::round(b)));
71+
CHECK(compare_floats(round(a), std::round(a)));
72+
CHECK(compare_floats(round(b), std::round(b)));
7173
}
7274

73-
TEST_CASE("round result is float", "[arduino-math]")
75+
TEST_CASE("round works with floats", "[arduino-math]")
7476
{
7577
float a = 2.9;
7678
float b = 3.0;

0 commit comments

Comments
 (0)