From 064ee8b899a16b238acc4682d44bd9a71651c6fd Mon Sep 17 00:00:00 2001 From: Jaskowicz1 Date: Mon, 19 Feb 2024 17:37:41 +0000 Subject: [PATCH 1/3] refactor: cleaned up unit-tests --- src/unittest/http.cpp | 94 ++++++++++++++++++++++++++++++++++++++ src/unittest/test.cpp | 84 +--------------------------------- src/unittest/test.h | 8 +++- src/unittest/utilities.cpp | 38 +++++++++++++++ 4 files changed, 140 insertions(+), 84 deletions(-) create mode 100644 src/unittest/http.cpp create mode 100644 src/unittest/utilities.cpp diff --git a/src/unittest/http.cpp b/src/unittest/http.cpp new file mode 100644 index 0000000000..08c998f7aa --- /dev/null +++ b/src/unittest/http.cpp @@ -0,0 +1,94 @@ +/************************************************************************************ + * + * D++, A Lightweight C++ library for Discord + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright 2021 Craig Edwards and D++ contributors + * (https://github.com/brainboxdotcc/DPP/graphs/contributors) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ************************************************************************************/ +#include "test.h" + +void http_unit_tests(const std::string& token) { + dpp::http_connect_info hci; + set_test(HOSTINFO, false); + + hci = dpp::https_client::get_host_info("https://test.com:444"); + bool hci_test = (hci.scheme == "https" && hci.hostname == "test.com" && hci.port == 444 && hci.is_ssl == true); + + hci = dpp::https_client::get_host_info("https://test.com"); + hci_test = hci_test && (hci.scheme == "https" && hci.hostname == "test.com" && hci.port == 443 && hci.is_ssl == true); + + hci = dpp::https_client::get_host_info("http://test.com"); + hci_test = hci_test && (hci.scheme == "http" && hci.hostname == "test.com" && hci.port == 80 && hci.is_ssl == false); + + hci = dpp::https_client::get_host_info("http://test.com:90"); + hci_test = hci_test && (hci.scheme == "http" && hci.hostname == "test.com" && hci.port == 90 && hci.is_ssl == false); + + hci = dpp::https_client::get_host_info("test.com:97"); + hci_test = hci_test && (hci.scheme == "http" && hci.hostname == "test.com" && hci.port == 97 && hci.is_ssl == false); + + hci = dpp::https_client::get_host_info("test.com"); + hci_test = hci_test && (hci.scheme == "http" && hci.hostname == "test.com" && hci.port == 80 && hci.is_ssl == false); + + set_test(HOSTINFO, hci_test); + + set_test(HTTPS, false); + if (!offline) { + dpp::multipart_content multipart = dpp::https_client::build_multipart( + "{\"content\":\"test\"}", {"test.txt", "blob.blob"}, {"ABCDEFGHI", "BLOB!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"}, {"text/plain", "application/octet-stream"} + ); + try { + dpp::https_client c("discord.com", 443, "/api/channels/" + std::to_string(TEST_TEXT_CHANNEL_ID) + "/messages", "POST", multipart.body, + { + {"Content-Type", multipart.mimetype}, + {"Authorization", "Bot " + token} + } + ); + std::string hdr1 = c.get_header("server"); + std::string content1 = c.get_content(); + set_test(HTTPS, hdr1 == "cloudflare" && c.get_status() == 200); + } + catch (const dpp::exception& e) { + std::cout << e.what() << "\n"; + set_test(HTTPS, false); + } + } + + set_test(HTTP, false); + try { + dpp::https_client c2("github.com", 80, "/", "GET", "", {}, true); + std::string hdr2 = c2.get_header("location"); + std::string content2 = c2.get_content(); + set_test(HTTP, hdr2 == "https://github.com/" && c2.get_status() == 301); + } + catch (const dpp::exception& e) { + std::cout << e.what() << "\n"; + set_test(HTTP, false); + } + + set_test(MULTIHEADER, false); + try { + dpp::https_client c2("dl.dpp.dev", 443, "/cookietest.php", "GET", "", {}); + size_t count = c2.get_header_count("set-cookie"); + size_t count_list = c2.get_header_list("set-cookie").size(); + // Google sets a bunch of cookies when we start accessing it. + set_test(MULTIHEADER, c2.get_status() == 200 && count > 1 && count == count_list); + } + catch (const dpp::exception& e) { + std::cout << e.what() << "\n"; + set_test(MULTIHEADER, false); + } +} \ No newline at end of file diff --git a/src/unittest/test.cpp b/src/unittest/test.cpp index fb599462a1..14fb739430 100644 --- a/src/unittest/test.cpp +++ b/src/unittest/test.cpp @@ -213,89 +213,9 @@ int main\\(\\) {\n\ \\`\\`\\`\n\ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* block\\`\n"); - set_test(URLENC, false); - set_test(URLENC, dpp::utility::url_encode("ABC123_+\\|$*/AAA[]😄") == "ABC123_%2B%5C%7C%24%2A%2FAAA%5B%5D%F0%9F%98%84"); + http_unit_tests(token); - set_test(BASE64ENC, false); - set_test(BASE64ENC, - dpp::base64_encode(reinterpret_cast("a"), 1) == "YQ==" && - dpp::base64_encode(reinterpret_cast("bc"), 2) == "YmM=" && - dpp::base64_encode(reinterpret_cast("def"), 3) == "ZGVm" && - dpp::base64_encode(reinterpret_cast("ghij"), 4) == "Z2hpag==" && - dpp::base64_encode(reinterpret_cast("klmno"), 5) == "a2xtbm8=" && - dpp::base64_encode(reinterpret_cast("pqrstu"), 6) == "cHFyc3R1" && - dpp::base64_encode(reinterpret_cast("vwxyz12"), 7) == "dnd4eXoxMg==" - ); - - dpp::http_connect_info hci; - set_test(HOSTINFO, false); - - hci = dpp::https_client::get_host_info("https://test.com:444"); - bool hci_test = (hci.scheme == "https" && hci.hostname == "test.com" && hci.port == 444 && hci.is_ssl == true); - - hci = dpp::https_client::get_host_info("https://test.com"); - hci_test = hci_test && (hci.scheme == "https" && hci.hostname == "test.com" && hci.port == 443 && hci.is_ssl == true); - - hci = dpp::https_client::get_host_info("http://test.com"); - hci_test = hci_test && (hci.scheme == "http" && hci.hostname == "test.com" && hci.port == 80 && hci.is_ssl == false); - - hci = dpp::https_client::get_host_info("http://test.com:90"); - hci_test = hci_test && (hci.scheme == "http" && hci.hostname == "test.com" && hci.port == 90 && hci.is_ssl == false); - - hci = dpp::https_client::get_host_info("test.com:97"); - hci_test = hci_test && (hci.scheme == "http" && hci.hostname == "test.com" && hci.port == 97 && hci.is_ssl == false); - - hci = dpp::https_client::get_host_info("test.com"); - hci_test = hci_test && (hci.scheme == "http" && hci.hostname == "test.com" && hci.port == 80 && hci.is_ssl == false); - - set_test(HOSTINFO, hci_test); - - set_test(HTTPS, false); - if (!offline) { - dpp::multipart_content multipart = dpp::https_client::build_multipart( - "{\"content\":\"test\"}", {"test.txt", "blob.blob"}, {"ABCDEFGHI", "BLOB!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"}, {"text/plain", "application/octet-stream"} - ); - try { - dpp::https_client c("discord.com", 443, "/api/channels/" + std::to_string(TEST_TEXT_CHANNEL_ID) + "/messages", "POST", multipart.body, - { - {"Content-Type", multipart.mimetype}, - {"Authorization", "Bot " + token} - } - ); - std::string hdr1 = c.get_header("server"); - std::string content1 = c.get_content(); - set_test(HTTPS, hdr1 == "cloudflare" && c.get_status() == 200); - } - catch (const dpp::exception& e) { - std::cout << e.what() << "\n"; - set_test(HTTPS, false); - } - } - - set_test(HTTP, false); - try { - dpp::https_client c2("github.com", 80, "/", "GET", "", {}, true); - std::string hdr2 = c2.get_header("location"); - std::string content2 = c2.get_content(); - set_test(HTTP, hdr2 == "https://github.com/" && c2.get_status() == 301); - } - catch (const dpp::exception& e) { - std::cout << e.what() << "\n"; - set_test(HTTP, false); - } - - set_test(MULTIHEADER, false); - try { - dpp::https_client c2("dl.dpp.dev", 443, "/cookietest.php", "GET", "", {}); - size_t count = c2.get_header_count("set-cookie"); - size_t count_list = c2.get_header_list("set-cookie").size(); - // Google sets a bunch of cookies when we start accessing it. - set_test(MULTIHEADER, c2.get_status() == 200 && count > 1 && count == count_list); - } - catch (const dpp::exception& e) { - std::cout << e.what() << "\n"; - set_test(MULTIHEADER, false); - } + utilities_unit_tests(); std::vector testaudio = load_test_audio(); diff --git a/src/unittest/test.h b/src/unittest/test.h index 2cdb80ac77..0f2b868294 100644 --- a/src/unittest/test.h +++ b/src/unittest/test.h @@ -3,7 +3,7 @@ * D++, A Lightweight C++ library for Discord * * SPDX-License-Identifier: Apache-2.0 - * Copyright 2021 Craig Edwards and D++ contributors + * Copyright 2021 Craig Edwards and D++ contributors * (https://github.com/brainboxdotcc/DPP/graphs/contributors) * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -181,7 +181,7 @@ DPP_TEST(USER_GET_AVATAR_URL, "user::get_avatar_url", tf_offline); DPP_TEST(CHANNEL_SET_TYPE, "channel::set_type", tf_offline); DPP_TEST(CHANNEL_GET_MENTION, "channel::get_mention", tf_offline); DPP_TEST(CHANNEL_GET_URL, "channel::get_url", tf_offline); -DPP_TEST(MESSAGE_GET_URL,"message::get_url",tf_offline); +DPP_TEST(MESSAGE_GET_URL, "message::get_url", tf_offline); DPP_TEST(UTILITY_GUILD_NAVIGATION, "utility::guild_navigation", tf_offline); DPP_TEST(UTILITY_ICONHASH, "utility::iconhash", tf_offline); DPP_TEST(UTILITY_MAKE_URL_PARAMETERS, "utility::make_url_parameters", tf_offline); @@ -507,6 +507,10 @@ double get_start_time(); */ double get_time(); +void http_unit_tests(const std::string& token); + +void utilities_unit_tests(); + /** * @brief A test version of the message collector for use in unit tests */ diff --git a/src/unittest/utilities.cpp b/src/unittest/utilities.cpp new file mode 100644 index 0000000000..5df89ad528 --- /dev/null +++ b/src/unittest/utilities.cpp @@ -0,0 +1,38 @@ +/************************************************************************************ + * + * D++, A Lightweight C++ library for Discord + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright 2021 Craig Edwards and D++ contributors + * (https://github.com/brainboxdotcc/DPP/graphs/contributors) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ************************************************************************************/ +#include "test.h" + +void utilities_unit_tests() { + set_test(URLENC, false); + set_test(URLENC, dpp::utility::url_encode("ABC123_+\\|$*/AAA[]😄") == "ABC123_%2B%5C%7C%24%2A%2FAAA%5B%5D%F0%9F%98%84"); + + set_test(BASE64ENC, false); + set_test(BASE64ENC, + dpp::base64_encode(reinterpret_cast("a"), 1) == "YQ==" && + dpp::base64_encode(reinterpret_cast("bc"), 2) == "YmM=" && + dpp::base64_encode(reinterpret_cast("def"), 3) == "ZGVm" && + dpp::base64_encode(reinterpret_cast("ghij"), 4) == "Z2hpag==" && + dpp::base64_encode(reinterpret_cast("klmno"), 5) == "a2xtbm8=" && + dpp::base64_encode(reinterpret_cast("pqrstu"), 6) == "cHFyc3R1" && + dpp::base64_encode(reinterpret_cast("vwxyz12"), 7) == "dnd4eXoxMg==" + ); +} From b54ef4c9bfa8a34047424ce91860708c4896151d Mon Sep 17 00:00:00 2001 From: Jaskowicz1 Date: Mon, 19 Feb 2024 17:49:26 +0000 Subject: [PATCH 2/3] refactor: moved more tests, windows now tests ts_not_null --- src/unittest/test.cpp | 46 -------------------------------------- src/unittest/test.h | 17 ++++++++++++++ src/unittest/utilities.cpp | 42 ++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+), 46 deletions(-) diff --git a/src/unittest/test.cpp b/src/unittest/test.cpp index 14fb739430..47257282fb 100644 --- a/src/unittest/test.cpp +++ b/src/unittest/test.cpp @@ -79,15 +79,6 @@ int main(int argc, char *argv[]) std::cout << "Running offline and " << (extended ? "extended" : "limited") << " online unit tests. Guild ID: " << TEST_GUILD_ID << " Text Channel ID: " << TEST_TEXT_CHANNEL_ID << " VC ID: " << TEST_VC_ID << " User ID: " << TEST_USER_ID << " Event ID: " << TEST_EVENT_ID << "\n"; } - std::string test_to_escape = "*** _This is a test_ ***\n```cpp\n\ -int main() {\n\ - /* Comment */\n\ - int answer = 42;\n\ - return answer; // ___\n\ -};\n\ -```\n\ -Markdown lol ||spoiler|| ~~strikethrough~~ `small *code* block`\n"; - set_test(COMPARISON, false); dpp::user u1; dpp::user u2; @@ -190,29 +181,6 @@ Markdown lol ||spoiler|| ~~strikethrough~~ `small *code* block`\n"; set_test(ERRORS, error_message_success); - set_test(MD_ESC_1, false); - set_test(MD_ESC_2, false); - std::string escaped1 = dpp::utility::markdown_escape(test_to_escape); - std::string escaped2 = dpp::utility::markdown_escape(test_to_escape, true); - set_test(MD_ESC_1, escaped1 == "\\*\\*\\* \\_This is a test\\_ \\*\\*\\*\n\ -```cpp\n\ -int main() {\n\ - /* Comment */\n\ - int answer = 42;\n\ - return answer; // ___\n\ -};\n\ -```\n\ -Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ `small *code* block`\n"); - set_test(MD_ESC_2, escaped2 == "\\*\\*\\* \\_This is a test\\_ \\*\\*\\*\n\ -\\`\\`\\`cpp\n\ -int main\\(\\) {\n\ - /\\* Comment \\*/\n\ - int answer = 42;\n\ - return answer; // \\_\\_\\_\n\ -};\n\ -\\`\\`\\`\n\ -Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* block\\`\n"); - http_unit_tests(token); utilities_unit_tests(); @@ -227,9 +195,6 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b fclose(fp); set_test(READFILE, off == rf_test.length()); - set_test(TIMESTAMPTOSTRING, false); - set_test(TIMESTAMPTOSTRING, dpp::ts_to_string(1642611864) == "2022-01-19T17:04:24Z"); - set_test(ROLE_COMPARE, false); dpp::role role_1, role_2; role_1.position = 1; @@ -811,17 +776,6 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b ); } -#ifndef _WIN32 - set_test(TIMESTRINGTOTIMESTAMP, false); - json tj; - tj["t1"] = "2022-01-19T17:18:14.506000+00:00"; - tj["t2"] = "2022-01-19T17:18:14+00:00"; - uint32_t inTimestamp = 1642612694; - set_test(TIMESTRINGTOTIMESTAMP, (uint64_t)dpp::ts_not_null(&tj, "t1") == inTimestamp && (uint64_t)dpp::ts_not_null(&tj, "t2") == inTimestamp); -#else - set_test(TIMESTRINGTOTIMESTAMP, true); -#endif - { set_test(TS, false); dpp::managed m(189759562910400512); diff --git a/src/unittest/test.h b/src/unittest/test.h index 0f2b868294..1af3c9b0c5 100644 --- a/src/unittest/test.h +++ b/src/unittest/test.h @@ -507,8 +507,25 @@ double get_start_time(); */ double get_time(); +/** + * @brief This unit test covers the following: + * - get_host_info + * - HTTPS request + * - HTTP request + * - multiheader cookie test + * + * @param token + */ void http_unit_tests(const std::string& token); +/** + * @brief This unit test covers the following: + * - Markdown escaping + * - URL encoding + * - Base 64 encoding + * - ts_to_string + * - ts_not_null + */ void utilities_unit_tests(); /** diff --git a/src/unittest/utilities.cpp b/src/unittest/utilities.cpp index 5df89ad528..9e7c0bf864 100644 --- a/src/unittest/utilities.cpp +++ b/src/unittest/utilities.cpp @@ -22,6 +22,38 @@ #include "test.h" void utilities_unit_tests() { + std::string text_to_escape = "*** _This is a test_ ***\n```cpp\n\ +int main() {\n\ + /* Comment */\n\ + int answer = 42;\n\ + return answer; // ___\n\ +};\n\ +```\n\ +Markdown lol ||spoiler|| ~~strikethrough~~ `small *code* block`\n"; + + set_test(MD_ESC_1, false); + set_test(MD_ESC_2, false); + std::string escaped1 = dpp::utility::markdown_escape(text_to_escape); + std::string escaped2 = dpp::utility::markdown_escape(text_to_escape, true); + set_test(MD_ESC_1, escaped1 == "\\*\\*\\* \\_This is a test\\_ \\*\\*\\*\n\ +```cpp\n\ +int main() {\n\ + /* Comment */\n\ + int answer = 42;\n\ + return answer; // ___\n\ +};\n\ +```\n\ +Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ `small *code* block`\n"); + set_test(MD_ESC_2, escaped2 == "\\*\\*\\* \\_This is a test\\_ \\*\\*\\*\n\ +\\`\\`\\`cpp\n\ +int main\\(\\) {\n\ + /\\* Comment \\*/\n\ + int answer = 42;\n\ + return answer; // \\_\\_\\_\n\ +};\n\ +\\`\\`\\`\n\ +Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* block\\`\n"); + set_test(URLENC, false); set_test(URLENC, dpp::utility::url_encode("ABC123_+\\|$*/AAA[]😄") == "ABC123_%2B%5C%7C%24%2A%2FAAA%5B%5D%F0%9F%98%84"); @@ -35,4 +67,14 @@ void utilities_unit_tests() { dpp::base64_encode(reinterpret_cast("pqrstu"), 6) == "cHFyc3R1" && dpp::base64_encode(reinterpret_cast("vwxyz12"), 7) == "dnd4eXoxMg==" ); + + set_test(TIMESTAMPTOSTRING, false); + set_test(TIMESTAMPTOSTRING, dpp::ts_to_string(1642611864) == "2022-01-19T17:04:24Z"); + + set_test(TIMESTRINGTOTIMESTAMP, false); + json tj; + tj["t1"] = "2022-01-19T17:18:14.506000+00:00"; + tj["t2"] = "2022-01-19T17:18:14+00:00"; + uint32_t inTimestamp = 1642612694; + set_test(TIMESTRINGTOTIMESTAMP, (uint64_t)dpp::ts_not_null(&tj, "t1") == inTimestamp && (uint64_t)dpp::ts_not_null(&tj, "t2") == inTimestamp); } From 8f368e0e32b726eab203f6c7feb45965c0e75f0b Mon Sep 17 00:00:00 2001 From: Jaskowicz1 Date: Mon, 19 Feb 2024 18:12:37 +0000 Subject: [PATCH 3/3] refactor: separated errors --- src/unittest/errors.cpp | 117 ++++++++++++++++++ src/unittest/http.cpp | 4 +- src/unittest/test.cpp | 239 +------------------------------------ src/unittest/test.h | 8 ++ src/unittest/utilities.cpp | 145 ++++++++++++++++++++++ 5 files changed, 273 insertions(+), 240 deletions(-) create mode 100644 src/unittest/errors.cpp diff --git a/src/unittest/errors.cpp b/src/unittest/errors.cpp new file mode 100644 index 0000000000..ee0e2a595d --- /dev/null +++ b/src/unittest/errors.cpp @@ -0,0 +1,117 @@ +/************************************************************************************ + * + * D++, A Lightweight C++ library for Discord + * + * SPDX-License-Identifier: Apache-2.0 + * Copyright 2021 Craig Edwards and D++ contributors + * (https://github.com/brainboxdotcc/DPP/graphs/contributors) + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + ************************************************************************************/ +#include "test.h" + +void errors_unit_tests() { + set_test(ERRORS, false); + + /* Prepare a confirmation_callback_t in error state (400) */ + dpp::confirmation_callback_t error_test; + bool error_message_success = false; + error_test.http_info.status = 400; + + error_test.http_info.body = "{\ + \"message\": \"Invalid Form Body\",\ + \"code\": 50035,\ + \"errors\": {\ + \"options\": {\ + \"0\": {\ + \"name\": {\ + \"_errors\": [\ + {\ + \"code\": \"STRING_TYPE_REGEX\",\ + \"message\": \"String value did not match validation regex.\"\ + },\ + {\ + \"code\": \"APPLICATION_COMMAND_INVALID_NAME\",\ + \"message\": \"Command name is invalid\"\ + }\ + ]\ + }\ + }\ + }\ + }\ + }"; + error_message_success = (error_test.get_error().human_readable == "50035: Invalid Form Body\n\t- options[0].name: String value did not match validation regex. (STRING_TYPE_REGEX)\n\t- options[0].name: Command name is invalid (APPLICATION_COMMAND_INVALID_NAME)"); + + error_test.http_info.body = "{\ + \"message\": \"Invalid Form Body\",\ + \"code\": 50035,\ + \"errors\": {\ + \"type\": {\ + \"_errors\": [\ + {\ + \"code\": \"BASE_TYPE_CHOICES\",\ + \"message\": \"Value must be one of {4, 5, 9, 10, 11}.\"\ + }\ + ]\ + }\ + }\ + }"; + error_message_success = (error_message_success && error_test.get_error().human_readable == "50035: Invalid Form Body - type: Value must be one of {4, 5, 9, 10, 11}. (BASE_TYPE_CHOICES)"); + + error_test.http_info.body = "{\ + \"message\": \"Unknown Guild\",\ + \"code\": 10004\ + }"; + error_message_success = (error_message_success && error_test.get_error().human_readable == "10004: Unknown Guild"); + + error_test.http_info.body = "{\ + \"message\": \"Invalid Form Body\",\ + \"code\": 50035,\ + \"errors\": {\ + \"allowed_mentions\": {\ + \"_errors\": [\ + {\ + \"code\": \"MESSAGE_ALLOWED_MENTIONS_PARSE_EXCLUSIVE\",\ + \"message\": \"parse:[\\\"users\\\"] and users: [ids...] are mutually exclusive.\"\ + }\ + ]\ + }\ + }\ + }"; + error_message_success = (error_message_success && error_test.get_error().human_readable == "50035: Invalid Form Body - allowed_mentions: parse:[\"users\"] and users: [ids...] are mutually exclusive. (MESSAGE_ALLOWED_MENTIONS_PARSE_EXCLUSIVE)"); + + error_test.http_info.body = "{\ + \"message\": \"Invalid Form Body\",\ + \"code\": 50035,\ + \"errors\": {\ + \"1\": {\ + \"options\": {\ + \"1\": {\ + \"description\": {\ + \"_errors\": [\ + {\ + \"code\": \"BASE_TYPE_BAD_LENGTH\",\ + \"message\": \"Must be between 1 and 100 in length.\"\ + }\ + ]\ + }\ + }\ + }\ + }\ + }\ + }"; + error_message_success = (error_message_success && error_test.get_error().human_readable == "50035: Invalid Form Body - [1].options[1].description: Must be between 1 and 100 in length. (BASE_TYPE_BAD_LENGTH)"); + + set_test(ERRORS, error_message_success); +} diff --git a/src/unittest/http.cpp b/src/unittest/http.cpp index 08c998f7aa..931277b0ac 100644 --- a/src/unittest/http.cpp +++ b/src/unittest/http.cpp @@ -58,7 +58,7 @@ void http_unit_tests(const std::string& token) { } ); std::string hdr1 = c.get_header("server"); - std::string content1 = c.get_content(); + //std::string content1 = c.get_content(); set_test(HTTPS, hdr1 == "cloudflare" && c.get_status() == 200); } catch (const dpp::exception& e) { @@ -71,7 +71,7 @@ void http_unit_tests(const std::string& token) { try { dpp::https_client c2("github.com", 80, "/", "GET", "", {}, true); std::string hdr2 = c2.get_header("location"); - std::string content2 = c2.get_content(); + //std::string content2 = c2.get_content(); set_test(HTTP, hdr2 == "https://github.com/" && c2.get_status() == 301); } catch (const dpp::exception& e) { diff --git a/src/unittest/test.cpp b/src/unittest/test.cpp index 47257282fb..0a0aa89bdd 100644 --- a/src/unittest/test.cpp +++ b/src/unittest/test.cpp @@ -79,107 +79,7 @@ int main(int argc, char *argv[]) std::cout << "Running offline and " << (extended ? "extended" : "limited") << " online unit tests. Guild ID: " << TEST_GUILD_ID << " Text Channel ID: " << TEST_TEXT_CHANNEL_ID << " VC ID: " << TEST_VC_ID << " User ID: " << TEST_USER_ID << " Event ID: " << TEST_EVENT_ID << "\n"; } - set_test(COMPARISON, false); - dpp::user u1; - dpp::user u2; - dpp::user u3; - u1.id = u2.id = 666; - u3.id = 777; - set_test(COMPARISON, u1 == u2 && u1 != u3); - - - set_test(ERRORS, false); - - /* Prepare a confirmation_callback_t in error state (400) */ - dpp::confirmation_callback_t error_test; - bool error_message_success = false; - error_test.http_info.status = 400; - - error_test.http_info.body = "{\ - \"message\": \"Invalid Form Body\",\ - \"code\": 50035,\ - \"errors\": {\ - \"options\": {\ - \"0\": {\ - \"name\": {\ - \"_errors\": [\ - {\ - \"code\": \"STRING_TYPE_REGEX\",\ - \"message\": \"String value did not match validation regex.\"\ - },\ - {\ - \"code\": \"APPLICATION_COMMAND_INVALID_NAME\",\ - \"message\": \"Command name is invalid\"\ - }\ - ]\ - }\ - }\ - }\ - }\ - }"; - error_message_success = (error_test.get_error().human_readable == "50035: Invalid Form Body\n\t- options[0].name: String value did not match validation regex. (STRING_TYPE_REGEX)\n\t- options[0].name: Command name is invalid (APPLICATION_COMMAND_INVALID_NAME)"); - - error_test.http_info.body = "{\ - \"message\": \"Invalid Form Body\",\ - \"code\": 50035,\ - \"errors\": {\ - \"type\": {\ - \"_errors\": [\ - {\ - \"code\": \"BASE_TYPE_CHOICES\",\ - \"message\": \"Value must be one of {4, 5, 9, 10, 11}.\"\ - }\ - ]\ - }\ - }\ - }"; - error_message_success = (error_message_success && error_test.get_error().human_readable == "50035: Invalid Form Body - type: Value must be one of {4, 5, 9, 10, 11}. (BASE_TYPE_CHOICES)"); - - error_test.http_info.body = "{\ - \"message\": \"Unknown Guild\",\ - \"code\": 10004\ - }"; - error_message_success = (error_message_success && error_test.get_error().human_readable == "10004: Unknown Guild"); - - error_test.http_info.body = "{\ - \"message\": \"Invalid Form Body\",\ - \"code\": 50035,\ - \"errors\": {\ - \"allowed_mentions\": {\ - \"_errors\": [\ - {\ - \"code\": \"MESSAGE_ALLOWED_MENTIONS_PARSE_EXCLUSIVE\",\ - \"message\": \"parse:[\\\"users\\\"] and users: [ids...] are mutually exclusive.\"\ - }\ - ]\ - }\ - }\ - }"; - error_message_success = (error_message_success && error_test.get_error().human_readable == "50035: Invalid Form Body - allowed_mentions: parse:[\"users\"] and users: [ids...] are mutually exclusive. (MESSAGE_ALLOWED_MENTIONS_PARSE_EXCLUSIVE)"); - - error_test.http_info.body = "{\ - \"message\": \"Invalid Form Body\",\ - \"code\": 50035,\ - \"errors\": {\ - \"1\": {\ - \"options\": {\ - \"1\": {\ - \"description\": {\ - \"_errors\": [\ - {\ - \"code\": \"BASE_TYPE_BAD_LENGTH\",\ - \"message\": \"Must be between 1 and 100 in length.\"\ - }\ - ]\ - }\ - }\ - }\ - }\ - }\ - }"; - error_message_success = (error_message_success && error_test.get_error().human_readable == "50035: Invalid Form Body - [1].options[1].description: Must be between 1 and 100 in length. (BASE_TYPE_BAD_LENGTH)"); - - set_test(ERRORS, error_message_success); + errors_unit_tests(); http_unit_tests(token); @@ -514,33 +414,6 @@ int main(int argc, char *argv[]) ); } - { // avatar size function - set_test(UTILITY_AVATAR_SIZE, false); - bool success = false; - success = dpp::utility::avatar_size(0).empty(); - success = dpp::utility::avatar_size(16) == "?size=16" && success; - success = dpp::utility::avatar_size(256) == "?size=256" && success; - success = dpp::utility::avatar_size(4096) == "?size=4096" && success; - success = dpp::utility::avatar_size(8192).empty() && success; - success = dpp::utility::avatar_size(3000).empty() && success; - set_test(UTILITY_AVATAR_SIZE, success); - } - - { // cdn endpoint url getter - set_test(UTILITY_CDN_ENDPOINT_URL_HASH, false); - bool success = false; - success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png }, "foobar/test", "", dpp::i_jpg, 0).empty(); - success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png }, "foobar/test", "", dpp::i_png, 0) == "https://cdn.discordapp.com/foobar/test.png" && success; - success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png }, "foobar/test", "", dpp::i_png, 128) == "https://cdn.discordapp.com/foobar/test.png?size=128" && success; - success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png, dpp::i_gif }, "foobar/test", "12345", dpp::i_gif, 0, false, true) == "https://cdn.discordapp.com/foobar/test/a_12345.gif" && success; - success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png, dpp::i_gif }, "foobar/test", "12345", dpp::i_png, 0, false, true) == "https://cdn.discordapp.com/foobar/test/a_12345.png" && success; - success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png, dpp::i_gif }, "foobar/test", "12345", dpp::i_png, 0, false, false) == "https://cdn.discordapp.com/foobar/test/12345.png" && success; - success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png, dpp::i_gif }, "foobar/test", "12345", dpp::i_png, 0, true, true) == "https://cdn.discordapp.com/foobar/test/a_12345.gif" && success; - success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png, dpp::i_gif }, "foobar/test", "", dpp::i_png, 0, true, true) == "https://cdn.discordapp.com/foobar/test.gif" && success; - success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png, dpp::i_gif }, "foobar/test", "", dpp::i_gif, 0, false, false).empty() && success; - set_test(UTILITY_CDN_ENDPOINT_URL_HASH, success); - } - { // sticker url getter set_test(STICKER_GET_URL, false); dpp::sticker s; @@ -666,116 +539,6 @@ int main(int argc, char *argv[]) ); } - { // utility methods - set_test(UTILITY_GUILD_NAVIGATION, false); - auto gn1 = dpp::utility::guild_navigation(123, dpp::utility::gnt_customize); - auto gn2 = dpp::utility::guild_navigation(1234, dpp::utility::gnt_browse); - auto gn3 = dpp::utility::guild_navigation(12345, dpp::utility::gnt_guide); - set_test(UTILITY_GUILD_NAVIGATION, gn1 == "<123:customize>" && gn2 == "<1234:browse>" && gn3 == "<12345:guide>"); - - set_test(UTILITY_ICONHASH, false); - auto iconhash1 = dpp::utility::iconhash("a_5532c6414c70765a28cf9448c117205f"); - set_test(UTILITY_ICONHASH, iconhash1.first == 6139187225817019994 && - iconhash1.second == 2940732121894297695 && - iconhash1.to_string() == "5532c6414c70765a28cf9448c117205f" - ); - - set_test(UTILITY_MAKE_URL_PARAMETERS, false); - auto url_params1 = dpp::utility::make_url_parameters({ - {"foo", 15}, - {"bar", 7} - }); - auto url_params2 = dpp::utility::make_url_parameters({ - {"foo", "hello"}, - {"bar", "two words"} - }); - set_test(UTILITY_MAKE_URL_PARAMETERS, url_params1 == "?bar=7&foo=15" && url_params2 == "?bar=two%20words&foo=hello"); - - set_test(UTILITY_MARKDOWN_ESCAPE, false); - auto escaped = dpp::utility::markdown_escape( - "> this is a quote\n" - "**some bold text**"); - set_test(UTILITY_MARKDOWN_ESCAPE, "\\>this is a quote\\n\\*\\*some bold text\\*\\*"); - - set_test(UTILITY_TOKENIZE, false); - auto tokens = dpp::utility::tokenize("some Whitespace seperated Text to Tokenize", " "); - std::vector expected_tokens = {"some", "Whitespace", "seperated", "Text", "to", "Tokenize"}; - set_test(UTILITY_TOKENIZE, tokens == expected_tokens); - - set_test(UTILITY_URL_ENCODE, false); - auto url_encoded = dpp::utility::url_encode("S2-^$1Nd+U!g'8+_??o?p-bla bla"); - set_test(UTILITY_URL_ENCODE, url_encoded == "S2-%5E%241Nd%2BU%21g%278%2B_%3F%3Fo%3Fp-bla%20bla"); - - set_test(UTILITY_SLASHCOMMAND_MENTION, false); - auto mention1 = dpp::utility::slashcommand_mention(123, "name"); - auto mention2 = dpp::utility::slashcommand_mention(123, "name", "sub"); - auto mention3 = dpp::utility::slashcommand_mention(123, "name", "group", "sub"); - bool success = mention1 == "" && mention2 == "" && mention3 == ""; - set_test(UTILITY_SLASHCOMMAND_MENTION, success); - - set_test(UTILITY_CHANNEL_MENTION, false); - auto channel_mention = dpp::utility::channel_mention(123); - set_test(UTILITY_CHANNEL_MENTION, channel_mention == "<#123>"); - - set_test(UTILITY_USER_MENTION, false); - auto user_mention = dpp::utility::user_mention(123); - set_test(UTILITY_USER_MENTION, user_mention == "<@123>"); - - set_test(UTILITY_ROLE_MENTION, false); - auto role_mention = dpp::utility::role_mention(123); - set_test(UTILITY_ROLE_MENTION, role_mention == "<@&123>"); - - set_test(UTILITY_EMOJI_MENTION, false); - auto emoji_mention1 = dpp::utility::emoji_mention("role1", 123, false); - auto emoji_mention2 = dpp::utility::emoji_mention("role2", 234, true); - auto emoji_mention3 = dpp::utility::emoji_mention("white_check_mark", 0, false); - auto emoji_mention4 = dpp::utility::emoji_mention("white_check_mark", 0, true); - set_test(UTILITY_EMOJI_MENTION, - emoji_mention1 == "<:role1:123>" && - emoji_mention2 == "" && - emoji_mention3 == ":white_check_mark:" && - emoji_mention4 == ":white_check_mark:" - ); - - set_test(UTILITY_USER_URL, false); - auto user_url = dpp::utility::user_url(123); - set_test(UTILITY_USER_URL, - user_url == dpp::utility::url_host + "/users/123" && - dpp::utility::user_url(0) == "" - ); - - set_test(UTILITY_MESSAGE_URL, false); - auto message_url = dpp::utility::message_url(1,2,3); - set_test(UTILITY_MESSAGE_URL, - message_url == dpp::utility::url_host+ "/channels/1/2/3" && - dpp::utility::message_url(0,2,3) == "" && - dpp::utility::message_url(1,0,3) == "" && - dpp::utility::message_url(1,2,0) == "" && - dpp::utility::message_url(0,0,3) == "" && - dpp::utility::message_url(0,2,0) == "" && - dpp::utility::message_url(1,0,0) == "" && - dpp::utility::message_url(0,0,0) == "" - ); - - set_test(UTILITY_CHANNEL_URL, false); - auto channel_url = dpp::utility::channel_url(1,2); - set_test(UTILITY_CHANNEL_URL, - channel_url == dpp::utility::url_host+ "/channels/1/2" && - dpp::utility::channel_url(0,2) == "" && - dpp::utility::channel_url(1,0) == "" && - dpp::utility::channel_url(0,0) == "" - ); - - set_test(UTILITY_THREAD_URL, false); - auto thread_url = dpp::utility::thread_url(1,2); - set_test(UTILITY_THREAD_URL, - thread_url == dpp::utility::url_host+ "/channels/1/2" && - dpp::utility::thread_url(0,2) == "" && - dpp::utility::thread_url(1,0) == "" && - dpp::utility::thread_url(0,0) == "" - ); - } - { set_test(TS, false); dpp::managed m(189759562910400512); diff --git a/src/unittest/test.h b/src/unittest/test.h index 1af3c9b0c5..629405e992 100644 --- a/src/unittest/test.h +++ b/src/unittest/test.h @@ -525,9 +525,17 @@ void http_unit_tests(const std::string& token); * - Base 64 encoding * - ts_to_string * - ts_not_null + * - All Utility tests + * - manged object comparison */ void utilities_unit_tests(); +/** + * @brief This unit test covers the following: + * - Human readable error translation + */ +void errors_unit_tests(); + /** * @brief A test version of the message collector for use in unit tests */ diff --git a/src/unittest/utilities.cpp b/src/unittest/utilities.cpp index 9e7c0bf864..56e8d901dc 100644 --- a/src/unittest/utilities.cpp +++ b/src/unittest/utilities.cpp @@ -77,4 +77,149 @@ Markdown lol \\|\\|spoiler\\|\\| \\~\\~strikethrough\\~\\~ \\`small \\*code\\* b tj["t2"] = "2022-01-19T17:18:14+00:00"; uint32_t inTimestamp = 1642612694; set_test(TIMESTRINGTOTIMESTAMP, (uint64_t)dpp::ts_not_null(&tj, "t1") == inTimestamp && (uint64_t)dpp::ts_not_null(&tj, "t2") == inTimestamp); + + { // utility methods + set_test(UTILITY_GUILD_NAVIGATION, false); + auto gn1 = dpp::utility::guild_navigation(123, dpp::utility::gnt_customize); + auto gn2 = dpp::utility::guild_navigation(1234, dpp::utility::gnt_browse); + auto gn3 = dpp::utility::guild_navigation(12345, dpp::utility::gnt_guide); + set_test(UTILITY_GUILD_NAVIGATION, gn1 == "<123:customize>" && gn2 == "<1234:browse>" && gn3 == "<12345:guide>"); + + set_test(UTILITY_ICONHASH, false); + auto iconhash1 = dpp::utility::iconhash("a_5532c6414c70765a28cf9448c117205f"); + set_test(UTILITY_ICONHASH, iconhash1.first == 6139187225817019994 && + iconhash1.second == 2940732121894297695 && + iconhash1.to_string() == "5532c6414c70765a28cf9448c117205f" + ); + + set_test(UTILITY_MAKE_URL_PARAMETERS, false); + auto url_params1 = dpp::utility::make_url_parameters({ + {"foo", 15}, + {"bar", 7} + }); + auto url_params2 = dpp::utility::make_url_parameters({ + {"foo", "hello"}, + {"bar", "two words"} + }); + set_test(UTILITY_MAKE_URL_PARAMETERS, url_params1 == "?bar=7&foo=15" && url_params2 == "?bar=two%20words&foo=hello"); + + set_test(UTILITY_MARKDOWN_ESCAPE, false); + auto escaped = dpp::utility::markdown_escape( + "> this is a quote\n" + "**some bold text**"); + set_test(UTILITY_MARKDOWN_ESCAPE, "\\>this is a quote\\n\\*\\*some bold text\\*\\*"); + + set_test(UTILITY_TOKENIZE, false); + auto tokens = dpp::utility::tokenize("some Whitespace seperated Text to Tokenize", " "); + std::vector expected_tokens = {"some", "Whitespace", "seperated", "Text", "to", "Tokenize"}; + set_test(UTILITY_TOKENIZE, tokens == expected_tokens); + + set_test(UTILITY_URL_ENCODE, false); + auto url_encoded = dpp::utility::url_encode("S2-^$1Nd+U!g'8+_??o?p-bla bla"); + set_test(UTILITY_URL_ENCODE, url_encoded == "S2-%5E%241Nd%2BU%21g%278%2B_%3F%3Fo%3Fp-bla%20bla"); + + set_test(UTILITY_SLASHCOMMAND_MENTION, false); + auto mention1 = dpp::utility::slashcommand_mention(123, "name"); + auto mention2 = dpp::utility::slashcommand_mention(123, "name", "sub"); + auto mention3 = dpp::utility::slashcommand_mention(123, "name", "group", "sub"); + bool success = mention1 == "" && mention2 == "" && mention3 == ""; + set_test(UTILITY_SLASHCOMMAND_MENTION, success); + + set_test(UTILITY_CHANNEL_MENTION, false); + auto channel_mention = dpp::utility::channel_mention(123); + set_test(UTILITY_CHANNEL_MENTION, channel_mention == "<#123>"); + + set_test(UTILITY_USER_MENTION, false); + auto user_mention = dpp::utility::user_mention(123); + set_test(UTILITY_USER_MENTION, user_mention == "<@123>"); + + set_test(UTILITY_ROLE_MENTION, false); + auto role_mention = dpp::utility::role_mention(123); + set_test(UTILITY_ROLE_MENTION, role_mention == "<@&123>"); + + set_test(UTILITY_EMOJI_MENTION, false); + auto emoji_mention1 = dpp::utility::emoji_mention("role1", 123, false); + auto emoji_mention2 = dpp::utility::emoji_mention("role2", 234, true); + auto emoji_mention3 = dpp::utility::emoji_mention("white_check_mark", 0, false); + auto emoji_mention4 = dpp::utility::emoji_mention("white_check_mark", 0, true); + set_test(UTILITY_EMOJI_MENTION, + emoji_mention1 == "<:role1:123>" && + emoji_mention2 == "" && + emoji_mention3 == ":white_check_mark:" && + emoji_mention4 == ":white_check_mark:" + ); + + set_test(UTILITY_USER_URL, false); + auto user_url = dpp::utility::user_url(123); + set_test(UTILITY_USER_URL, + user_url == dpp::utility::url_host + "/users/123" && + dpp::utility::user_url(0) == "" + ); + + set_test(UTILITY_MESSAGE_URL, false); + auto message_url = dpp::utility::message_url(1,2,3); + set_test(UTILITY_MESSAGE_URL, + message_url == dpp::utility::url_host+ "/channels/1/2/3" && + dpp::utility::message_url(0,2,3) == "" && + dpp::utility::message_url(1,0,3) == "" && + dpp::utility::message_url(1,2,0) == "" && + dpp::utility::message_url(0,0,3) == "" && + dpp::utility::message_url(0,2,0) == "" && + dpp::utility::message_url(1,0,0) == "" && + dpp::utility::message_url(0,0,0) == "" + ); + + set_test(UTILITY_CHANNEL_URL, false); + auto channel_url = dpp::utility::channel_url(1,2); + set_test(UTILITY_CHANNEL_URL, + channel_url == dpp::utility::url_host+ "/channels/1/2" && + dpp::utility::channel_url(0,2) == "" && + dpp::utility::channel_url(1,0) == "" && + dpp::utility::channel_url(0,0) == "" + ); + + set_test(UTILITY_THREAD_URL, false); + auto thread_url = dpp::utility::thread_url(1,2); + set_test(UTILITY_THREAD_URL, + thread_url == dpp::utility::url_host+ "/channels/1/2" && + dpp::utility::thread_url(0,2) == "" && + dpp::utility::thread_url(1,0) == "" && + dpp::utility::thread_url(0,0) == "" + ); + } + + { // avatar size function + set_test(UTILITY_AVATAR_SIZE, false); + bool success = false; + success = dpp::utility::avatar_size(0).empty(); + success = dpp::utility::avatar_size(16) == "?size=16" && success; + success = dpp::utility::avatar_size(256) == "?size=256" && success; + success = dpp::utility::avatar_size(4096) == "?size=4096" && success; + success = dpp::utility::avatar_size(8192).empty() && success; + success = dpp::utility::avatar_size(3000).empty() && success; + set_test(UTILITY_AVATAR_SIZE, success); + } + + { // cdn endpoint url getter + set_test(UTILITY_CDN_ENDPOINT_URL_HASH, false); + bool success = false; + success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png }, "foobar/test", "", dpp::i_jpg, 0).empty(); + success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png }, "foobar/test", "", dpp::i_png, 0) == "https://cdn.discordapp.com/foobar/test.png" && success; + success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png }, "foobar/test", "", dpp::i_png, 128) == "https://cdn.discordapp.com/foobar/test.png?size=128" && success; + success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png, dpp::i_gif }, "foobar/test", "12345", dpp::i_gif, 0, false, true) == "https://cdn.discordapp.com/foobar/test/a_12345.gif" && success; + success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png, dpp::i_gif }, "foobar/test", "12345", dpp::i_png, 0, false, true) == "https://cdn.discordapp.com/foobar/test/a_12345.png" && success; + success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png, dpp::i_gif }, "foobar/test", "12345", dpp::i_png, 0, false, false) == "https://cdn.discordapp.com/foobar/test/12345.png" && success; + success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png, dpp::i_gif }, "foobar/test", "12345", dpp::i_png, 0, true, true) == "https://cdn.discordapp.com/foobar/test/a_12345.gif" && success; + success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png, dpp::i_gif }, "foobar/test", "", dpp::i_png, 0, true, true) == "https://cdn.discordapp.com/foobar/test.gif" && success; + success = dpp::utility::cdn_endpoint_url_hash({ dpp::i_png, dpp::i_gif }, "foobar/test", "", dpp::i_gif, 0, false, false).empty() && success; + set_test(UTILITY_CDN_ENDPOINT_URL_HASH, success); + } + + set_test(COMPARISON, false); + dpp::user u1; + dpp::user u2; + dpp::user u3; + u1.id = u2.id = 666; + u3.id = 777; + set_test(COMPARISON, u1 == u2 && u1 != u3); }