Very basic unit testing. I had to write my own unit testing because gcc44 can not compile BOOST_CHECK. Implemented mostly in macros. See examples in any ++u-*.cc++ file. See also http://github.com/apenwarr/wvtest/tree/master[] Other
See array docs
eq() - numeric comparison template function (math.h) Used for numeric comparison in generic programming.
Usually you can not in some programe define numeric type to a name (let say T) and then change it to other type if it used in sufishently complex computations. For example when you compare integer type you can use exact comparision but for floating types you need to account for an floating ops error (we will call it epsilon). And even when you change floating type to another floating type (let say from float to double), you still can not do it because epsilon will be very different.
eq() will allow you do this.
For floating point types we need two values (3rd and 4th arg) to specify precision. Both have reasonable defautls.
The 3rd arg is whole number of ULPs (Unit in the Last Place) and defaults to 100. It is inherent precision of type. It depends on variable value (characteristic type) and for value 1.0 is equal to std::numeric_limits<T>::epsilon().
Error in floating point expression is proportional to absolute value of compared values. Error will be bigger for 10000 than for 0.00001 and bigger for float than for double. This absolute value here is called characteristic value. Usually characteristic value is equal to value that we want to compare, and that is what eq defaults to: average of absolutes of compared values (1st and 2nd argument). But in chain of calculations characteristic value can be different and this is why we might need to explicitly specify it. For example in: x=1000.1; y=x-1000. characteristic value of y is 1000 even though it is approximately equal to 0.1.
For integer types exact comparison will be used and ULPs and characteristic value are ignored. Also if one of arguments is unsigned then other argument converted to unsigned type too (to avoid overflows). It is assumed that if comparison is with unsigned then it is guaranted that other value is positive (TODO: add assert check)
check.h
Very basic unit testing. I had to write my own unit testing because gcc44 can not compile BOOST_CHECK. Implemented mostly in macros. See examples in any ++u-*.cc++ file. See also http://github.com/apenwarr/wvtest/tree/master[] Other
| Header | Sample Use | Description |
|---|---|---|
mmap.h |
t-mmap.cc |
simplified mmap files ops. |
timer.h |
t-timer.cc |
timer of interval/total for cpu/wall/tick time. |
meta.h |
u-meta.cc |
meta programming |
float.h |
u-float.cc |
floating point traits and bit-twiddling |