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

Function TEST

libraries/AP_Math/tests/test_vector3.cpp:6–84  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 10

is_equalFunction · 0.85
limit_length_xyMethod · 0.80
is_zeroMethod · 0.45
zeroMethod · 0.45
is_nanMethod · 0.45
is_infMethod · 0.45
length_squaredMethod · 0.45
lengthMethod · 0.45
normalizeMethod · 0.45
normalizedMethod · 0.45

Tested by

no test coverage detected