diff options
Diffstat (limited to 'fbench/src/test/httpclient_splitstring.cpp')
-rw-r--r-- | fbench/src/test/httpclient_splitstring.cpp | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/fbench/src/test/httpclient_splitstring.cpp b/fbench/src/test/httpclient_splitstring.cpp new file mode 100644 index 00000000000..4e893d37db4 --- /dev/null +++ b/fbench/src/test/httpclient_splitstring.cpp @@ -0,0 +1,58 @@ +// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. + +#include <util/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(); +} |