cd15a4eb8ff16be9f70b4ac7baf3f7f068a78c2e
[blender-staging.git] / tests / gtests / blenlib / BLI_math_geom_test.cc
1 /* Apache License, Version 2.0 */
2
3 #include "testing/testing.h"
4
5 #include "BLI_math.h"
6
7 TEST(math_geom, DistToLine2DSimple)
8 {
9         float p[2] = {5.0f, 1.0f},
10               a[2] = {0.0f, 0.0f},
11               b[2] = {2.0f, 0.0f};
12         float distance = dist_to_line_v2(p, a, b);
13         EXPECT_NEAR(1.0f, distance, 1e-6);
14 }
15
16 TEST(math_geom, DistToLineSegment2DSimple)
17 {
18         float p[2] = {3.0f, 1.0f},
19               a[2] = {0.0f, 0.0f},
20               b[2] = {2.0f, 0.0f};
21         float distance = dist_to_line_segment_v2(p, a, b);
22         EXPECT_NEAR(sqrtf(2.0f), distance, 1e-6);
23 }