aboutsummaryrefslogtreecommitdiffstats
path: root/fbench/src/test/httpclient_splitstring.cpp
blob: acd0c61b268866880511fac09ce136f7b1b90046 (plain) (blame)
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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include <vespa/vespalib/net/crypto_engine.h>
#include <httpclient/httpclient.h>
#include <cstring>

class DebugHTTPClient : public HTTPClient
{
public:
    DebugHTTPClient()
        : HTTPClient(std::make_shared<vespalib::NullCryptoEngine>(),
                     "localhost", 80, true, 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();
}