summaryrefslogtreecommitdiff
path: root/test/test_io.c
diff options
context:
space:
mode:
Diffstat (limited to 'test/test_io.c')
-rw-r--r--test/test_io.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/test_io.c b/test/test_io.c
index fd1e483..86dde8e 100644
--- a/test/test_io.c
+++ b/test/test_io.c
@@ -17,6 +17,7 @@
You should have received a copy of the GNU General Public License
along with Nekopack. If not, see <http://www.gnu.org/licenses/>. */
+#include <stdint.h>
#include <string.h>
#include "minunit.h"
@@ -54,3 +55,35 @@ char *test_stream_rw(void) {
stream_free(s);
return NULL;
}
+
+
+char *test_stream_realloc(void) {
+ struct stream *s = stream_new(0x2);
+ stream_write(s, "\x00\x01\x02\x03", 4);
+ mu_assert("`len` not modified", s->len > 0x2);
+ return NULL;
+}
+
+
+char *test_stream_xor(void) {
+ struct stream *s = stream_new(2);
+ stream_write(s, "\x01\x01", 2);
+ stream_xor(s, 1, 0);
+ mu_assert("Initial key failure", !memcmp(s->_start, "\x00\x01", 2));
+ stream_xor(s, 0, 1);
+ mu_assert("Primary key failure", !memcmp(s->_start, "\x01\x00", 2));
+ stream_free(s);
+ return NULL;
+}
+
+
+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_rewind(s);
+ mu_assert("Cursor not rewinded", stream_tell(s) == 0);
+ stream_free(s);
+ return NULL;
+}