utility.c
来自「db.* (pronounced dee-be star) is an adva」· C语言 代码 · 共 65 行
C
65 行
/****************************************************************************** * * db.* * Test Suite * * Utility variables and functions * *****************************************************************************/#include <stdio.h>#include <stdlib.h>#include "test.h"#include "utility.h"#include "db.star.h"#include "dbtype.h"#include "testdb.h"/* Perform a single subset of tests */void perform_tests(struct unit_test tests[], int num_tests){ DB_TASK *Currtask; /* for loop through tests */ int i = 0; for (i = 0; i < num_tests; i++) { /* setup the database initialized to have no data within it*/ if (d_opentask(&Currtask) != S_OKAY || d_sopen(&testdb_dbd, "o", Currtask) != S_OKAY || d_initialize(Currtask, CURR_DB) != S_OKAY) { printf("errno: %d\n", errno); perror("Failed to open database"); alltestspass = FALSE; exit(EXIT_FAILURE); } /* run test */ bool pass = tests[i].f(Currtask); if(!pass) alltestspass = FALSE; /* print result */ print_result(tests[i].name, pass); /* tear down database */ d_close(Currtask); d_closetask(Currtask); }}/* Nicely format the results of a test */void print_result(char* test_name, bool pass){ if(pass) { printf(" %-30s PASSED\n", test_name); } else { printf(" %-30s FAILED\n", test_name); }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?