Lines Matching refs:io
13 #include <api/io.h>
59 size_t buf_size, struct io *io)
64 io->fd = open(path, O_RDONLY);
65 if (io->fd < 0) {
70 io->buf = malloc(buf_size);
71 if (io->buf == NULL) {
73 close(io->fd);
77 io__init(io, io->fd, io->buf, buf_size);
81 static void cleanup_test(char path[PATH_MAX], struct io *io)
83 zfree(&io->buf);
84 close(io->fd);
91 struct io io;
95 if (setup_test(path, test_string, buf_size, &io))
99 ch = io__get_char(&io);
102 EXPECT_EQUAL(io.eof, false);
104 ch = io__get_char(&io);
106 EXPECT_EQUAL(io.eof, true);
108 cleanup_test(path, &io);
138 struct io io;
142 if (setup_test(path, test_string, 4, &io))
145 ch = io__get_hex(&io, &hex);
149 ch = io__get_hex(&io, &hex);
153 ch = io__get_hex(&io, &hex);
157 EXPECT_EQUAL(io.eof, end_eof);
159 cleanup_test(path, &io);
219 struct io io;
223 if (setup_test(path, test_string, 4, &io))
226 ch = io__get_dec(&io, &dec);
230 ch = io__get_dec(&io, &dec);
234 ch = io__get_dec(&io, &dec);
238 EXPECT_EQUAL(io.eof, end_eof);
240 cleanup_test(path, &io);
296 struct io io;
310 if (setup_test(path, test_string, buf_size, &io))
313 EXPECT_EQUAL((int)io__getline(&io, &line, &line_len), 513);
318 EXPECT_EQUAL((int)io__getline(&io, &line, &line_len), 510);
323 cleanup_test(path, &io);
343 DEFINE_SUITE("Test api io", api_io);