Skip to content

Commit

Permalink
Finish snake_case refactor of oscar's tests, bar the Graphics/ folder
Browse files Browse the repository at this point in the history
  • Loading branch information
adamkewley committed Nov 6, 2024
1 parent 00619ba commit 4c59579
Show file tree
Hide file tree
Showing 33 changed files with 154 additions and 147 deletions.
6 changes: 3 additions & 3 deletions tests/testoscar/Graphics/TestVertexAttribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ using namespace osc;
// set intersection between multiple vertex buffers etc. more easily
TEST(VertexAttribute, order_matches_default_vertex_buffer_layout)
{
const auto order = std::to_array({
const auto expected_order = std::to_array({
VertexAttribute::Position,
VertexAttribute::Normal,
VertexAttribute::Tangent,
VertexAttribute::Color,
VertexAttribute::TexCoord0,
});
static_assert(std::tuple_size_v<decltype(order)> == num_options<VertexAttribute>());
static_assert(std::tuple_size_v<decltype(expected_order)> == num_options<VertexAttribute>());

ASSERT_TRUE(std::is_sorted(order.begin(), order.end()));
ASSERT_TRUE(std::is_sorted(expected_order.begin(), expected_order.end()));
}
6 changes: 3 additions & 3 deletions tests/testoscar/Maths/TestAnalyticPlane.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@

using namespace osc;

TEST(AnalyticPlane, IsRegular)
TEST(AnalyticPlane, is_regular)
{
static_assert(std::regular<AnalyticPlane>);
}

TEST(AnalyticPlane, ConstructsPointingUpwards)
TEST(AnalyticPlane, default_constructor_normal_points_along_plus_y)
{
static_assert(AnalyticPlane{}.normal == Vec3{0.0f, 1.0f, 0.0f});
}

TEST(AnalyticPlane, CanStreamToString)
TEST(AnalyticPlane, can_be_written_to_std_ostream)
{
std::stringstream ss;
ss << AnalyticPlane{};
Expand Down
32 changes: 16 additions & 16 deletions tests/testoscar/Maths/TestAngle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,27 @@
using namespace osc;
using namespace osc::literals;

TEST(Angle, RadiansCanValueConstructToZero)
TEST(Radians, can_be_constructed_from_zero_float)
{
static_assert(Radians{} == Radians{0.0f});
}

TEST(Angle, RadiansCanConstructWithInitialValue)
TEST(Radians, can_be_constructed_with_initial_value)
{
static_assert(Radians{5.0f}.count() == 5.0);
}

TEST(Angle, RadiansCanConstructViaUDL)
TEST(Radians, can_be_constructed_from_user_defined_radians_literal)
{
static_assert(8.0_rad == Radians{8.0f});
}

TEST(Angle, RadiansCanConstructFromDegrees)
TEST(Radians, can_be_constructed_from_Degrees)
{
static_assert(Radians{50.0_deg} == Radians{Degrees{50.0f}});
}

TEST(Angle, RadiansConversionFromDegreesWorksAsExpected)
TEST(Radians, construction_from_Degrees_converts_the_value_as_expected)
{
static_assert(Radians{-90.0_deg} == Radians{-0.5f*pi_v<float>});
static_assert(Radians{90.0_deg} == Radians{0.5f*pi_v<float>});
Expand All @@ -40,23 +40,23 @@ TEST(Angle, RadiansConversionFromDegreesWorksAsExpected)
static_assert(Radians{360.0_deg} == Radians{2.0f*pi_v<float>});
}

TEST(Angle, RadiansAddingTwoRadiansWorksAsExpected)
TEST(Radians, addition_operator_works_as_expected)
{
static_assert(Radians{1.0f} + Radians{1.0f} == Radians{2.0f});
}

TEST(Angle, RadiansSubtractingTwoRadiansWorksAsExpected)
TEST(Radians, subtraction_operator_works_as_expected)
{
static_assert(Radians{1.0f} - Radians{0.5f} == Radians{0.5f});
}

TEST(Angle, RadiansMultiplyingRadiansByScalarWorksAsExpected)
TEST(Radians, scalar_multiplication_operator_works_as_expected)
{
static_assert(2.0f*Radians{1.0f} == Radians{2.0f});
static_assert(Radians{1.0f}*3.0f == Radians{3.0f});
}

TEST(Angle, ComparisonBehavesAsExpected)
TEST(Radians, three_way_comparison_works_as_expected)
{
static_assert(1_rad < 2_rad);
static_assert(1_rad <= 2_rad);
Expand All @@ -65,14 +65,14 @@ TEST(Angle, ComparisonBehavesAsExpected)
static_assert(1_rad > 0.5_rad);
}

TEST(Angle, RadiansPlusEqualsWorksAsExpected)
TEST(Radians, addition_assignment_operator_works_as_expected)
{
Radians r{1.0f};
r += 1_rad;
ASSERT_EQ(r, 2_rad);
}

TEST(Angle, FmodBehavesAsExpected)
TEST(Radians, mod_works_as_expected)
{
using osc::mod;

Expand All @@ -81,30 +81,30 @@ TEST(Angle, FmodBehavesAsExpected)
ASSERT_EQ(r, 0_rad);
}

TEST(Angle, MixedAdditionReturnsRadians)
TEST(Angle, addition_operator_works_with_different_Angle_types)
{
static_assert(Radians{360_deg} == Radians{180_deg} + 180_deg);
}

TEST(Angle, TurnConvertsToRadiansOrDegreesAsExpected)
TEST(Turns, converts_to_Degrees_or_Radians_as_expected)
{
static_assert(1_turn == 2.0f*pi_v<float>*1_rad);
static_assert(0.5_turn == pi_v<float>*1_rad);
static_assert(1_turn == 360_deg);
static_assert(0.5_turn == 180_deg);
}

TEST(Angle, CanCompareMixedAngularTypes)
TEST(Angle, equality_works_across_mixed_Angle_types)
{
static_assert(1_turn == 360_deg); // should compile
}

TEST(Angle, ScalarDivisionWorksAsExpected)
TEST(Turn, division_by_a_scalar_works_as_expected)
{
static_assert(1_turn/2 == 180_deg);
}

TEST(Angle, CanUseProjectedClampWithAngles)
TEST(Angle, is_compatible_with_projected_clamp_algorithm)
{
// just a "it'd be nice to know osc::Angle inter-operates with std::ranges::clamp algs"
struct S {
Expand Down
5 changes: 2 additions & 3 deletions tests/testoscar/Maths/TestBVH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@

using namespace osc;

TEST(BVH, GetMaxDepthReturns0OnDefaultConstruction)
TEST(BVH, max_depth_returns_zero_on_default_construction)
{
BVH bvh;

const BVH bvh;
ASSERT_EQ(bvh.max_depth(), 0);
}
8 changes: 4 additions & 4 deletions tests/testoscar/Maths/TestClosedInterval.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ using namespace osc;

TEST(ClosedInterval, default_constructor_value_initializes)
{
ClosedInterval<float> r;
const ClosedInterval<float> r;
ASSERT_EQ(r.lower, float{});
ASSERT_EQ(r.upper, float{});
}
Expand All @@ -21,17 +21,17 @@ TEST(ClosedInterval, can_use_structured_bindings_to_get_lower_and_upper)
ASSERT_EQ(upper, 3);
}

TEST(ClosedInterval, CanConstructForInts)
TEST(ClosedInterval, can_be_constructed_from_ints)
{
[[maybe_unused]] ClosedInterval<int> r{0, 1}; // shouldn't throw etc
}

TEST(ClosedInterval, ReversingOrderIsAllowed)
TEST(ClosedInterval, reversing_lower_and_upper_is_allowed)
{
[[maybe_unused]] ClosedInterval<int> r{1, 0};
}

TEST(ClosedInterval, TimestampsAreAllowed)
TEST(ClosedInterval, can_be_constructed_from_time_points)
{
using TP = std::chrono::system_clock::time_point;
[[maybe_unused]] ClosedInterval<TP> r{TP{}, TP{} + std::chrono::seconds{1}};
Expand Down
16 changes: 8 additions & 8 deletions tests/testoscar/Maths/TestCommonFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,31 @@

using namespace osc;

TEST(abs, WorksForFloats)
TEST(abs, works_on_floating_point_numbers)
{
ASSERT_EQ(abs(-1.4f), 1.4f);
}

TEST(abs, WorksForSignedIntegrals)
TEST(abs, works_on_signed_integers)
{
ASSERT_EQ(abs(-5), 5);
}

TEST(abs, WorksForVectorOfFloats)
TEST(abs, works_on_Vec3)
{
ASSERT_EQ(abs(Vec3(-1.0f, -2.0f, 3.0f)), Vec3(1.0f, 2.0f, 3.0f));
}

TEST(abs, WorksForVectorOfInts)
TEST(abs, works_on_Vec3i)
{
ASSERT_EQ(abs(Vec3i(-3, -2, 0)), Vec3i(3, 2, 0));
}

TEST(mod, WorksForVectorOfAngles)
TEST(mod, works_on_Vec3_of_Angles)
{
Vec<3, Degrees> x{10.0f, 3.0f, 4.0f};
Vec<3, Degrees> y{8.0f, 2.0f, 1.0f};
Vec<3, Degrees> expected{2.0f, 1.0f, 0.0f};
const Vec<3, Degrees> x{10.0f, 3.0f, 4.0f};
const Vec<3, Degrees> y{8.0f, 2.0f, 1.0f};
const Vec<3, Degrees> expected{2.0f, 1.0f, 0.0f};

ASSERT_EQ(mod(x, y), expected);
}
4 changes: 2 additions & 2 deletions tests/testoscar/Maths/TestCoordinateAxis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ namespace
std::optional<CoordinateAxis> expected;
};

constexpr auto c_ParsingTestCases = std::to_array<ParsingTestCase>({
constexpr auto c_parsing_test_cases = std::to_array<ParsingTestCase>({
// blank/value-initialized
{"", std::nullopt},
{{}, std::nullopt},
Expand Down Expand Up @@ -131,7 +131,7 @@ namespace
INSTANTIATE_TEST_SUITE_P(
CoordinateAxisParsingTest,
CoordinateAxisParsingTestFixture,
testing::ValuesIn(c_ParsingTestCases)
testing::ValuesIn(c_parsing_test_cases)
);

TEST_P(CoordinateAxisParsingTestFixture, Check)
Expand Down
34 changes: 17 additions & 17 deletions tests/testoscar/Maths/TestCoordinateDirection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,43 @@
using namespace osc;
using namespace osc::literals;

TEST(CoordinateDirection, IsRegular)
TEST(CoordinateDirection, is_regular)
{
static_assert(std::regular<CoordinateDirection>);
}

TEST(CoordinateDirection, DefaultConstructedPointsInPositiveX)
TEST(CoordinateDirection, default_constructed_is_positive_X)
{
static_assert(CoordinateDirection{} == CoordinateDirection::x());
}

TEST(CoordinateDirection, XIsEquivalentToConstructingFromXAxisDirection)
TEST(CoordinateDirection, x_compares_equivalent_to_constructing_from_x_CoordinateAxis)
{
static_assert(CoordinateDirection::x() == CoordinateDirection{CoordinateAxis::x()});
}

TEST(CoordinateDirection, XYZAreNotEqualToEachover)
TEST(CoordinateDirection, x_y_and_z_are_not_equal_to_eachover)
{
static_assert(CoordinateDirection::x() != CoordinateDirection::y());
static_assert(CoordinateDirection::x() != CoordinateDirection::z());
static_assert(CoordinateDirection::y() != CoordinateDirection::z());
}

TEST(CoordinateDirection, PositiveDirectionsNotEqualToNegative)
TEST(CoordinateDirection, positive_compares_not_equal_to_negative_CoordinateDirection)
{
static_assert(CoordinateDirection::x() != CoordinateDirection::minus_x());
static_assert(CoordinateDirection::y() != CoordinateDirection::minus_y());
static_assert(CoordinateDirection::z() != CoordinateDirection::minus_z());
}

TEST(CoordinateDirection, AxisIgnoresPositiveVsNegative)
TEST(CoordinateDirection, axis_ignores_positive_vs_negative)
{
static_assert(CoordinateDirection::x().axis() == CoordinateDirection::minus_x().axis());
static_assert(CoordinateDirection::y().axis() == CoordinateDirection::minus_y().axis());
static_assert(CoordinateDirection::z().axis() == CoordinateDirection::minus_z().axis());
}

TEST(CoordinateDirection, UnaryNegationWorksAsExpected)
TEST(CoordinateDirection, unary_minus_works_as_expected)
{
static_assert(-CoordinateDirection::x() == CoordinateDirection::minus_x());
static_assert(-CoordinateDirection::y() == CoordinateDirection::minus_y());
Expand All @@ -58,7 +58,7 @@ TEST(CoordinateDirection, UnaryNegationWorksAsExpected)
static_assert(-CoordinateDirection::minus_z() == CoordinateDirection::z());
}

TEST(CoordinateDirection, DirectionReturnsExpectedResults)
TEST(CoordinateDirection, direction_returns_expected_results)
{
static_assert(CoordinateDirection::x().direction() == 1.0f);
static_assert(CoordinateDirection::minus_x().direction() == -1.0f);
Expand All @@ -76,20 +76,20 @@ TEST(CoordinateDirection, DirectionReturnsExpectedResults)
static_assert(CoordinateDirection::minus_x().direction<double>() == -1.0);
}

TEST(CoordinateDirection, AreOrderedAsExpected)
TEST(CoordinateDirection, have_an_expected_total_ordering)
{
const auto expectedOrder = std::to_array({
const auto expected_order = std::to_array({
CoordinateDirection::minus_x(),
CoordinateDirection::x(),
CoordinateDirection::minus_y(),
CoordinateDirection::y(),
CoordinateDirection::minus_z(),
CoordinateDirection::z(),
});
ASSERT_TRUE(std::is_sorted(expectedOrder.begin(), expectedOrder.end()));
ASSERT_TRUE(std::is_sorted(expected_order.begin(), expected_order.end()));
}

TEST(CoordinateDirection, CrossWorksAsExpected)
TEST(CoordinateDirection, cross_works_as_expected)
{
// cross products along same axis (undefined: falls back to first arg)
static_assert(cross(CoordinateDirection::x(), CoordinateDirection::x()) == CoordinateDirection::x());
Expand Down Expand Up @@ -157,7 +157,7 @@ namespace
std::optional<CoordinateDirection> expected;
};

constexpr auto c_ParsingTestCases = std::to_array<ParsingTestCase>({
constexpr auto c_parsing_test_cases = std::to_array<ParsingTestCase>({
// blank/value-initialized
{"", std::nullopt},
{{}, std::nullopt},
Expand Down Expand Up @@ -211,7 +211,7 @@ namespace
INSTANTIATE_TEST_SUITE_P(
CoordinateDirectionParsingTest,
ParsingTestFixture,
testing::ValuesIn(c_ParsingTestCases)
testing::ValuesIn(c_parsing_test_cases)
);

TEST_P(ParsingTestFixture, Check)
Expand All @@ -228,7 +228,7 @@ namespace
std::string_view expected;
};

constexpr auto c_PrintingTestCases = std::to_array<PrintingTestCase>({
constexpr auto c_printing_test_cases = std::to_array<PrintingTestCase>({
{CoordinateDirection::x(), "x"},
{CoordinateDirection::minus_x(), "-x"},
{CoordinateDirection::y(), "y"},
Expand All @@ -243,7 +243,7 @@ namespace
INSTANTIATE_TEST_SUITE_P(
CoordinateDirectionPrintingTest,
PrintingTestFixture,
testing::ValuesIn(c_PrintingTestCases)
testing::ValuesIn(c_printing_test_cases)
);

TEST_P(PrintingTestFixture, Check)
Expand All @@ -266,7 +266,7 @@ TEST(CoordinateDirection, is_negated_WorksAsExpected)
static_assert(CoordinateDirection::minus_z().is_negated());
}

TEST(CoordinateDirection, VecReturnsExpectedResults)
TEST(CoordinateDirection, vec_returns_expected_results)
{
ASSERT_EQ(CoordinateDirection::x().vec(), Vec3(1.0f, 0.0f, 0.0f));
ASSERT_EQ(CoordinateDirection::y().vec(), Vec3(0.0f, 1.0f, 0.0f));
Expand Down
2 changes: 1 addition & 1 deletion tests/testoscar/Maths/TestFrustumPlanes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

using namespace osc;

TEST(FrustumPlanes, IsRegular)
TEST(FrustumPlanes, is_regular)
{
static_assert(std::regular<FrustumPlanes>);
}
Loading

0 comments on commit 4c59579

Please sign in to comment.