Skip to content

Commit c0c9702

Browse files
tests: add test with result being a zero vector
Co-authored-by: realstealthninja <[email protected]>
1 parent cc025c2 commit c0c9702

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

math/vector_cross_product.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,14 @@ static void test() {
109109
/// Tests the mag() function.
110110
double t_mag = math::vector_cross::mag({6, 8, 0});
111111
assert(t_mag == 10);
112+
113+
/// Tests A ⨯ A = 0
114+
std::array<double, 3> t_vec2 =
115+
math::vector_cross::cross({1, 2, 3}, {1, 2, 3});
116+
assert(t_vec2[0] == 0 && t_vec2[1] == 0 &&
117+
t_vec2[2] == 0); // checking each element
118+
assert(math::vector_cross::mag(t_vec2) ==
119+
0); // checking the magnitude is also zero
112120
}
113121

114122
/**

0 commit comments

Comments
 (0)