]>
git.proxmox.com Git - libgit2.git/blob - tests/core/futils.c
1 #include "clar_libgit2.h"
4 /* Fixture setup and teardown */
5 void test_core_futils__initialize(void)
7 cl_must_pass(p_mkdir("futils", 0777));
10 void test_core_futils__cleanup(void)
12 cl_fixture_cleanup("futils");
15 void test_core_futils__writebuffer(void)
17 git_buf out
= GIT_BUF_INIT
,
18 append
= GIT_BUF_INIT
;
20 /* create a new file */
21 git_buf_puts(&out
, "hello!\n");
22 git_buf_printf(&out
, "this is a %s\n", "test");
24 cl_git_pass(git_futils_writebuffer(&out
, "futils/test-file", O_RDWR
|O_CREAT
, 0666));
26 cl_assert_equal_file(out
.ptr
, out
.size
, "futils/test-file");
28 /* append some more data */
29 git_buf_puts(&append
, "And some more!\n");
30 git_buf_put(&out
, append
.ptr
, append
.size
);
32 cl_git_pass(git_futils_writebuffer(&append
, "futils/test-file", O_RDWR
|O_APPEND
, 0666));
34 cl_assert_equal_file(out
.ptr
, out
.size
, "futils/test-file");
36 git_buf_dispose(&out
);
37 git_buf_dispose(&append
);
40 void test_core_futils__write_hidden_file(void)
45 git_buf out
= GIT_BUF_INIT
, append
= GIT_BUF_INIT
;
48 git_buf_puts(&out
, "hidden file.\n");
49 git_futils_writebuffer(&out
, "futils/test-file", O_RDWR
| O_CREAT
, 0666);
51 cl_git_pass(git_win32__set_hidden("futils/test-file", true));
53 /* append some more data */
54 git_buf_puts(&append
, "And some more!\n");
55 git_buf_put(&out
, append
.ptr
, append
.size
);
57 cl_git_pass(git_futils_writebuffer(&append
, "futils/test-file", O_RDWR
| O_APPEND
, 0666));
59 cl_assert_equal_file(out
.ptr
, out
.size
, "futils/test-file");
61 cl_git_pass(git_win32__hidden(&hidden
, "futils/test-file"));
64 git_buf_dispose(&out
);
65 git_buf_dispose(&append
);