PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches
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
22static void test_stringbuffer_append(void)
23{
25 const char *str;
26
28 stringbuffer_append(sb, "hello world");
30
31 ASSERT_STRING_EQUAL("hello world", str);
32
34}
35
37{
39 const char *str;
40
42 stringbuffer_aprintf(sb, "hello %dth world", 14);
44
45 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*/
58{
59 CU_pSuite suite = CU_add_suite("stringbuffer", NULL, NULL);
62}
static void test_stringbuffer_append(void)
void stringbuffer_suite_setup(void)
static void test_stringbuffer_aprintf(void)
#define PG_ADD_TEST(suite, testfunc)
#define ASSERT_STRING_EQUAL(o, e)
#define str(s)
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.
const char * stringbuffer_getstring(stringbuffer_t *s)
Returns a reference to the internal string being managed by the stringbuffer.
void stringbuffer_destroy(stringbuffer_t *s)
Free the stringbuffer_t and all memory managed within it.
stringbuffer_t * stringbuffer_create_with_size(size_t size)
Allocate a new stringbuffer_t.
static void stringbuffer_append(stringbuffer_t *s, const char *a)
Append the specified string to the stringbuffer_t.