int main() { plan(20); test_uints(); test_ints(); test_bools(); test_floats(); test_doubles(); test_nils(); test_strls(); test_binls(); test_strs(); test_bins(); test_arrays(); test_maps(); test_next_on_arrays(); test_next_on_maps(); test_compare_uints(); test_format(); test_mp_print(); test_mp_check(); test_numbers(); test_overflow(); return check_plan(); }
void TestJson_run_tests() { int num_tests = 107; #ifndef LUCY_VALGRIND num_tests += 28; // FIXME: syntax errors leak memory. #endif TestBatch *batch = TestBatch_new(num_tests); TestBatch_Plan(batch); // Test tolerance, then liberalize for testing. test_tolerance(batch); Json_set_tolerant(true); test_to_and_from(batch); test_escapes(batch); test_numbers(batch); test_spew_and_slurp(batch); test_integers(batch); test_floats(batch); test_max_depth(batch); test_illegal_keys(batch); #ifndef LUCY_VALGRIND test_syntax_errors(batch); #endif DECREF(batch); }
int main() { /* TODO: i guess we need a little bit more coverage here */ test_numbers(); runtest("1,1+T",2<<16); runtest("6,6*T",36<<16); runtest("1,4X3*LT",81<<16); runtest("1,2,3,2)T",1<<16); runtest("3?5:1;T",5<<16); runtest("0?5:1;T",1<<16); return 0; }
void TestJson_Run_IMP(TestJson *self, TestBatchRunner *runner) { uint32_t num_tests = 105; #ifndef LUCY_VALGRIND num_tests += 28; // FIXME: syntax errors leak memory. #endif TestBatchRunner_Plan(runner, (TestBatch*)self, num_tests); // Test tolerance, then liberalize for testing. test_tolerance(runner); Json_set_tolerant(true); test_to_and_from(runner); test_escapes(runner); test_numbers(runner); test_spew_and_slurp(runner); test_integers(runner); test_floats(runner); test_max_depth(runner); #ifndef LUCY_VALGRIND test_syntax_errors(runner); #endif }
int Test::all() { clock_t begin = clock(); exeTime = 0; test_general(); test_types(); test_booleans(); test_numbers(); test_strings(); test_arrays(); test_intervals(); test_map(); test_set(); test_objects(); test_functions(); test_classes(); test_loops(); test_operators(); test_references(); test_exceptions(); test_operations(); test_system(); test_json(); test_files(); test_doc(); test_utils(); double elapsed_secs = double(clock() - begin) / CLOCKS_PER_SEC; int errors = (total - success_count); int leaks = (obj_created - obj_deleted); int mpz_leaks = (mpz_obj_created - mpz_obj_deleted); std::ostringstream line1, line2, line3, line4; line1 << "Total : " << total << ", success : " << success_count << ", errors : " << errors; line2 << "Total time : " << elapsed_secs * 1000 << " ms"; line3 << "Objects destroyed : " << obj_deleted << " / " << obj_created << " (" << leaks << " leaked)"; line4 << "MPZ objects destroyed : " << mpz_obj_deleted << " / " << mpz_obj_created << " (" << mpz_leaks << " leaked)"; unsigned w = std::max(line1.str().size(), std::max(line2.str().size(), std::max(line3.str().size(), line4.str().size()))); auto pad = [](std::string s, int l) { l -= s.size(); while (l-- > 0) s += " "; return s; }; std::cout << "┌"; for (unsigned i = 0; i < w + 2; ++i) std::cout << "─"; std::cout << "┐" << std::endl; std::cout << "│ " << pad(line1.str(), w) << " │" << std::endl; std::cout << "│ " << pad(line2.str(), w) << " │" << std::endl; std::cout << "│ " << pad(line3.str(), w) << " │" << std::endl; std::cout << "│ " << pad(line4.str(), w) << " │" << std::endl; std::cout << "├"; for (unsigned i = 0; i < w + 2; ++i) std::cout << "─"; std::cout << "┤"; std::cout << std::endl; int result = abs(errors) + abs(leaks) + abs(mpz_leaks); if (result == 0) { std::cout << "│ " << pad("GOOD! ✔", w + 2) << " │" << std::endl; } else { std::cout << "│ " << pad("BAD! : " + std::to_string(result) + " error(s) ✘", w + 2) << " │" << std::endl; } std::cout << "└"; for (unsigned i = 0; i < w + 2; ++i) std::cout << "─"; std::cout << "┘" << std::endl; for (const auto& error : failed_tests) { std::cout << " " << error << std::endl; } if (failed_tests.size()) { std::cout << std::endl; } return result; }