Changeset 969 for trunk/test/unit


Ignore:
Timestamp:
Sep 21, 2011, 7:10:21 PM (11 years ago)
Author:
sam
Message:

core: switch real mantissa to uint16_t instead of uint32_t to ease the
multiplication.

File:
1 edited

Legend:

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

    r967 r969  
    2626    LOLUNIT_TEST(test_real_from_float)
    2727    {
    28         float x = real4k(0.0f);
    29         float y = real4k(1.0f);
     28        float x = real(0.0f);
     29        float y = real(1.0f);
     30        float z = real(1.5f);
    3031
    3132        LOLUNIT_ASSERT_EQUAL(x, 0.0f);
    3233        LOLUNIT_ASSERT_EQUAL(y, 1.0f);
     34        LOLUNIT_ASSERT_EQUAL(z, 1.5f);
     35    }
     36
     37    LOLUNIT_TEST(test_real_mul)
     38    {
     39        real x(1.25f);
     40        real y(1.5f);
     41        real z(1.99999f);
     42        real w(-1.5f);
     43
     44        float m1 = x * x;
     45        float m2 = y * y;
     46        float m3 = z * z;
     47        float m4 = w * w;
     48
     49        LOLUNIT_ASSERT_EQUAL(m1, 1.25f * 1.25f);
     50        LOLUNIT_ASSERT_EQUAL(m2, 1.5f * 1.5f);
     51        LOLUNIT_ASSERT_EQUAL(m3, 1.99999f * 1.99999f);
     52        LOLUNIT_ASSERT_EQUAL(m4, -1.5f * -1.5f);
    3353    }
    3454};
Note: See TracChangeset for help on using the changeset viewer.