/////////////////////////////////////////////////////////////////// // LibUtils.h - utility functions and classes for all libraries // // ver 1.0 // // ------------------------------------------------------------- // // copyright © Jim Fawcett, 2012 // // All rights granted provided that this notice is retained // // ------------------------------------------------------------- // // Jim Fawcett, CST 4-187, Syracuse University, 315 443 3948 // // Summer Projects, 2012 // // Win7, Visual Studio 2010 // /////////////////////////////////////////////////////////////////// #ifdef TEST_LIBUTILS #include "LibUtils.h" #include using namespace LibUtils; int main() { std::cout << "\n Test LibUtils"; std::cout << "\n ===============\n"; std::cout.precision(8); double pi = 3.1415927; std::string piStr = toString(pi); std::cout << "\n converting double into string: " << piStr; std::cout << "\n converting string into double: " << fromString(piStr); std::cout << "\n"; for(int i=0; i<2; ++i) { bool test_predicate = (i!=0); try { Assert::is(test_predicate, "this is a test"); test_predicate = !test_predicate; Assert::is(test_predicate, "this is another test"); } catch(std::exception& ex) { std::cout << "\n " << ex.what(); } } for(int i=0; i<2; ++i) { bool test_predicate = (i!=0); try { Assert::is(test_predicate); test_predicate = !test_predicate; Assert::is(test_predicate); } catch(std::exception& ex) { std::cout << "\n " << ex.what(); } } typedef Assert assert; for(int i=0; i<2; ++i) { bool test_predicate = (i!=0); try { assert::is(test_predicate,"using typedef assert"); test_predicate = !test_predicate; assert::is(test_predicate); } catch(std::exception& ex) { std::cout << "\n " << ex.what(); } } std::cout << "\n\n"; } #endif