|
|
@@ -2,7 +2,7 @@
|
|
|
* libdpkg - Debian packaging suite library routines
|
|
|
* t-verbuf.c - test varbuf implementation
|
|
|
*
|
|
|
- * Copyright © 2009-2011 Guillem Jover <guillem@debian.org>
|
|
|
+ * Copyright © 2009-2011, 2013-2015 Guillem Jover <guillem@debian.org>
|
|
|
*
|
|
|
* This is free software; you can redistribute it and/or modify
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
@@ -222,6 +222,35 @@ test_varbuf_end_str(void)
|
|
|
varbuf_destroy(&vb);
|
|
|
}
|
|
|
|
|
|
+static void
|
|
|
+test_varbuf_get_str(void)
|
|
|
+{
|
|
|
+ struct varbuf vb;
|
|
|
+ const char *str;
|
|
|
+
|
|
|
+ varbuf_init(&vb, 10);
|
|
|
+
|
|
|
+ varbuf_add_buf(&vb, "1234567890", 10);
|
|
|
+ str = varbuf_get_str(&vb);
|
|
|
+ test_pass(vb.buf == str);
|
|
|
+ test_pass(vb.used == 10);
|
|
|
+ test_pass(vb.buf[vb.used] == '\0');
|
|
|
+ test_pass(str[vb.used] == '\0');
|
|
|
+ test_str(vb.buf, ==, "1234567890");
|
|
|
+ test_str(str, ==, "1234567890");
|
|
|
+
|
|
|
+ varbuf_add_buf(&vb, "abcde", 5);
|
|
|
+ str = varbuf_get_str(&vb);
|
|
|
+ test_pass(vb.buf == str);
|
|
|
+ test_pass(vb.used == 15);
|
|
|
+ test_pass(vb.buf[vb.used] == '\0');
|
|
|
+ test_pass(str[vb.used] == '\0');
|
|
|
+ test_str(vb.buf, ==, "1234567890abcde");
|
|
|
+ test_str(str, ==, "1234567890abcde");
|
|
|
+
|
|
|
+ varbuf_destroy(&vb);
|
|
|
+}
|
|
|
+
|
|
|
static void
|
|
|
test_varbuf_printf(void)
|
|
|
{
|
|
|
@@ -322,7 +351,7 @@ test_varbuf_detach(void)
|
|
|
static void
|
|
|
test(void)
|
|
|
{
|
|
|
- test_plan(108);
|
|
|
+ test_plan(120);
|
|
|
|
|
|
test_varbuf_init();
|
|
|
test_varbuf_prealloc();
|
|
|
@@ -333,6 +362,7 @@ test(void)
|
|
|
test_varbuf_dup_char();
|
|
|
test_varbuf_map_char();
|
|
|
test_varbuf_end_str();
|
|
|
+ test_varbuf_get_str();
|
|
|
test_varbuf_printf();
|
|
|
test_varbuf_reset();
|
|
|
test_varbuf_snapshot();
|