This source file includes following definitions.
- my_exit
- START_TEST
- START_TEST
- START_TEST
- START_TEST
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 #define TEST_SUITE_NAME "/lib"
24
25 #include "tests/mctest.h"
26
27 #include <stdio.h>
28
29 #include "lib/strutil.h"
30 #include "lib/util.h"
31
32 #include "lib/tty/tty.h"
33
34
35
36 static int my_exit__status__captured;
37
38
39 void
40 my_exit (int status)
41 {
42 my_exit__status__captured = status;
43 }
44
45
46
47 START_TEST (test_tty_check_term_unset)
48 {
49
50 g_unsetenv ("TERM");
51
52
53 tty_check_xterm_compat (FALSE);
54
55
56 ck_assert_int_eq (my_exit__status__captured, 1);
57 }
58 END_TEST
59
60
61
62 START_TEST (test_tty_check_term_set_empty)
63 {
64
65 g_setenv ("TERM", "", TRUE);
66
67
68 tty_check_xterm_compat (FALSE);
69
70
71 ck_assert_int_eq (my_exit__status__captured, 1);
72 }
73 END_TEST
74
75
76
77 START_TEST (test_tty_check_term_non_xterm)
78 {
79
80 g_setenv ("TERM", "gnome-terminal", TRUE);
81
82
83 const gboolean actual_result_force_false = tty_check_xterm_compat (FALSE);
84 const gboolean actual_result_force_true = tty_check_xterm_compat (TRUE);
85
86
87 ck_assert_int_eq (my_exit__status__captured, 0);
88 mctest_assert_false (actual_result_force_false);
89 mctest_assert_true (actual_result_force_true);
90 }
91 END_TEST
92
93
94 START_TEST (test_tty_check_term_xterm_like)
95 {
96
97 g_setenv ("TERM", "alacritty-terminal", TRUE);
98
99
100 const gboolean actual_result_force_false = tty_check_xterm_compat (FALSE);
101 const gboolean actual_result_force_true = tty_check_xterm_compat (TRUE);
102
103
104 ck_assert_int_eq (my_exit__status__captured, 0);
105 mctest_assert_true (actual_result_force_false);
106 mctest_assert_true (actual_result_force_true);
107 }
108 END_TEST
109
110
111
112 int
113 main (void)
114 {
115 TCase *tc_core;
116
117 tc_core = tcase_create ("Core");
118
119
120 tcase_add_test (tc_core, test_tty_check_term_unset);
121 tcase_add_test (tc_core, test_tty_check_term_set_empty);
122 tcase_add_test (tc_core, test_tty_check_term_non_xterm);
123 tcase_add_test (tc_core, test_tty_check_term_xterm_like);
124
125
126 return mctest_run_all (tc_core);
127 }
128
129