server/src/util/strings.test.c
Enno Rehling cd70b8684d fix escape_string mmeory corruption error.
fix a number of small stuff that happens when loading very old data files (like 572).
2014-12-12 11:28:37 +01:00

24 lines
991 B
C

#include <CuTest.h>
#include <ctype.h>
#include <stdio.h>
#include <string.h>
#include "goodies.h"
static void test_escape_string(CuTest * tc)
{
char scratch[64];
CuAssertStrEquals(tc, "12345678901234567890", escape_string("12345678901234567890", scratch, 16));
CuAssertStrEquals(tc, "123456789\\\"12345", escape_string("123456789\"1234567890", scratch, 16));
CuAssertStrEquals(tc, "1234567890123456", escape_string("1234567890123456\"890", scratch, 16));
CuAssertStrEquals(tc, "hello world", escape_string("hello world", scratch, sizeof(scratch)));
CuAssertStrEquals(tc, "hello \\\"world\\\"", escape_string("hello \"world\"", scratch, sizeof(scratch)));
CuAssertStrEquals(tc, "\\\"\\\\", escape_string("\"\\", scratch, sizeof(scratch)));
CuAssertStrEquals(tc, "\\\\", escape_string("\\", scratch, sizeof(scratch)));
}
CuSuite *get_strings_suite(void)
{
CuSuite *suite = CuSuiteNew();
SUITE_ADD_TEST(suite, test_escape_string);
return suite;
}