-
-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathquit.c
86 lines (66 loc) · 1.31 KB
/
quit.c
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
#include "libvim.h"
#include "minunit.h"
static int quitCount = 0;
static int lastForce = 0;
static buf_T *lastQuitBuf = 0;
void onQuit(buf_T *buffer, int force)
{
lastQuitBuf = buffer;
lastForce = force;
quitCount++;
}
void test_setup(void)
{
vimExecute("e!");
vimInput("g");
vimInput("g");
quitCount = 0;
}
void test_teardown(void) {}
MU_TEST(test_q)
{
vimExecute("q");
mu_check(quitCount == 1);
mu_check(lastQuitBuf == curbuf);
mu_check(lastForce == FALSE);
}
MU_TEST(test_q_force)
{
vimExecute("q!");
mu_check(quitCount == 1);
mu_check(lastQuitBuf == curbuf);
mu_check(lastForce == TRUE);
}
MU_TEST(test_xall)
{
vimExecute("xall");
mu_check(quitCount == 1);
mu_check(lastQuitBuf == NULL);
mu_check(lastForce == FALSE);
}
MU_TEST(test_xit)
{
vimExecute("xit!");
mu_check(quitCount == 1);
mu_check(lastQuitBuf == curbuf);
mu_check(lastForce == TRUE);
}
MU_TEST_SUITE(test_suite)
{
MU_SUITE_CONFIGURE(&test_setup, &test_teardown);
MU_RUN_TEST(test_q);
MU_RUN_TEST(test_q_force);
MU_RUN_TEST(test_xall);
MU_RUN_TEST(test_xit);
}
int main(int argc, char **argv)
{
vimInit(argc, argv);
vimSetQuitCallback(&onQuit);
win_setwidth(5);
win_setheight(100);
vimBufferOpen("collateral/testfile.txt", 1, 0);
MU_RUN_SUITE(test_suite);
MU_REPORT();
MU_RETURN();
}