summaryrefslogtreecommitdiffstats
path: root/common/basicobjects/simplebuffer_ut.c
diff options
context:
space:
mode:
authorDmitri Pal <dpal@redhat.com>2010-07-23 19:33:04 -0400
committerDmitri Pal <dpal@redhat.com>2010-08-10 12:51:32 -0400
commit3b65ae0b2b60d86111ee03005dad7f6ccf7fc40f (patch)
treef249204c0971abfefedf0d8e3f2ff293b2352c68 /common/basicobjects/simplebuffer_ut.c
parenta1935263ae19d2161b1e425135864c7edb9efe49 (diff)
downloadsssd-3b65ae0b2b60d86111ee03005dad7f6ccf7fc40f.tar.gz
sssd-3b65ae0b2b60d86111ee03005dad7f6ccf7fc40f.tar.xz
sssd-3b65ae0b2b60d86111ee03005dad7f6ccf7fc40f.zip
[BASICOBJ] Added a convenience function
Added a function to add a string to the buffer. Allows adding const strings to the buffer. This solution eliminates all the hassle of type casting that was needed before.
Diffstat (limited to 'common/basicobjects/simplebuffer_ut.c')
-rw-r--r--common/basicobjects/simplebuffer_ut.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/common/basicobjects/simplebuffer_ut.c b/common/basicobjects/simplebuffer_ut.c
index f94a1c0..61272da 100644
--- a/common/basicobjects/simplebuffer_ut.c
+++ b/common/basicobjects/simplebuffer_ut.c
@@ -43,6 +43,7 @@ int simple_test(void)
struct simplebuffer *data = NULL;
char str1[] = "test string 1";
char str2[] = "test string 2";
+ const char str3[] = "test string 3";
uint32_t left = 0;
int i;
const unsigned char *buf;
@@ -82,6 +83,23 @@ int simple_test(void)
return error;
}
+ error = simplebuffer_add_cr(data);
+ if (error) {
+ printf("Failed to add CR to an object %d\n", error);
+ simplebuffer_free(data);
+ return error;
+ }
+
+ error = simplebuffer_add_str(data,
+ str3,
+ strlen(str3),
+ 1);
+ if (error) {
+ printf("Failed to add string to an object %d\n", error);
+ simplebuffer_free(data);
+ return error;
+ }
+
left = simplebuffer_get_len(data);
buf = simplebuffer_get_buf(data);