-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgenerate-tests.py
More file actions
107 lines (82 loc) · 2.34 KB
/
generate-tests.py
File metadata and controls
107 lines (82 loc) · 2.34 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
def format_color(color):
to_remove = ["fg_", "bg_"]
for r in to_remove:
color = color.replace(r, "")
color = color.replace("_", " ")
color = color.lower()
return f"Color: {color}"
def main():
fg = [
"fg_BLACK",
"fg_RED",
"fg_GREEN",
"fg_YELLOW",
"fg_BLUE",
"fg_MAGENTA",
"fg_CYAN",
"fg_WHITE",
"fg_DEFAULT"]
bright_fg = [
"fg_BRIGHT_BLACK",
"fg_BRIGHT_RED",
"fg_BRIGHT_GREEN",
"fg_BRIGHT_YELLOW",
"fg_BRIGHT_BLUE",
"fg_BRIGHT_MAGENTA",
"fg_BRIGHT_CYAN",
"fg_BRIGHT_WHITE",
]
bg = [
"bg_BLACK",
"bg_RED",
"bg_GREEN",
"bg_YELLOW",
"bg_BLUE",
"bg_MAGENTA",
"bg_CYAN",
"bg_WHITE",
"bg_DEFAULT"]
bright_bg = [
"bg_BRIGHT_BLACK",
"bg_BRIGHT_RED",
"bg_BRIGHT_GREEN",
"bg_BRIGHT_YELLOW",
"bg_BRIGHT_BLUE",
"bg_BRIGHT_MAGENTA",
"bg_BRIGHT_CYAN",
"bg_BRIGHT_WHITE"
]
spacing = 1
c_code = ""
c_code += " /* test foreground colors */\n"
for i, color in enumerate(fg):
f_color = format_color(color)
if len(f_color) > spacing:
spacing = len(f_color) + 1
c_code += f"move_cursor_to(0, {i});\n"
c_code += f"set_fg({color});\n"
c_code += f"printf(\"{f_color}\");\n\n"
for i, color in enumerate(bright_fg):
f_color = format_color(color)
c_code += f"move_cursor_to({spacing}, {i});\n"
c_code += f"set_fg({color});\n"
c_code += f"printf(\"{f_color}\");\n\n"
spacing = 1
c_code += "reset_fg();\n"
c_code += " /* test background colors */\n"
for i, color in enumerate(bg):
f_color = format_color(color)
if len(f_color) > spacing:
spacing = len(f_color) + 1
c_code += f"move_cursor_to(0, {i+9});\n"
c_code += f"set_bg({color});\n"
c_code += f"printf(\"{f_color}\");\n\n"
for i, color in enumerate(bright_bg):
f_color = format_color(color)
c_code += f"move_cursor_to({spacing}, {i+9});\n"
c_code += f"set_bg({color});\n"
c_code += f"printf(\"{f_color}\");\n\n"
c_code += "printf(\"\\n\");\n"
print(c_code, end="")
if __name__ == "__main__":
main()