65 {
66 std::string msg;
67 try {
68 if (init_) init_();
69 for (UnitTestList::const_iterator i = list_.begin(), ie = list_.end(); i != ie; ++i) {
70 std::cout << "ctest:module=" << i->first << std::endl;
71 try {
72 (i->second)();
73 } catch (std::exception& e) {
74 exceptionCount_++;
75 std::cout << "ctest: " << i->first << " is stopped by exception " << e.what() << std::endl;
76 } catch (...) {
77 exceptionCount_++;
78 std::cout << "ctest: " << i->first << " is stopped by unknown exception" << std::endl;
79 }
80 }
81 if (term_) term_();
82 } catch (std::exception& e) {
83 msg = std::string("ctest:err:") + e.what();
84 } catch (...) {
85 msg = "ctest:err: catch unknown exception";
86 }
87 fflush(stdout);
88 if (msg.empty()) {
89 int err = ngCount_ + exceptionCount_;
90 int total = okCount_ + err;
92 << ", module=" << list_.size()
93 << ", total=" << total
94 << ", ok=" << okCount_
95 << ", ng=" << ngCount_
96 << ", exception=" << exceptionCount_ << std::endl;
97 return err > 0 ? 1 : 0;
98 } else {
99 std::cout << msg << std::endl;
100 return 1;
101 }
102 }