diff options
author | Kartik K. Agaram <vc@akkartik.com> | 2015-04-22 13:35:47 -0700 |
---|---|---|
committer | Kartik K. Agaram <vc@akkartik.com> | 2015-04-22 13:35:47 -0700 |
commit | 9e608a7704e79834d7a5a314cec6fe3a5f153711 (patch) | |
tree | f182a970b543a24d3fa074d22592e9c4ca288080 /cpp | |
parent | b39ceb27794272100154b88b6d50195d1dca0431 (diff) | |
download | mu-9e608a7704e79834d7a5a314cec6fe3a5f153711.tar.gz |
1134
Diffstat (limited to 'cpp')
-rw-r--r-- | cpp/002test | 18 | ||||
-rw-r--r-- | cpp/050scenario | 46 |
2 files changed, 29 insertions, 35 deletions
diff --git a/cpp/002test b/cpp/002test index 6f0fcaa8..465f213f 100644 --- a/cpp/002test +++ b/cpp/002test @@ -48,7 +48,12 @@ if (Run_tests) { // we run some tests and then exit; assume no state need be maintained afterward // End Test Run Initialization - run_tests(); + time_t t; time(&t); + cerr << "C tests: " << ctime(&t); + for (size_t i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) { + run_test(i); + } + // End Tests cerr << '\n'; if (Num_failures > 0) cerr << Num_failures << " failure" @@ -58,15 +63,6 @@ if (Run_tests) { } :(code) -void run_tests() { - time_t t; time(&t); - cerr << "C tests: " << ctime(&t); - for (size_t i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) { - run_test(i); - } - // End Tests -} - void run_test(size_t i) { if (i >= sizeof(Tests)/sizeof(Tests[0])) { cerr << "no test " << i << '\n'; @@ -77,8 +73,6 @@ void run_test(size_t i) { // End Test Setup (*Tests[i])(); if (Passed) cerr << "."; - // Test Teardown - // End Test Teardown } bool is_number(const string& s) { diff --git a/cpp/050scenario b/cpp/050scenario index 9b5b74bb..247bb0c1 100644 --- a/cpp/050scenario +++ b/cpp/050scenario @@ -17,33 +17,33 @@ vector<scenario> Scenarios; :(before "End Tests") time_t mu_time; time(&mu_time); cerr << "\nMu tests: " << ctime(&mu_time); -run_mu_tests(); +for (size_t i = 0; i < Scenarios.size(); ++i) { + run_mu_test(i); +} :(code) -void run_mu_tests() { - for (size_t i = 0; i < Scenarios.size(); ++i) { - setup(); - Trace_file = Scenarios[i].name; - START_TRACING_UNTIL_END_OF_SCOPE - if (!Scenarios[i].dump_layer.empty()) - Trace_stream->dump_layer = Scenarios[i].dump_layer; -//? cerr << "AAA " << Scenarios[i].name << '\n'; //? 1 -//? cout << Scenarios[i].to_run; //? 2 - run(Scenarios[i].to_run); -//? cout << "after: " << Memory[1] << '\n'; //? 1 -//? cout << "After:\n"; dump_memory(); //? 1 - for (map<int, int>::iterator p = Scenarios[i].memory_expectations.begin(); - p != Scenarios[i].memory_expectations.end(); - ++p) { - if (Memory[p->first] != p->second) { - // todo: unit tests for the test parsing infrastructure; use raise? - cerr << Scenarios[i].name << ": Expected location " << p->first << " to contain " << p->second << " but saw " << Memory[p->first] << '\n'; - Passed = false; - } +void run_mu_test(size_t i) { + setup(); + Trace_file = Scenarios[i].name; + START_TRACING_UNTIL_END_OF_SCOPE + if (!Scenarios[i].dump_layer.empty()) + Trace_stream->dump_layer = Scenarios[i].dump_layer; +//? cerr << "AAA " << Scenarios[i].name << '\n'; //? 1 +//? cout << Scenarios[i].to_run; //? 2 + run(Scenarios[i].to_run); +//? cout << "after: " << Memory[1] << '\n'; //? 1 +//? cout << "after:\n"; dump_memory(); //? 1 + for (map<int, int>::iterator p = Scenarios[i].memory_expectations.begin(); + p != Scenarios[i].memory_expectations.end(); + ++p) { + if (Memory[p->first] != p->second) { + // todo: unit tests for the test parsing infrastructure; use raise? + cerr << Scenarios[i].name << ": Expected location " << p->first << " to contain " << p->second << " but saw " << Memory[p->first] << '\n'; + Passed = false; } - // End Scenario Checks - if (Passed) cerr << "."; } + // End Scenario Checks + if (Passed) cerr << "."; } //:: How we create Scenarios. |