Line | Branch | Decision | Exec | Source |
---|---|---|---|---|
1 | #include "pch.h" | |||
2 | ||||
3 | #include "linear_func.h" | |||
4 | ||||
5 | class LinearFuncTest : public ::testing::Test { | |||
6 | protected: | |||
7 | // Maps (1, 4) -> (100, -100) | |||
8 | LinearFunc dut; | |||
9 | ||||
10 | 2 | void SetUp() override { | ||
11 | 2 | dut.configure(1, 100, 4, -100, -110, 110); | ||
12 | 2 | } | ||
13 | }; | |||
14 | ||||
15 | #define test_point(in, out) \ | |||
16 | { \ | |||
17 | auto result = dut.convert(in); \ | |||
18 | \ | |||
19 | EXPECT_TRUE(result.Valid); \ | |||
20 | ASSERT_NEAR(result.Value, (out), EPS4D) << "Not " << out << " for " << in; \ | |||
21 | } | |||
22 | ||||
23 | #define test_point_invalid(in) \ | |||
24 | { EXPECT_FALSE(dut.convert(in).Valid); } | |||
25 | ||||
26 | 4 | TEST_F(LinearFuncTest, TestInRange) { | ||
27 |
5/19✓ Branch 2 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
✗ Branch 11 not taken.
✗ Branch 16 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✓ Branch 34 taken 1 time.
✗ Branch 37 not taken.
✓ Branch 38 taken 1 time.
✗ Branch 41 not taken.
✗ Branch 44 not taken.
✗ Branch 48 not taken.
✗ Branch 51 not taken.
✗ Branch 55 not taken.
✗ Branch 60 not taken.
✗ Branch 63 not taken.
✓ Branch 72 taken 1 time.
✗ Branch 73 not taken.
|
2 | test_point(2.5, 0); | |
28 |
5/19✓ Branch 2 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
✗ Branch 11 not taken.
✗ Branch 16 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✓ Branch 34 taken 1 time.
✗ Branch 37 not taken.
✓ Branch 38 taken 1 time.
✗ Branch 41 not taken.
✗ Branch 44 not taken.
✗ Branch 48 not taken.
✗ Branch 51 not taken.
✗ Branch 55 not taken.
✗ Branch 60 not taken.
✗ Branch 63 not taken.
✓ Branch 72 taken 1 time.
✗ Branch 73 not taken.
|
2 | test_point(1, 100); | |
29 |
5/19✓ Branch 2 taken 1 time.
✗ Branch 7 not taken.
✓ Branch 8 taken 1 time.
✗ Branch 11 not taken.
✗ Branch 16 not taken.
✗ Branch 20 not taken.
✗ Branch 23 not taken.
✓ Branch 34 taken 1 time.
✗ Branch 37 not taken.
✓ Branch 38 taken 1 time.
✗ Branch 41 not taken.
✗ Branch 44 not taken.
✗ Branch 48 not taken.
✗ Branch 51 not taken.
✗ Branch 55 not taken.
✗ Branch 60 not taken.
✗ Branch 63 not taken.
✓ Branch 72 taken 1 time.
✗ Branch 73 not taken.
|
2 | test_point(4, -100); | |
30 | } | |||
31 | ||||
32 | TEST_F(LinearFuncTest, TestOutOfRange) { | |||
33 | test_point(1, 100); | |||
34 | test_point_invalid(0.5); | |||
35 | ||||
36 | test_point(4, -100); | |||
37 | test_point_invalid(4.5); | |||
38 | } | |||
39 |