int main() { test_macros(); test_functions(); return 0; }
int main(int argc, char** argv) { test_functions(); std::cout << "this executable doesn't use cuda code, just call methods defined" << std::endl; std::cout << "in object files that have cuda code" << std::endl; return 0; }
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; }
int main(int argc, char **argv) { double *numbers; int i, j, n, r, o; int compare_mode = 0; int nopdiffs = 0, nansdiffs = 0, nxdiffs = 0, nclsdiffs = 0; int *numansdiffs, opansdiffs[4] = {0, 0, 0, 0}; int rndansdiffs[4] = {0, 0, 0, 0}; int *numxdiffs, opxdiffs[4] = {0, 0, 0, 0}, rndxdiffs[4] = {0, 0, 0, 0}; int *numt, opt[4] = {0, 0, 0, 0}, rndt[4] = {0, 0, 0, 0}; int oprndansdiffs[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int oprndxdiffs[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; int oprndt[16] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; char *compare_file; FILE *fp = NULL; if(argc == 1) { fprintf(stderr, "Usage: %s [-test | -cmp <file> | <list of floats....>]\n", argv[0]); exit(1); } if(argc >= 2) { if(strcmp(argv[1], "-cmp") == 0) { if(argc < 3) { fprintf(stderr, "You must supply a file to compare with\n"); exit(1); } else if(argc > 3) { fprintf(stderr, "WARNING: ignoring arguments after %s\n", argv[3]); } compare_mode = 1; compare_file = argv[2]; fp = fopen(compare_file, "r"); if(fp == NULL) { fprintf(stderr, "Error opening comparison file "); perror(compare_file); abort(); } } else if(strcmp(argv[1], "-test") == 0) { return test_functions(); } } if(compare_mode) { if(fscanf(fp, "Numbers: %d", &n) != 1) { printf("Problem reading comparison file %s\n", compare_file); abort(); } } else { n = argc - 1; printf("Numbers: %d\n", n); } numbers = malloc(n * sizeof(double)); if(numbers == NULL) { perror("Memory allocation"); abort(); } numansdiffs = malloc(n * sizeof(int)); if(numansdiffs == NULL) { perror("Memory allocation"); abort(); } numxdiffs = malloc(n * sizeof(int)); if(numxdiffs == NULL) { perror("Memory allocation"); abort(); } numt = malloc(n * sizeof(int)); if(numt == NULL) { perror("Memory allocation"); abort(); } for(i = 0; i < n; i++) { if(compare_mode) { if(fscanf(fp, "%lf", &numbers[i]) != 1) { printf("Problem reading comparison file %s\n", compare_file); abort(); } } else { numbers[i] = atof(argv[i + 1]); printf("%s\n", argv[i + 1]); } numansdiffs[i] = 0; numxdiffs[i] = 0; numt[i] = 0; } for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { for(o = 0; o <= 3; o++) { for(r = 0; r <= 3; r++) { int pansdiffs = nansdiffs; int pxdiffs = nxdiffs; op(numbers[i], numbers[j], o, r, fp, &nopdiffs, &nansdiffs, &nxdiffs, &nclsdiffs); if(pansdiffs != nansdiffs) { numansdiffs[i]++; numansdiffs[j]++; opansdiffs[o]++; rndansdiffs[r]++; oprndansdiffs[(o * 4) + r]++; } if(pxdiffs != nxdiffs) { numxdiffs[i]++; numxdiffs[j]++; opxdiffs[o]++; rndxdiffs[r]++; oprndxdiffs[(o * 4) + r]++; } numt[i]++; numt[j]++; opt[o]++; rndt[r]++; oprndt[(o * 4) + r]++; } } } } if(compare_mode) { fclose(fp); printf("Summary of differences between comparison file and this run:\n"); printf("\t(Each is a count of the number of calculations concerned)\n"); printf("\t%d\t-- different representation of one or more operands\n", nopdiffs); printf("\t%d\t-- different answer where operands represented the same\n", nansdiffs); printf("\t%d\t-- different exceptions where answer the same\n", nxdiffs); printf("\t%d\t-- different fpclasses where answer the same\n", nclsdiffs); printf("Breakdown of differences by number, operator and rounding " "direction:\n"); printf("\t% 8s % 15s % 6s % 9s % 5s\n", "Type", "Data", "Answer", "Exception", "Total"); for(i = 0; i < n; i++) { printf("\t% 8s % 15g % 6d % 9d % 5d\n", "Number", numbers[i], numansdiffs[i], numxdiffs[i], numt[i]); } for(i = 0; i < 4; i++) { printf("\t% 8s % 15s % 6d % 9d % 5d\n", "Operator", operators[i], opansdiffs[i], opxdiffs[i], opt[i]); } for(i = 0; i < 4; i++) { printf("\t% 8s % 15s % 6d % 9d % 5d\n", "Round", rnddir[i], rndansdiffs[i], rndxdiffs[i], rndt[i]); } for(o = 0; o < 4; o++) { for(r = 0; r < 4; r++) { printf("\t% 8s % 14s%s % 6d % 9d % 5d\n", "Op&Round", operators[o], rnddir[r], oprndansdiffs[(o * 4) + r], oprndxdiffs[(o * 4) + r], oprndt[(o * 4) + r]); } } } free(numbers); free(numansdiffs); free(numxdiffs); free(numt); return 0; }