Ignore:
Timestamp:
Sep 8, 2011, 2:17:00 PM (8 years ago)
Author:
sam
Message:

lolunit: add a LOLUNIT_SET_CONTEXT / LOLUNIT_UNSET_CONTEXT macro pair.

This is useful when doing several asserts in one loop, for instance: there
isn't always a way to deduce the loop index from the assert failure, so
these macros allow the user to give more context information.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/trig.cpp

    r914 r927  
    3838#endif
    3939            double b = lol_sin(f);
     40            LOLUNIT_SET_CONTEXT(f);
    4041            LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
    4142        }
     
    5051#endif
    5152            double b = lol_sin(f);
     53            LOLUNIT_SET_CONTEXT(f);
    5254            LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
    5355        }
     
    6567#endif
    6668            double b = lol_cos(f);
     69            LOLUNIT_SET_CONTEXT(f);
    6770            LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
    6871        }
     
    7780#endif
    7881            double b = lol_cos(f);
     82            LOLUNIT_SET_CONTEXT(f);
    7983            LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(f) * 1e-11);
    8084        }
     
    9599            double b1, b2;
    96100            lol_sincos(f, &b1, &b2);
     101            LOLUNIT_SET_CONTEXT(f);
    97102            LOLUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11);
    98103            LOLUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, fabs(f) * 1e-11);
     
    111116            double b1, b2;
    112117            lol_sincos(f, &b1, &b2);
     118            LOLUNIT_SET_CONTEXT(f);
    113119            LOLUNIT_ASSERT_DOUBLES_EQUAL(a1, b1, fabs(f) * 1e-11);
    114120            LOLUNIT_ASSERT_DOUBLES_EQUAL(a2, b2, fabs(f) * 1e-11);
     
    127133#endif
    128134            double b = lol_tan(f);
     135            LOLUNIT_SET_CONTEXT(f);
    129136            if (fabs(a) > 1e4)
    130137                LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * fabs(a) * 1e-11);
     
    144151#endif
    145152            double b = lol_tan(f);
     153            LOLUNIT_SET_CONTEXT(f);
    146154            if (fabs(a) > 1e4)
    147155                LOLUNIT_ASSERT_DOUBLES_EQUAL(a, b, fabs(a) * fabs(a) * 1e-11);
Note: See TracChangeset for help on using the changeset viewer.