Lines Matching refs:io
13 #include <api/io.h>
58 size_t buf_size, struct io *io)
63 io->fd = open(path, O_RDONLY);
64 if (io->fd < 0) {
69 io->buf = malloc(buf_size);
70 if (io->buf == NULL) {
72 close(io->fd);
76 io__init(io, io->fd, io->buf, buf_size);
80 static void cleanup_test(char path[PATH_MAX], struct io *io)
82 free(io->buf);
83 close(io->fd);
90 struct io io;
94 if (setup_test(path, test_string, buf_size, &io))
98 ch = io__get_char(&io);
101 EXPECT_EQUAL(io.eof, false);
103 ch = io__get_char(&io);
105 EXPECT_EQUAL(io.eof, true);
107 cleanup_test(path, &io);
137 struct io io;
141 if (setup_test(path, test_string, 4, &io))
144 ch = io__get_hex(&io, &hex);
148 ch = io__get_hex(&io, &hex);
152 ch = io__get_hex(&io, &hex);
156 EXPECT_EQUAL(io.eof, end_eof);
158 cleanup_test(path, &io);
218 struct io io;
222 if (setup_test(path, test_string, 4, &io))
225 ch = io__get_dec(&io, &dec);
229 ch = io__get_dec(&io, &dec);
233 ch = io__get_dec(&io, &dec);
237 EXPECT_EQUAL(io.eof, end_eof);
239 cleanup_test(path, &io);