File: soap-decode_header_value.c

package info (click to toggle)
libisds 0.9-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 5,348 kB
  • ctags: 1,659
  • sloc: ansic: 24,898; sh: 11,772; makefile: 393; xml: 375; sed: 16
file content (68 lines) | stat: -rw-r--r-- 1,707 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#include "../test.h"
#include "soap.c"

static int test_decode_header_value(const char *input,
        const char *correct_output) {
    char *decoded;

    decoded = decode_header_value(input);
    TEST_DESTRUCTOR(free, decoded);
    TEST_STRING_DUPLICITY(correct_output, decoded);
    PASS_TEST;
}

int main(int argc, char **argv) {
    int i;

    const char *inputs[] = {
        "foo",
        " foo ",
        "foo bar",
        "foo  bar",
        "foo\r\n bar",
        "foo\r\n\tbar",
        "foo \r\n bar",
        "(=?ISO-8859-1?Q?a?=)",
        "(=?ISO-8859-1?Q?a?= b)",
        "(a =?ISO-8859-1?Q?b?=)",
        "(=?ISO-8859-1?Q?a?= =?ISO-8859-1?Q?b?=)",
        "(=?ISO-8859-1?Q?a?=  =?ISO-8859-1?Q?b?=)",
        "(=?ISO-8859-1?Q?a?=\r\n    =?ISO-8859-1?Q?b?=)",
        "(=?ISO-8859-1?Q?a_b?=)",
        "(=?ISO-8859-1?Q?a?= =?ISO-8859-2?Q?_b?=)",
        "=?UTF-8?B?SmVkbm9yw6F6b3bDvSBrw7NkIG9kZXNsw6FuLg==?=",
        "=?ISO-8859-1?B?ZOlsa2E=?=",
        "=?ISO-8859-1?Q?d=E9lka?="
    };
    const char *outputs[] = {
        "foo",
        "foo",
        "foo bar",
        "foo bar",
        "foo bar",
        "foo bar",
        "foo bar",
        "(a)",
        "(a b)",
        "(a b)",
        "(ab)",
        "(ab)",
        "(ab)",
        "(a b)",
        "(a b)",
        "Jednorázový kód odeslán.",
        "délka",
        "délka"
    };

    INIT_TEST("HTTP header value decoder");

    for (i = 0; i < sizeof(inputs)/sizeof(inputs[0]); i++) {
        TEST(inputs[i], test_decode_header_value, inputs[i], outputs[i]);
    }

    TEST("Empty string", test_decode_header_value, "", "");
    TEST("NULL pointer", test_decode_header_value, NULL, NULL);

    SUM_TEST();
}