Changeset 982 for trunk/test/unit


Ignore:
Timestamp:
Sep 26, 2011, 2:00:52 AM (11 years ago)
Author:
sam
Message:

core: add rounding to real->double conversion, fix a bug in the addition
code shortcut, fix bugs in the addition and subtraction, another one in
the multiplication code, and add new unit tests for most of these.

File:
1 edited

Legend:

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

    r979 r982  
    9898        float a4 = real(-1.0f) + real(-1.0f);
    9999        float a5 = real(1.0f) + real(0.125f);
     100        double a6 = real(3.13609818956293918)
     101                  + real(0.00005972154828114);
     102        float a7 = real(1.0f) + real(-0.125f);
     103        double a8 = real(0.10000000002) + real(-2.0e-11);
    100104
    101105        LOLUNIT_ASSERT_EQUAL(a1, 1.0f);
     
    104108        LOLUNIT_ASSERT_EQUAL(a4, -2.0f);
    105109        LOLUNIT_ASSERT_EQUAL(a5, 1.125f);
     110        LOLUNIT_ASSERT_DOUBLES_EQUAL(a6, 3.1361579, 0.000001);
     111        LOLUNIT_ASSERT_EQUAL(a7, 0.875f);
     112        LOLUNIT_ASSERT_DOUBLES_EQUAL(a8, 0.1, 1.0e-13);
    106113    }
    107114
     
    140147        float m3 = a1 / a2;
    141148        float m4 = a2 / a2;
     149        float m5 = a1 / -a2;
    142150
    143151        LOLUNIT_ASSERT_EQUAL(m1, 1.0f);
     
    145153        LOLUNIT_ASSERT_EQUAL(m3, 0.5f);
    146154        LOLUNIT_ASSERT_EQUAL(m4, 1.0f);
     155        LOLUNIT_ASSERT_EQUAL(m5, -0.5f);
    147156    }
    148157};
Note: See TracChangeset for help on using the changeset viewer.