blender/tests/gtests/blenlib/BLI_math_geom_test.cc
Campbell Barton 7ecc3f4734 Add brief license headers to tests
These are effectively public-domain, but use apache2.0 to avoid adding new licenses
2014-06-19 18:48:41 +10:00

24 lines
519 B
C++

/* Apache License, Version 2.0 */
#include "testing/testing.h"
#include "BLI_math.h"
TEST(mathutils, DistToLine2DSimple)
{
float p[2] = {5.0f, 1.0f},
a[2] = {0.0f, 0.0f},
b[2] = {2.0f, 0.0f};
float distance = dist_to_line_v2(p, a, b);
EXPECT_NEAR(1.0f, distance, 1e-6);
}
TEST(mathutils, DistToLineSegment2DSimple)
{
float p[2] = {3.0f, 1.0f},
a[2] = {0.0f, 0.0f},
b[2] = {2.0f, 0.0f};
float distance = dist_to_line_segment_v2(p, a, b);
EXPECT_NEAR(sqrtf(2.0f), distance, 1e-6);
}