Changeset 971 for trunk/test/unit


Ignore:
Timestamp:
Sep 22, 2011, 9:15:56 AM (11 years ago)
Author:
sam
Message:

core: handle zero, negative zero and infinite in the real constructor,
and add a test suite check for unary minus.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/real.cpp

    r970 r971  
    2626    LOLUNIT_TEST(test_real_from_float)
    2727    {
    28         float x = real(0.0f);
    29         float y = real(1.0f);
    30         float z = real(1.5f);
     28        float a1 = real(0.0f);
     29        float a2 = real(-0.0f);
     30        float a3 = real(1.0f);
     31        float a4 = real(-1.0f);
     32        float a5 = real(1.5f);
    3133
    32         LOLUNIT_ASSERT_EQUAL(x, 0.0f);
    33         LOLUNIT_ASSERT_EQUAL(y, 1.0f);
    34         LOLUNIT_ASSERT_EQUAL(z, 1.5f);
     34        LOLUNIT_ASSERT_EQUAL(a1, 0.0f);
     35        LOLUNIT_ASSERT_EQUAL(a2, -0.0f);
     36        LOLUNIT_ASSERT_EQUAL(a3, 1.0f);
     37        LOLUNIT_ASSERT_EQUAL(a4, -1.0f);
     38        LOLUNIT_ASSERT_EQUAL(a5, 1.5f);
     39    }
     40
     41    LOLUNIT_TEST(test_real_neg)
     42    {
     43        float a1 = - real(1.0f);
     44        float a2 = - real(-1.0f);
     45        float a3 = - real(0.0f);
     46        float a4 = - real(-0.0f);
     47
     48        LOLUNIT_ASSERT_EQUAL(a1, -1.0f);
     49        LOLUNIT_ASSERT_EQUAL(a2, 1.0f);
     50        LOLUNIT_ASSERT_EQUAL(a3, -0.0f);
     51        LOLUNIT_ASSERT_EQUAL(a4, 0.0f);
    3552    }
    3653
Note: See TracChangeset for help on using the changeset viewer.