VC源码,开源测试工具.有助于VC++的学习与开发
源代码在线查看: fail.cpp
#include #include #include using std::string; using std::runtime_error; namespace tut { /** * Testing fail() method. */ struct fail_test { }; typedef test_group tf; typedef tf::object object; tf fail_test("fail()"); template template void object::test() { set_test_name("checks fail with message"); try { fail("A Fail"); throw runtime_error("fail doesn't work"); } catch (const failure& ex) { if (string(ex.what()).find("A Fail") == string::npos ) { throw runtime_error("fail doesn't contain proper message"); } } } template template void object::test() { set_test_name("checks fail without message"); try { fail(); throw runtime_error("fail doesn't work"); } catch (const failure&) { } } }