PostGIS  2.4.9dev-r@@SVN_REVISION@@
cu_stringbuffer.c
Go to the documentation of this file.
1 /**********************************************************************
2  *
3  * PostGIS - Spatial Types for PostgreSQL
4  * http://postgis.net
5  *
6  * Copyright 2012 Sandro Santilli <strk@kbt.io>
7  *
8  * This is free software; you can redistribute and/or modify it under
9  * the terms of the GNU General Public Licence. See the COPYING file.
10  *
11  **********************************************************************/
12 
13 #include <stdio.h>
14 #include <stdlib.h>
15 #include <string.h>
16 #include "CUnit/Basic.h"
17 
18 #include "stringbuffer.h"
19 #include "cu_tester.h"
20 
21 
22 static void test_stringbuffer_append(void)
23 {
24  stringbuffer_t *sb;
25  const char *str;
26 
28  stringbuffer_append(sb, "hello world");
29  str = stringbuffer_getstring(sb);
30 
31  CU_ASSERT_STRING_EQUAL("hello world", str);
32 
34 }
35 
36 static void test_stringbuffer_aprintf(void)
37 {
38  stringbuffer_t *sb;
39  const char *str;
40 
42  stringbuffer_aprintf(sb, "hello %dth world", 14);
43  str = stringbuffer_getstring(sb);
44 
45  CU_ASSERT_STRING_EQUAL("hello 14th world", str);
46 
48 }
49 
50 
51 /* TODO: add more... */
52 
53 /*
54 ** Used by the test harness to register the tests in this file.
55 */
56 void stringbuffer_suite_setup(void);
58 {
59  CU_pSuite suite = CU_add_suite("stringbuffer", NULL, NULL);
62 }
static void test_stringbuffer_aprintf(void)
void stringbuffer_suite_setup(void)
stringbuffer_t * stringbuffer_create_with_size(size_t size)
Allocate a new stringbuffer_t.
Definition: stringbuffer.c:65
int stringbuffer_aprintf(stringbuffer_t *s, const char *fmt,...)
Appends a formatted string to the current string buffer, using the format and argument list provided...
Definition: stringbuffer.c:253
#define PG_ADD_TEST(suite, testfunc)
void stringbuffer_append(stringbuffer_t *s, const char *a)
Append the specified string to the stringbuffer_t.
Definition: stringbuffer.c:134
void stringbuffer_destroy(stringbuffer_t *s)
Free the stringbuffer_t and all memory managed within it.
Definition: stringbuffer.c:78
static void test_stringbuffer_append(void)
const char * stringbuffer_getstring(stringbuffer_t *s)
Returns a reference to the internal string being managed by the stringbuffer.
Definition: stringbuffer.c:149