From 7a219c68bae6dbe214aec69a051015e851e32400 Mon Sep 17 00:00:00 2001 From: "Kartik K. Agaram" Date: Thu, 12 Oct 2017 23:55:19 -0700 Subject: 4054 --- html/subx/002test.cc.html | 54 +++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 27 deletions(-) (limited to 'html/subx/002test.cc.html') diff --git a/html/subx/002test.cc.html b/html/subx/002test.cc.html index a2a785f4..85be9d1a 100644 --- a/html/subx/002test.cc.html +++ b/html/subx/002test.cc.html @@ -74,19 +74,19 @@ if ('onhashchange' in window) { 12 typedef void (*test_fn)(void); 13 :(before "Globals") 14 // move a global ahead into types that we can't generate an extern declaration for - 15 const test_fn Tests[] = { + 15 const test_fn Tests[] = { 16 #include "test_list" // auto-generated; see 'build' script 17 }; 18 19 :(before "End Globals") - 20 bool Run_tests = false; - 21 bool Passed = true; // set this to false inside any test to indicate failure + 20 bool Run_tests = false; + 21 bool Passed = true; // set this to false inside any test to indicate failure 22 23 :(before "End Includes") 24 #define CHECK(X) \ 25 if (Passed && !(X)) { \ 26 ¦ cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): " << #X << '\n'; \ - 27 ¦ Passed = false; \ + 27 ¦ Passed = false; \ 28 ¦ return; /* Currently we stop at the very first failure. */ \ 29 } 30 @@ -94,20 +94,20 @@ if ('onhashchange' in window) { 32 if (Passed && (X) != (Y)) { \ 33 ¦ cerr << "\nF - " << __FUNCTION__ << "(" << __FILE__ << ":" << __LINE__ << "): " << #X << " == " << #Y << '\n'; \ 34 ¦ cerr << " got " << (X) << '\n'; /* BEWARE: multiple eval */ \ - 35 ¦ Passed = false; \ + 35 ¦ Passed = false; \ 36 ¦ return; /* Currently we stop at the very first failure. */ \ 37 } 38 39 :(before "End Reset") - 40 Passed = true; + 40 Passed = true; 41 42 :(before "End Commandline Parsing") - 43 if (argc > 1 && is_equal(argv[1], "test")) { - 44 Run_tests = true; --argc; ++argv; // shift 'test' out of commandline args + 43 if (argc > 1 && is_equal(argv[1], "test")) { + 44 Run_tests = true; --argc; ++argv; // shift 'test' out of commandline args 45 } 46 47 :(before "End Main") - 48 if (Run_tests) { + 48 if (Run_tests) { 49 // Test Runs 50 // we run some tests and then exit; assume no state need be maintained afterward 51 @@ -115,10 +115,10 @@ if ('onhashchange' in window) { 53 // End Test Run Initialization 54 time_t t; time(&t); 55 cerr << "C tests: " << ctime(&t); - 56 for (size_t i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) { + 56 for (size_t i=0; i < sizeof(Tests)/sizeof(Tests[0]); ++i) { 57 //? cerr << "running .build/test_list line " << (i+1) << '\n'; - 58 ¦ run_test(i); - 59 ¦ if (Passed) cerr << '.'; + 58 ¦ run_test(i); + 59 ¦ if (Passed) cerr << '.'; 60 ¦ else ++num_failures; 61 } 62 cerr << '\n'; @@ -133,25 +133,25 @@ if ('onhashchange' in window) { 71 } 72 73 :(code) - 74 void run_test(size_t i) { - 75 if (i >= sizeof(Tests)/sizeof(Tests[0])) { - 76 ¦ cerr << "no test " << i << '\n'; + 74 void run_test(size_t i) { + 75 if (i >= sizeof(Tests)/sizeof(Tests[0])) { + 76 ¦ cerr << "no test " << i << '\n'; 77 ¦ return; 78 } - 79 reset(); + 79 reset(); 80 // End Test Setup 81 (*Tests[i])(); 82 // End Test Teardown 83 } 84 - 85 bool is_integer(const string& s) { + 85 bool is_integer(const string& s) { 86 return s.find_first_not_of("0123456789-") == string::npos // no other characters 87 ¦ ¦ && s.find_first_of("0123456789") != string::npos // at least one digit 88 ¦ ¦ && s.find('-', 1) == string::npos; // '-' only at first position 89 } 90 - 91 int to_integer(string n) { - 92 char* end = NULL; + 91 int to_integer(string n) { + 92 char* end = NULL; 93 // safe because string.c_str() is guaranteed to be null-terminated 94 int result = strtoll(n.c_str(), &end, /*any base*/0); 95 if (*end != '\0') cerr << "tried to convert " << n << " to number\n"; @@ -159,14 +159,14 @@ if ('onhashchange' in window) { 97 return result; 98 } 99 -100 void test_is_integer() { -101 CHECK(is_integer("1234")); -102 CHECK(is_integer("-1")); -103 CHECK(!is_integer("234.0")); -104 CHECK(is_integer("-567")); -105 CHECK(!is_integer("89-0")); -106 CHECK(!is_integer("-")); -107 CHECK(!is_integer("1e3")); // not supported +100 void test_is_integer() { +101 CHECK(is_integer("1234")); +102 CHECK(is_integer("-1")); +103 CHECK(!is_integer("234.0")); +104 CHECK(is_integer("-567")); +105 CHECK(!is_integer("89-0")); +106 CHECK(!is_integer("-")); +107 CHECK(!is_integer("1e3")); // not supported 108 } 109 110 :(before "End Includes") -- cgit 1.4.1-2-gfad0