| the Compartmented Robust Posix C++ Unit Test system |
|
|---|
Namespace for library name access functions used by
CRPCUT_WRAP_FUNC(lib, func, rv, param_list, param_call) and
CRPCUT_WRAP_V_FUNC(lib, func, rv, param_list, param_call).
crpcut already defines library name access functions for
libc and librt. To write
a wrapper for a function defined in another library requires a
library name access function for it. A library name access
function has the signature:
const char * const *libname()The array returned must be zero-terminated.
Example: The test program wrapping a function in libm
#include <crpcut.hpp>
#include <math.h>
namespace crpcut {
namespace libs {
const char * const * libm()
{
static const char * const name[] = {
"libm.so",
"libm.so.6",
0
};
return name;
}
}
}
namespace original {
CRPCUT_WRAP_FUNC(libm, asin, double, (double d), (d))
}
extern "C"
{
double asin(double d) throw ()
{
ASSERT_GE(d, -1.0);
ASSERT_LT(d, 1.0);
return original::asin(d);
}
}
TEST(pass_in_range)
{
double d = asin(0.5);
INFO << "d=" << d;
}
TEST(fail_assert_lt)
{
double d = asin(1.1);
INFO << "d=" << d;
}
int main(int argc, char *argv[])
{
return crpcut::run(argc, argv);
}
fails one test:
FAILED!: fail_assert_lt
phase="running" --------------------------------------------------------------
samples/wrapped.cpp:53
ASSERT_LT(d, 1.0)
where d = 1.1
1.0 = 1
-------------------------------------------------------------------------------
===============================================================================
2 test cases selected
Sum Critical Non-critical
PASSED : 1 1 0
FAILED : 1 1 0