Przeglądaj źródła

test: give more explicit names to unit test cases.

legacy
Sam Hocevar sam 13 lat temu
rodzic
commit
56511457d2
4 zmienionych plików z 31 dodań i 36 usunięć
  1. +12
    -14
      test/unit/half.cpp
  2. +7
    -9
      test/unit/matrix.cpp
  3. +8
    -8
      test/unit/real.cpp
  4. +4
    -5
      test/unit/trig.cpp

+ 12
- 14
test/unit/half.cpp Wyświetl plik

@@ -22,8 +22,7 @@ namespace lol

LOLUNIT_FIXTURE(HalfTest)
{
public:
LOLUNIT_TEST(test_half_from_float)
LOLUNIT_TEST(FloatToHalf)
{
for (size_t i = 0; i < sizeof(pairs) / sizeof(*pairs); i++)
{
@@ -34,7 +33,7 @@ public:
}
}

LOLUNIT_TEST(test_half_makeaccurate)
LOLUNIT_TEST(FloatToHalfAccurate)
{
for (size_t i = 0; i < sizeof(pairs) / sizeof(*pairs); i++)
{
@@ -45,7 +44,7 @@ public:
}
}

LOLUNIT_TEST(test_half_makebits)
LOLUNIT_TEST(BitsToHalf)
{
for (unsigned int i = 0; i < 0x10000; i++)
{
@@ -56,7 +55,7 @@ public:
}
}

LOLUNIT_TEST(test_half_is_nan)
LOLUNIT_TEST(HalfIsNaN)
{
LOLUNIT_ASSERT(half::makebits(0x7c01).is_nan());
LOLUNIT_ASSERT(half::makebits(0xfc01).is_nan());
@@ -72,7 +71,7 @@ public:
LOLUNIT_ASSERT(!half(-2.0f).is_nan());
}

LOLUNIT_TEST(test_half_is_inf)
LOLUNIT_TEST(HalfIsInf)
{
LOLUNIT_ASSERT(half(65536.0f).is_inf());
LOLUNIT_ASSERT(half(-65536.0f).is_inf());
@@ -89,7 +88,7 @@ public:
LOLUNIT_ASSERT(!half::makebits(0xfe00).is_inf());
}

LOLUNIT_TEST(test_half_is_finite)
LOLUNIT_TEST(HalfIsFinite)
{
LOLUNIT_ASSERT(half(0.0f).is_finite());
LOLUNIT_ASSERT(half(-0.0f).is_finite());
@@ -106,7 +105,7 @@ public:
LOLUNIT_ASSERT(!half::makebits(0xfe00).is_finite());
}

LOLUNIT_TEST(test_half_is_normal)
LOLUNIT_TEST(HalfIsNormal)
{
LOLUNIT_ASSERT(half(0.0f).is_normal());
LOLUNIT_ASSERT(half(-0.0f).is_normal());
@@ -123,7 +122,7 @@ public:
LOLUNIT_ASSERT(!half::makebits(0xfe00).is_normal());
}

LOLUNIT_TEST(test_half_classify)
LOLUNIT_TEST(HalfClassify)
{
for (uint32_t i = 0; i < 0x10000; i++)
{
@@ -147,7 +146,7 @@ public:
}
}

LOLUNIT_TEST(test_half_to_float)
LOLUNIT_TEST(HalfToFloat)
{
for (size_t i = 0; i < sizeof(pairs) / sizeof(*pairs); i++)
{
@@ -176,7 +175,7 @@ public:
}
}

LOLUNIT_TEST(test_half_to_int)
LOLUNIT_TEST(HalfToInt)
{
LOLUNIT_ASSERT_EQUAL((int)(half)(0.0f), 0);
LOLUNIT_ASSERT_EQUAL((int)(half)(-0.0f), 0);
@@ -190,7 +189,7 @@ public:
LOLUNIT_ASSERT_EQUAL((int)(half)(-65504.0f), -65504);
}

LOLUNIT_TEST(test_float_op_half)
LOLUNIT_TEST(FloatOpHalf)
{
half zero = 0;
half one = 1;
@@ -231,7 +230,7 @@ public:
LOLUNIT_ASSERT_EQUAL(2.0f, f);
}

LOLUNIT_TEST(test_half_op_float)
LOLUNIT_TEST(HalfOpFloat)
{
half zero = 0;
half one = 1;
@@ -273,7 +272,6 @@ public:
LOLUNIT_ASSERT_EQUAL(two.bits, f.bits);
}

private:
struct TestPair { float f; uint16_t x; };

static TestPair const pairs[11];


+ 7
- 9
test/unit/matrix.cpp Wyświetl plik

@@ -20,7 +20,6 @@ namespace lol

LOLUNIT_FIXTURE(MatrixTest)
{
public:
void SetUp()
{
identity = mat4(1.0f);
@@ -36,7 +35,7 @@ public:

void TearDown() {}

LOLUNIT_TEST(test_vec_eq)
LOLUNIT_TEST(VectorEquality)
{
vec2 a2(1.0f, 2.0f);
vec2 b2(0.0f, 2.0f);
@@ -84,7 +83,7 @@ public:
LOLUNIT_ASSERT_NOT_EQUAL(a4, e4);
}

LOLUNIT_TEST(test_vec_lt)
LOLUNIT_TEST(VectorInequality)
{
vec2 a2(1.0f, 3.0f);
vec2 b2(0.0f, 0.0f);
@@ -108,7 +107,7 @@ public:
LOLUNIT_ASSERT_LESS(a2, f2);
}

LOLUNIT_TEST(test_vec_unary)
LOLUNIT_TEST(VectorUnaryMinus)
{
vec2 a(1.0f, 3.0f);
vec2 b(-1.0f, -3.0f);
@@ -117,7 +116,7 @@ public:
LOLUNIT_ASSERT_EQUAL(-a, b);
}

LOLUNIT_TEST(test_vec_cast)
LOLUNIT_TEST(CastVector)
{
vec2 a1(1.0f, 3.0f);

@@ -137,7 +136,7 @@ public:
LOLUNIT_ASSERT_EQUAL(a3, a1);
}

LOLUNIT_TEST(test_mat_det)
LOLUNIT_TEST(MatrixDeterminant)
{
float d1 = triangular.det();
LOLUNIT_ASSERT_EQUAL(d1, 24.0f);
@@ -145,7 +144,7 @@ public:
LOLUNIT_ASSERT_EQUAL(d2, -1.0f);
}

LOLUNIT_TEST(test_mat_mul)
LOLUNIT_TEST(MatrixMultiplication)
{
mat4 m0 = identity;
mat4 m1 = identity;
@@ -172,7 +171,7 @@ public:
LOLUNIT_ASSERT_EQUAL(m2[3][3], 1.0f);
}

LOLUNIT_TEST(test_mat_inv)
LOLUNIT_TEST(MatrixInverse)
{
mat4 m0 = invertible;
mat4 m1 = m0.invert();
@@ -200,7 +199,6 @@ public:
LOLUNIT_ASSERT_EQUAL(m2[3][3], 1.0f);
}

private:
mat4 triangular, identity, invertible;
};



+ 8
- 8
test/unit/real.cpp Wyświetl plik

@@ -22,7 +22,7 @@ namespace lol

LOLUNIT_FIXTURE(RealTest)
{
LOLUNIT_TEST(test_real_from_float)
LOLUNIT_TEST(FloatToReal)
{
float a1 = real(0.0f);
float a2 = real(-0.0f);
@@ -39,7 +39,7 @@ LOLUNIT_FIXTURE(RealTest)
LOLUNIT_ASSERT_EQUAL(a6, 12345678.0f);
}

LOLUNIT_TEST(test_real_from_double)
LOLUNIT_TEST(DoubleToReal)
{
double a1 = real(0.0);
double a2 = real(-0.0);
@@ -56,7 +56,7 @@ LOLUNIT_FIXTURE(RealTest)
LOLUNIT_ASSERT_DOUBLES_EQUAL(a6, 1234567876543210.0, 0.0);
}

LOLUNIT_TEST(test_real_neg)
LOLUNIT_TEST(UnaryMinus)
{
float a1 = - real(1.0f);
float a2 = - real(-1.0f);
@@ -69,7 +69,7 @@ LOLUNIT_FIXTURE(RealTest)
LOLUNIT_ASSERT_EQUAL(a4, 0.0f);
}

LOLUNIT_TEST(test_real_comp)
LOLUNIT_TEST(RealComparison)
{
LOLUNIT_ASSERT(real(1.0f) > real(0.5f));
LOLUNIT_ASSERT(real(1.0f) >= real(0.5f));
@@ -90,7 +90,7 @@ LOLUNIT_FIXTURE(RealTest)
LOLUNIT_ASSERT(real(0.5f) >= real(-1.0f));
}

LOLUNIT_TEST(test_real_add)
LOLUNIT_TEST(RealAddition)
{
float a1 = real(1.0f) + real(0.0f);
float a2 = real(0.0f) + real(1.0f);
@@ -105,14 +105,14 @@ LOLUNIT_FIXTURE(RealTest)
LOLUNIT_ASSERT_EQUAL(a5, 1.125f);
}

LOLUNIT_TEST(test_real_sub)
LOLUNIT_TEST(RealSubtraction)
{
float a1 = real(1.0f) + real(1e20f) - real(1e20f);

LOLUNIT_ASSERT_EQUAL(a1, 1.0f);
}

LOLUNIT_TEST(test_real_mul)
LOLUNIT_TEST(RealMultiplication)
{
real x(1.25f);
real y(1.5f);
@@ -130,7 +130,7 @@ LOLUNIT_FIXTURE(RealTest)
LOLUNIT_ASSERT_EQUAL(m4, -1.5f * -1.5f);
}

LOLUNIT_TEST(test_real_div)
LOLUNIT_TEST(RealDivision)
{
real a1(1.0f);
real a2(2.0f);


+ 4
- 5
test/unit/trig.cpp Wyświetl plik

@@ -22,8 +22,7 @@ namespace lol

LOLUNIT_FIXTURE(TrigTest)
{
public:
LOLUNIT_TEST(test_sin)
LOLUNIT_TEST(Sin)
{
for (int i = -10000; i < 10000; i++)
{
@@ -52,7 +51,7 @@ public:
}
}

LOLUNIT_TEST(test_cos)
LOLUNIT_TEST(Cos)
{
for (int i = -10000; i < 10000; i++)
{
@@ -81,7 +80,7 @@ public:
}
}

LOLUNIT_TEST(test_sincos)
LOLUNIT_TEST(SinCos)
{
for (int i = -10000; i < 10000; i++)
{
@@ -118,7 +117,7 @@ public:
}
}

LOLUNIT_TEST(test_tan)
LOLUNIT_TEST(Tan)
{
for (int i = -100000; i < 100000; i++)
{


Ładowanie…
Anuluj
Zapisz