dte test coverage


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 50.0% high: ≥ 85.0%
Coverage Exec / Excl / Total
Lines: 0.0% 0 / 0 / 10
Functions: 0.0% 0 / 0 / 1
Branches: 0.0% 0 / 0 / 4

test/sizes.h
Line Branch Exec Source
1 #ifndef TEST_SIZES_H
2 #define TEST_SIZES_H
3
4 #include <stdio.h>
5 #include "command/cache.h"
6 #include "command/run.h"
7 #include "compiler.h"
8 #include "editor.h"
9 #include "editorconfig/editorconfig.h"
10 #include "editorconfig/ini.h"
11 #include "indent.h"
12 #include "load-save.h"
13 #include "regexp.h"
14 #include "selection.h"
15 #include "spawn.h"
16 #include "syntax/syntax.h"
17 #include "terminal/parse.h"
18 #include "terminal/terminal.h"
19 #include "ui.h"
20 #include "util/exitcode.h"
21 #include "util/macros.h"
22
23 #define entry(type, level) { \
24 .name = #type, \
25 .size = sizeof(type), \
26 .indent_level = level \
27 }
28
29 #define S(type) entry(type, 0)
30 #define S1(type) entry(type, 1)
31 #define S2(type) entry(type, 2)
32 #define DIVIDER {NULL, 0, 0}
33
34 static const struct {
35 const char *name;
36 unsigned int size;
37 uint8_t indent_level;
38 } ssizes[] = {
39 S(EditorState),
40 S1(Terminal),
41 S2(TermOutputBuffer),
42 S2(TermInputBuffer),
43 S1(ErrorBuffer),
44 S1(StyleMap),
45 S2(TermStyle),
46 S1(CommandLine),
47 S2(CompletionState),
48 S1(Clipboard),
49 S1(FileHistory),
50 S1(FileLocksContext),
51 S1(GlobalOptions),
52 S1(History),
53 S1(MacroRecorder),
54 S1(MessageList),
55 S1(ModeHandler),
56 S1(SearchState),
57 S1(SyntaxLoader),
58 S1(TagFile),
59
60 DIVIDER,
61 S(Buffer),
62 S1(FileInfo),
63 S1(Change),
64 S1(LocalOptions),
65
66 DIVIDER,
67 S(View),
68 S1(BlockIter),
69
70 DIVIDER,
71 S(Window),
72 S(Frame),
73 S(Block),
74
75 DIVIDER,
76 S(Command),
77 S(CachedCommand),
78 S1(CommandArgs),
79 S(CommandRunner),
80 S(CommandSet),
81
82 DIVIDER,
83 S(Syntax),
84 S(State),
85 S(Condition),
86 S1(ConditionData),
87 S1(Action),
88 S(HeredocState),
89 S(StringList),
90
91 DIVIDER,
92 S(Compiler),
93 S(EditorConfigOptions),
94 S(ErrorFormat),
95 S(FileHistoryEntry),
96 S(FileLocation),
97 S(FileSaveContext),
98 S(HistoryEntry),
99 S(IndentInfo),
100 S(IniParser),
101 S(InternedRegexp),
102 S1(regex_t),
103 S(Message),
104 S(ScreenState),
105 S(SelectionInfo),
106 S(SpawnContext),
107 S(Tag),
108 S(TermControlParams),
109 S(TermCursorStyle),
110 };
111
112 /*
113 For a list of typedef'd struct names, see:
114
115 make tags && readtags -lF '(if
116 (and (eq? $kind "t") (prefix? $typeref "struct"))
117 (list $name #t)
118 #f
119 )'
120
121 See also:
122 • make print-struct-sizes
123 • build/test/test -h
124 • build/test/test -s
125 */
126
127 static inline ExitCode print_struct_sizes(void)
128 {
129 puts (
130 "\n"
131 "---------------------------------\n"
132 " Struct Size\n"
133 "---------------------------------"
134 );
135
136 for (size_t i = 0; i < ARRAYLEN(ssizes); i++) {
137 const char *name = ssizes[i].name;
138 int indent = 3 * ssizes[i].indent_level;
139 if (name) {
140 printf("%*s %-*s %5u\n", indent, "", 24 - indent, name, ssizes[i].size);
141 } else {
142 putchar('\n');
143 }
144 }
145
146 putchar('\n');
147 return EC_OK;
148 }
149
150 #endif
151