diff options
| author | jakob <jakob@memeware.net> | 2017-02-14 18:47:57 -0500 |
|---|---|---|
| committer | jakob <jakob@memeware.net> | 2017-02-14 18:47:57 -0500 |
| commit | 1fc6cc323dbaa5387d84630615c0d4cab0c1c5ba (patch) | |
| tree | c94a738cb6d7f06fde68fc0765ccfd6a6dd19f4b /test/test_io.c | |
| parent | 01d185f31ff7194773342881fa0e0a550b5d5c5a (diff) | |
Implemented a basic parser for the XP3 header.
Diffstat (limited to 'test/test_io.c')
| -rw-r--r-- | test/test_io.c | 30 |
1 files changed, 17 insertions, 13 deletions
diff --git a/test/test_io.c b/test/test_io.c index 8bf7593..fd1e483 100644 --- a/test/test_io.c +++ b/test/test_io.c @@ -1,4 +1,4 @@ -/* test_io.c -- MinUnit test cases for I/O related functions. +/* test_io.c -- MinUnit test cases for io.c Copyright (C) 2017 Jakob Tsar-Fox, All Rights Reserved. @@ -17,36 +17,40 @@ You should have received a copy of the GNU General Public License along with Nekopack. If not, see <http://www.gnu.org/licenses/>. */ -#include <stdio.h> #include <string.h> #include "minunit.h" #include "io.h" -int tests_run = 0; +extern int tests_run; -static char *test_stream_obj(void) { +char *test_stream_obj(void) { struct stream *s_1 = stream_new(0x10); struct stream *s_2 = stream_new(0x20); struct stream *s_3 = stream_new(0x40); - mu_assert("Incorrect size for `s_1`", s_1.len == 0x10); - mu_assert("Incorrect size for `s_2`", s_1.len == 0x20); - mu_assert("Incorrect size for `s_3`", s_1.len == 0x40); + mu_assert("Incorrect size for `s_1`", s_1->len == 0x10); + mu_assert("Incorrect size for `s_2`", s_2->len == 0x20); + mu_assert("Incorrect size for `s_3`", s_3->len == 0x40); stream_free(s_1); stream_free(s_2); stream_free(s_3); + return NULL; } -static char *test_stream_rw(void) { +char *test_stream_rw(void) { char dest[4]; - struct stream *s_1 = stream_new(0x4); - stream_write(s_1, "\x00\x01\x02\x03", 4); - mu_assert("Write failure", !memcmp(s_1->_start, "\x00\x01\x02\x03", 4)); - mu_assert("Cursor not incremented", s_1->cur - s_1->start == 4); + struct stream *s = stream_new(0x4); + stream_write(s, "\x00\x01\x02\x03", 4); + mu_assert("Write failure", !memcmp(s->_start, "\x00\x01\x02\x03", 4)); + mu_assert("Cursor not incremented", s->_cur - s->_start == 4); + s->_cur = s->_start; + stream_read(dest, s, 4); mu_assert("Read failure", !memcmp(dest, "\x00\x01\x02\x03", 4)); - stream_free(s_1); + mu_assert("Cursor not incremented", s->_cur - s->_start == 4); + stream_free(s); + return NULL; } |