Ignore:
Timestamp:
Oct 3, 2011, 1:36:25 AM (11 years ago)
Author:
sam
Message:

core: implement asin() and acos() for real numbers and add unit tests for
these functions.

File:
1 edited

Legend:

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

    r998 r1001  
    237237        LOLUNIT_ASSERT(!!a);
    238238    }
     239
     240    LOLUNIT_TEST(AsinAcos)
     241    {
     242        double tests[14] =
     243        {
     244            -1024.0, -1023.0, -513.0, -512.0, -511.0, -1.0, -0.0,
     245            0.0, 1.0, 511.0, 512.0, 513.0, 1023.0, 1024.0
     246        };
     247
     248        for (int n = 0; n < 14; n++)
     249        {
     250            double a = tests[n] / 1024;
     251            double b = sin(asin((real)a));
     252            double c = cos(acos((real)a));
     253
     254            LOLUNIT_SET_CONTEXT(a);
     255            LOLUNIT_ASSERT_DOUBLES_EQUAL(b, a, 1e-100);
     256            LOLUNIT_ASSERT_DOUBLES_EQUAL(c, a, 1e-100);
     257        }
     258    }
    239259};
    240260
Note: See TracChangeset for help on using the changeset viewer.