test-istream-jsonstr.c revision c3393007354b7ab607449fea0c3d7088193ab208
/* Copyright (c) 2016-2017 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "str.h"
#include "istream-private.h"
#include "istream-jsonstr.h"
static const struct {
const char *input;
const char *output;
int stream_errno;
} tests[] = {
{ "foo\\\\\\\"\\b\\f\\n\\r\\t\\u0001\\uffff\"",
"foo\\\"\b\f\n\r\t\001\xEF\xBF\xBF", 0 },
{ "\\ud801\\udc37\"", "\xf0\x90\x90\xb7", 0 }, /* valid codepoint */
{ "\"", "", 0 },
};
static void
{
const unsigned char *data;
for (i = 1; i < json_input_len; i++) {
break;
test_assert_idx(ret == 0, i);
}
while (ret > 0 && stream_errno != 0)
if (size > 0)
}
static void test_istream_jsonstr_autoretry(void)
{
const char *json_input = "\\u0001\"";
test_begin("istream-jsonstr autoretry");
test_end();
}
static void test_istream_jsonstr_partial(void)
{
const char *json_input = "hello\\u0060x\"";
const char *output = "hello`x";
test_begin("istream-jsonstr partial");
test_end();
}
void test_istream_jsonstr(void)
{
unsigned int i;
for (i = 0; i < N_ELEMENTS(tests); i++) {
test_end();
}
}