MCPcopy Create free account
hub / github.com/git/git / test_reftable_stack__read_file

Function test_reftable_stack__read_file

t/unit-tests/u-reftable-stack.c:77–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

75}
76
77void test_reftable_stack__read_file(void)
78{
79 char *fn = get_tmp_template(__LINE__);
80 struct tempfile *tmp = mks_tempfile(fn);
81 int fd = get_tempfile_fd(tmp);
82 char out[1024] = "line1\n\nline2\nline3";
83 int n, err;
84 char **names = NULL;
85 const char *want[] = { "line1", "line2", "line3" };
86
87 cl_assert(fd > 0);
88 n = write_in_full(fd, out, strlen(out));
89 cl_assert_equal_i(n, strlen(out));
90 err = close(fd);
91 cl_assert(err >= 0);
92
93 err = read_lines(fn, &names);
94 cl_assert(!err);
95
96 for (size_t i = 0; names[i]; i++)
97 cl_assert_equal_s(want[i], names[i]);
98 free_names(names);
99 (void) remove(fn);
100 delete_tempfile(&tmp);
101}
102
103static int write_test_ref(struct reftable_writer *wr, void *arg)
104{

Callers

nothing calls this directly

Calls 7

get_tmp_templateFunction · 0.85
mks_tempfileFunction · 0.85
get_tempfile_fdFunction · 0.85
write_in_fullFunction · 0.85
read_linesFunction · 0.85
free_namesFunction · 0.85
delete_tempfileFunction · 0.85

Tested by

no test coverage detected