blob: b3d3e7897faee577f9394409266ba84fb37ffc5e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
#include <catch2/catch_test_macros.hpp>
#include "fixed_point.h"
TEST_CASE("fp_t addition is commutative") {
fp_t a = fp_t::from_int(1);
fp_t b = fp_t::from_int(2);
CHECK(a + b == b + a);
REQUIRE(a.raw != 0);
}
TEST_CASE("fp_t addition overflows") {
fp_t a = fp_t::from_raw(INT32_MAX);
fp_t b = fp_t::from_raw(1);
fp_t c = fp_t::from_raw(INT32_MIN);
CHECK(a + b == c);
}
|