2014-08-24 22:54:40 +02:00
|
|
|
#include <CuTest.h>
|
|
|
|
#include <ctype.h>
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2015-05-15 20:35:36 +02:00
|
|
|
#include "strings.h"
|
2014-08-24 22:54:40 +02:00
|
|
|
|
|
|
|
static void test_escape_string(CuTest * tc)
|
|
|
|
{
|
|
|
|
char scratch[64];
|
2014-12-12 11:28:37 +01:00
|
|
|
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));
|
2014-08-24 22:54:40 +02:00
|
|
|
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;
|
|
|
|
}
|