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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include <httpclient/httpclient.h>
class DebugHTTPClient : public HTTPClient
{
public:
DebugHTTPClient(const char* server, int port, bool keepAlive)
: HTTPClient(server, port, keepAlive, true) {}
static void SplitLineTest(const char *input);
static void DebugSplitLine();
};
void
DebugHTTPClient::SplitLineTest(const char *input)
{
char str[1024];
char *rest;
int argc;
char *argv[5];
int i;
memcpy(str, input, strlen(input) + 1);
printf("*** TEST HTTPClient::SplitString ***\n");
printf("string:'%s'\n", str);
rest = str;
while (rest != NULL) {
rest = SplitString(rest, argc, argv, 5);
printf("argc:'%d'\n", argc);
printf("rest:'%s'\n", (rest == NULL) ? "NULL" : rest);
for(i = 0; i < argc; i++) {
printf(" %d:'%s'\n", i, argv[i]);
}
}
}
void
DebugHTTPClient::DebugSplitLine()
{
SplitLineTest("This is a test");
SplitLineTest("This is exactly five words");
SplitLineTest("five words with traling space ");
SplitLineTest(" This\t is \ta \t harder\ttest ");
SplitLineTest("SingleWord");
SplitLineTest("\t\t \t\tSingleWordWithSpacesAround \t\t ");
SplitLineTest("just all too many parts baby ");
SplitLineTest("many many words does this long fancy string contain "
", and they all must be tokenized by split line");
}
int
main(int argc, char **argv)
{
(void) argc;
(void) argv;
DebugHTTPClient::DebugSplitLine();
}
|