forked from sumatrapdfreader/sumatrapdf
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUtAssert.cpp
More file actions
46 lines (38 loc) · 1.17 KB
/
Copy pathUtAssert.cpp
File metadata and controls
46 lines (38 loc) · 1.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
/* Copyright 2015 the SumatraPDF project authors (see AUTHORS file).
License: Simplified BSD (see COPYING.BSD) */
#include "BaseUtil.h"
#include "UtAssert.h"
static int g_nTotal = 0;
static int g_nFailed = 0;
#define MAX_FAILED_ASSERTS 32
struct FailedAssert {
const char *exprStr;
const char *file;
int lineNo;
};
static FailedAssert g_failedAssert[MAX_FAILED_ASSERTS];
void utassert_func(bool ok, const char *exprStr, const char *file, int lineNo)
{
++g_nTotal;
if (ok)
return;
if (g_nFailed < MAX_FAILED_ASSERTS) {
g_failedAssert[g_nFailed].exprStr = exprStr;
g_failedAssert[g_nFailed].file = file;
g_failedAssert[g_nFailed].lineNo = lineNo;
}
++g_nFailed;
}
int utassert_print_results()
{
if (0 == g_nFailed) {
printf("Passed all %d tests\n", g_nTotal);
return 0;
}
fprintf(stderr, "Failed %d (of %d) tests\n", g_nFailed, g_nTotal);
for (int i=0; i < g_nFailed && i < MAX_FAILED_ASSERTS; i++) {
FailedAssert *a = &(g_failedAssert[i]);
fprintf(stderr, "'%s' %s@%d\n", a->exprStr, a->file, a->lineNo);
}
return g_nFailed;
}