MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / TEST

Function TEST

libraries/AP_Math/tests/test_vector2.cpp:7–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

5const AP_HAL::HAL& hal = AP_HAL::get_HAL();
6
7TEST(Vector2Test, Operator)
8{
9 Vector2f v_float0{1.0f, 1.0f};
10 EXPECT_FALSE(v_float0.is_zero());
11 v_float0 = Vector2f();
12 EXPECT_TRUE(v_float0.is_zero());
13 v_float0[1] = 1.0f;
14 EXPECT_FALSE(v_float0.is_zero());
15 const float testf1 = v_float0[1];
16 EXPECT_TRUE(is_equal(testf1, 1.0f));
17 v_float0.zero();
18 EXPECT_TRUE(v_float0.is_zero());
19
20 Vector2i v_inti1{1, 1};
21 EXPECT_FALSE(v_inti1.is_zero());
22 v_inti1 = Vector2i();
23 EXPECT_TRUE(v_inti1.is_zero());
24 v_inti1[0] = 1;
25 EXPECT_FALSE(v_inti1.is_zero());
26 const int16_t testi1 = v_inti1[0];
27 EXPECT_TRUE(1 == testi1);
28 v_inti1.zero();
29 EXPECT_TRUE(v_inti1.is_zero());
30
31 Vector2ui v_uinti1{1u, 1u};
32 EXPECT_FALSE(v_uinti1.is_zero());
33 v_uinti1 = Vector2ui();
34 EXPECT_TRUE(v_uinti1.is_zero());
35 v_uinti1[0] = 1u;
36 EXPECT_FALSE(v_uinti1.is_zero());
37 const uint16_t testui1 = v_uinti1[0];
38 EXPECT_TRUE(1u == testui1);
39 v_uinti1.zero();
40 EXPECT_TRUE(v_uinti1.is_zero());
41
42 Vector2l v_intl1{1, 1};
43 EXPECT_FALSE(v_intl1.is_zero());
44 v_intl1 = Vector2l();
45 EXPECT_TRUE(v_intl1.is_zero());
46 v_intl1[0] = 1;
47 EXPECT_FALSE(v_intl1.is_zero());
48 const int32_t testl1 = v_intl1[0];
49 EXPECT_TRUE(1 == testl1);
50 v_intl1.zero();
51 EXPECT_TRUE(v_intl1.is_zero());
52
53 Vector2ul v_uint1l{1, 1};
54 EXPECT_FALSE(v_uint1l.is_zero());
55 v_uint1l = Vector2ul();
56 EXPECT_TRUE(v_uint1l.is_zero());
57 v_uint1l[0] = 1;
58 EXPECT_FALSE(v_uint1l.is_zero());
59 const uint32_t testul1 = v_uint1l[0];
60 EXPECT_TRUE(1 == testul1);
61 v_uint1l.zero();
62 EXPECT_TRUE(v_uint1l.is_zero());
63
64 Vector2f v_float1(1.0f, 1.0f);

Callers

nothing calls this directly

Calls 15

is_equalFunction · 0.85
radiansFunction · 0.85
limit_lengthMethod · 0.80
is_zeroFunction · 0.50
is_zeroMethod · 0.45
zeroMethod · 0.45
is_nanMethod · 0.45
is_infMethod · 0.45
angleMethod · 0.45
length_squaredMethod · 0.45
normalizeMethod · 0.45
normalizedMethod · 0.45

Tested by

no test coverage detected