summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/test_io.c8
-rw-r--r--test/test_run.c1
-rw-r--r--test/test_table.c17
-rw-r--r--test/test_table.h1
4 files changed, 24 insertions, 3 deletions
diff --git a/test/test_io.c b/test/test_io.c
index 86dde8e..f295182 100644
--- a/test/test_io.c
+++ b/test/test_io.c
@@ -80,8 +80,12 @@ char *test_stream_xor(void) {
char *test_stream_nav(void) {
struct stream *s = stream_new(2);
mu_assert("Cursor not at beginning", stream_tell(s) == 0);
- stream_seek(s, 2);
- mu_assert("Cursor not advanced", stream_tell(s) == 2);
+ stream_seek(s, 2, SEEK_CUR);
+ mu_assert("Cursor not advanced (SEEK_CUR)", stream_tell(s) == 2);
+ stream_seek(s, 2, SEEK_SET);
+ mu_assert("Cursor not advanced (SEEK_SET)", stream_tell(s) == 2);
+ stream_seek(s, 0, SEEK_END);
+ mu_assert("Cursor not advanced (SEEK_END)", stream_tell(s) == 2);
stream_rewind(s);
mu_assert("Cursor not rewinded", stream_tell(s) == 0);
stream_free(s);
diff --git a/test/test_run.c b/test/test_run.c
index 7ec1403..c6930dc 100644
--- a/test/test_run.c
+++ b/test/test_run.c
@@ -36,6 +36,7 @@ static char *run_all_tests(void) {
mu_run_test(test_stream_nav);
mu_run_test(test_header_read);
mu_run_test(test_table_list);
+ mu_run_test(test_table_elif);
return NULL;
}
diff --git a/test/test_table.c b/test/test_table.c
index efdac3d..e6c18b0 100644
--- a/test/test_table.c
+++ b/test/test_table.c
@@ -18,15 +18,16 @@
along with Nekopack. If not, see <http://www.gnu.org/licenses/>. */
#include <stdlib.h>
+#include <string.h>
#include "minunit.h"
+#include "io.h"
#include "table.h"
char *test_table_list(void) {
struct table_entry *root = calloc(sizeof(struct table_entry), 1);
- mu_assert("Structure not zeroed", root->next == NULL);
struct table_entry *next = calloc(sizeof(struct table_entry), 1);
next->key = 0xffffffff;
entry_append(root, next);
@@ -34,3 +35,17 @@ char *test_table_list(void) {
entry_free(root);
return NULL;
}
+
+
+char *test_table_elif(void) {
+ struct stream *s = stream_new(10);
+ struct table_entry *root = calloc(sizeof(struct table_entry), 1);
+ stream_write(s, "\xff\xff\xff\xff\x01\x00\x41\x00\x00\x00", 10);
+ stream_rewind(s);
+ read_elif(s, root);
+ mu_assert("Entry not inserted", root->next != NULL);
+ mu_assert("Filename handling failed", !strcmp(root->next->filename, "A"));
+ entry_free(root);
+ stream_free(s);
+ return NULL;
+}
diff --git a/test/test_table.h b/test/test_table.h
index 1c6fe03..899c2ab 100644
--- a/test/test_table.h
+++ b/test/test_table.h
@@ -20,3 +20,4 @@
#pragma once
char *test_table_list(void);
+char *test_table_elif(void);