This source file includes following definitions.
- my_exit
- 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 setenv ("TERM", "", 1);
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_non_xterm)
63 {
64
65 setenv ("TERM", "gnome-terminal", 1);
66
67
68 const gboolean actual_result_force_false = tty_check_xterm_compat (FALSE);
69 const gboolean actual_result_force_true = tty_check_xterm_compat (TRUE);
70
71
72 ck_assert_int_eq (my_exit__status__captured, 0);
73 ck_assert_int_eq (actual_result_force_false, 0);
74 ck_assert_int_eq (actual_result_force_true, 1);
75 }
76 END_TEST
77
78
79 START_TEST (test_tty_check_term_xterm_like)
80 {
81
82 setenv ("TERM", "alacritty-terminal", 1);
83
84
85 const gboolean actual_result_force_false = tty_check_xterm_compat (FALSE);
86 const gboolean actual_result_force_true = tty_check_xterm_compat (TRUE);
87
88
89 ck_assert_int_eq (my_exit__status__captured, 0);
90 ck_assert_int_eq (actual_result_force_false, 1);
91 ck_assert_int_eq (actual_result_force_true, 1);
92 }
93 END_TEST
94
95
96
97 int
98 main (void)
99 {
100 TCase *tc_core;
101
102 tc_core = tcase_create ("Core");
103
104
105 tcase_add_test (tc_core, test_tty_check_term_unset);
106 tcase_add_test (tc_core, test_tty_check_term_non_xterm);
107 tcase_add_test (tc_core, test_tty_check_term_xterm_like);
108
109
110 return mctest_run_all (tc_core);
111 }
112
113