Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | QAbstractTestLogger::QAbstractTestLogger(const char *filename) | - |
5 | { | - |
6 | if (!filename) { partially evaluated: !filename yes Evaluation Count:399 | no Evaluation Count:0 |
| 0-399 |
7 | stream = stdout; | - |
8 | return; executed: return; Execution Count:399 | 399 |
9 | } | - |
10 | | - |
11 | | - |
12 | | - |
13 | stream = ::fopen(filename, "wt"); | - |
14 | if (!stream) { | 0 |
15 | | - |
16 | fprintf(stderr, "Unable to open file for logging: %s\n", filename); | - |
17 | ::exit(1); never executed: ::exit(1); | 0 |
18 | } | - |
19 | } | 0 |
20 | | - |
21 | QAbstractTestLogger::~QAbstractTestLogger() | - |
22 | { | - |
23 | do { if (!(stream)) qt_assert("stream","qabstracttestlogger.cpp",76); } while (0); partially evaluated: !(stream) no Evaluation Count:0 | yes Evaluation Count:396 |
never executed: qt_assert("stream","qabstracttestlogger.cpp",76); partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:396 |
executed: } Execution Count:396 | 0-396 |
24 | if (stream != stdout) { partially evaluated: stream != stdout no Evaluation Count:0 | yes Evaluation Count:396 |
| 0-396 |
25 | fclose(stream); | - |
26 | } | 0 |
27 | stream = 0; | - |
28 | } executed: } Execution Count:396 | 396 |
29 | | - |
30 | void QAbstractTestLogger::filterUnprintable(char *str) const | - |
31 | { | - |
32 | char *idx = str; | - |
33 | while (*idx) { evaluated: *idx yes Evaluation Count:4337162 | yes Evaluation Count:69974 |
| 69974-4337162 |
34 | if (((*idx < 0x20 && *idx != '\n' && *idx != '\t') || *idx > 0x7e)) evaluated: *idx < 0x20 yes Evaluation Count:71762 | yes Evaluation Count:4265400 |
evaluated: *idx != '\n' yes Evaluation Count:23 | yes Evaluation Count:71739 |
evaluated: *idx != '\t' yes Evaluation Count:12 | yes Evaluation Count:11 |
partially evaluated: *idx > 0x7e no Evaluation Count:0 | yes Evaluation Count:4337150 |
| 0-4337150 |
35 | *idx = '?'; executed: *idx = '?'; Execution Count:12 | 12 |
36 | ++idx; | - |
37 | } executed: } Execution Count:4337162 | 4337162 |
38 | } executed: } Execution Count:69974 | 69974 |
39 | | - |
40 | void QAbstractTestLogger::outputString(const char *msg) | - |
41 | { | - |
42 | do { if (!(stream)) qt_assert("stream","qabstracttestlogger.cpp",95); } while (0); never executed: qt_assert("stream","qabstracttestlogger.cpp",95); executed: } Execution Count:69974 partially evaluated: !(stream) no Evaluation Count:0 | yes Evaluation Count:69974 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:69974 |
| 0-69974 |
43 | do { if (!(msg)) qt_assert("msg","qabstracttestlogger.cpp",96); } while (0); never executed: qt_assert("msg","qabstracttestlogger.cpp",96); executed: } Execution Count:69974 partially evaluated: !(msg) no Evaluation Count:0 | yes Evaluation Count:69974 |
partially evaluated: 0 no Evaluation Count:0 | yes Evaluation Count:69974 |
| 0-69974 |
44 | | - |
45 | char *filtered = new char[strlen(msg) + 1]; | - |
46 | strcpy(filtered, msg); | - |
47 | filterUnprintable(filtered); | - |
48 | | - |
49 | ::fputs(filtered, stream); | - |
50 | ::fflush(stream); | - |
51 | | - |
52 | delete [] filtered; | - |
53 | } executed: } Execution Count:69974 | 69974 |
54 | | - |
55 | void QAbstractTestLogger::startLogging() | - |
56 | { | - |
57 | } | - |
58 | | - |
59 | void QAbstractTestLogger::stopLogging() | - |
60 | { | - |
61 | } | - |
62 | | - |
63 | namespace QTest | - |
64 | { | - |
65 | | - |
66 | extern void filter_unprintable(char *str); | - |
67 | | - |
68 | | - |
69 | | - |
70 | | - |
71 | | - |
72 | int qt_asprintf(QTestCharBuffer *str, const char *format, ...) | - |
73 | { | - |
74 | static const int MAXSIZE = 1024*1024*2; | - |
75 | | - |
76 | qt_noop(); | - |
77 | | - |
78 | int size = str->size(); | - |
79 | | - |
80 | va_list ap; | - |
81 | int res = 0; | - |
82 | | - |
83 | for (;;) { | - |
84 | __builtin_va_start(ap,format); | - |
85 | res = qvsnprintf(str->data(), size, format, ap); | - |
86 | __builtin_va_end(ap); | - |
87 | str->data()[size - 1] = '\0'; | - |
88 | if (res >= 0 && res < size) { partially evaluated: res >= 0 yes Evaluation Count:69264 | no Evaluation Count:0 |
evaluated: res < size yes Evaluation Count:69171 | yes Evaluation Count:93 |
| 0-69264 |
89 | | - |
90 | break; executed: break; Execution Count:69171 | 69171 |
91 | } | - |
92 | | - |
93 | | - |
94 | size *= 2; | - |
95 | if (size > MAXSIZE) { partially evaluated: size > MAXSIZE no Evaluation Count:0 | yes Evaluation Count:93 |
| 0-93 |
96 | break; | 0 |
97 | } | - |
98 | if (!str->reset(size)) partially evaluated: !str->reset(size) no Evaluation Count:0 | yes Evaluation Count:93 |
| 0-93 |
99 | break; | 0 |
100 | } executed: } Execution Count:93 | 93 |
101 | | - |
102 | return res; executed: return res; Execution Count:69171 | 69171 |
103 | } | - |
104 | | - |
105 | } | - |
106 | | - |
107 | | - |
108 | | - |
| | |