diff options
Diffstat (limited to 'test/tgbot')
-rw-r--r-- | test/tgbot/net/HttpParser.cpp | 9 | ||||
-rw-r--r-- | test/tgbot/tools/StringTools.cpp | 10 |
2 files changed, 13 insertions, 6 deletions
diff --git a/test/tgbot/net/HttpParser.cpp b/test/tgbot/net/HttpParser.cpp index 236eb90..9272736 100644 --- a/test/tgbot/net/HttpParser.cpp +++ b/test/tgbot/net/HttpParser.cpp @@ -41,7 +41,7 @@ BOOST_AUTO_TEST_CASE(generateRequest) { "Content-Type: application/x-www-form-urlencoded\r\n" "Content-Length: 49\r\n" "\r\n" - "email=test%40example.com&text=Hello%2c%20world%21"; + "email=test%40example.com&text=Hello%2C%20world%21"; BOOST_CHECK_MESSAGE(t == e, diffS(t, e)); } @@ -55,17 +55,18 @@ BOOST_AUTO_TEST_CASE(generateMultipartFormData) { "\r\n" "test@example.com\r\n" "--" + boundary + "\r\n" - "Content-Disposition: form-data; name=\"text\"\r\n" + "Content-Disposition: form-data; name=\"text\"; filename=\"\"\r\n" "Content-Type: text/plain\r\n" "\r\n" - "Hello, world!\r\n"; + "Hello, world!\r\n" + "--" + boundary + "--\r\n"; BOOST_CHECK_MESSAGE(t == e, diffS(t, e)); } BOOST_AUTO_TEST_CASE(generateWwwFormUrlencoded) { vector<HttpReqArg> args = { HttpReqArg("email", "test@example.com"), HttpReqArg("text", "Hello, world!") }; string t = HttpParser::getInstance().generateWwwFormUrlencoded(args); - string e = "email=test%40example.com&text=Hello%2c%20world%21"; + string e = "email=test%40example.com&text=Hello%2C%20world%21"; BOOST_CHECK_MESSAGE(t == e, diffS(t, e)); } diff --git a/test/tgbot/tools/StringTools.cpp b/test/tgbot/tools/StringTools.cpp index 453919c..81e469a 100644 --- a/test/tgbot/tools/StringTools.cpp +++ b/test/tgbot/tools/StringTools.cpp @@ -36,12 +36,18 @@ BOOST_AUTO_TEST_SUITE(tStringTools) BOOST_AUTO_TEST_CASE(startsWith) { BOOST_CHECK(StringTools::startsWith("abc123", "abc")); - BOOST_CHECK(StringTools::startsWith("abc", "abc123")); + BOOST_CHECK(!StringTools::startsWith("abc123", "aac")); + BOOST_CHECK(!StringTools::startsWith("abc123", "Xabc")); + BOOST_CHECK(!StringTools::startsWith("abc123", "abcX")); + BOOST_CHECK(!StringTools::startsWith("abc", "abc123")); } BOOST_AUTO_TEST_CASE(endsWith) { BOOST_CHECK(StringTools::endsWith("abc123", "123")); - BOOST_CHECK(StringTools::endsWith("123", "abc123")); + BOOST_CHECK(!StringTools::endsWith("abc123", "113")); + BOOST_CHECK(!StringTools::endsWith("abc123", "X123")); + BOOST_CHECK(!StringTools::endsWith("abc123", "123X")); + BOOST_CHECK(!StringTools::endsWith("123", "abc123")); } BOOST_AUTO_TEST_CASE(split) { |