PostGIS  2.1.10dev-r@@SVN_REVISION@@
cu_stringbuffer.c
Go to the documentation of this file.
1 /**********************************************************************
2  * $Id$
3  *
4  * PostGIS - Spatial Types for PostgreSQL
5  * http://postgis.net
6  *
7  * Copyright 2012 Sandro Santilli <strk@keybit.net>
8  *
9  * This is free software; you can redistribute and/or modify it under
10  * the terms of the GNU General Public Licence. See the COPYING file.
11  *
12  **********************************************************************/
13 
14 #include <stdio.h>
15 #include <stdlib.h>
16 #include <string.h>
17 #include "CUnit/Basic.h"
18 
19 #include "stringbuffer.h"
20 #include "cu_tester.h"
21 
22 
23 static void test_stringbuffer_append(void)
24 {
25  stringbuffer_t *sb;
26  const char *str;
27 
29  stringbuffer_append(sb, "hello world");
30  str = stringbuffer_getstring(sb);
31 
32  CU_ASSERT_STRING_EQUAL("hello world", str);
33 
35 }
36 
37 static void test_stringbuffer_aprintf(void)
38 {
39  stringbuffer_t *sb;
40  const char *str;
41 
43  stringbuffer_aprintf(sb, "hello %dth world", 14);
44  str = stringbuffer_getstring(sb);
45 
46  CU_ASSERT_STRING_EQUAL("hello 14th world", str);
47 
49 }
50 
51 
52 /* TODO: add more... */
53 
54 /*
55 ** Used by the test harness to register the tests in this file.
56 */
57 void stringbuffer_suite_setup(void);
59 {
60  CU_pSuite suite = CU_add_suite("StringBuffer", NULL, NULL);
63 }
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:56
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:247
#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:128
void stringbuffer_destroy(stringbuffer_t *s)
Free the stringbuffer_t and all memory managed within it.
Definition: stringbuffer.c:72
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:143