#include "verb.hpp" #include #include #include #include #include using BoostVerb = boost::beast::http::verb; TEST(BoostToHttpVerb, ValidCase) { std::map verbMap = { {HttpVerb::Delete, BoostVerb::delete_}, {HttpVerb::Get, BoostVerb::get}, {HttpVerb::Head, BoostVerb::head}, {HttpVerb::Options, BoostVerb::options}, {HttpVerb::Patch, BoostVerb::patch}, {HttpVerb::Post, BoostVerb::post}, {HttpVerb::Put, BoostVerb::put}, }; for (int verbIndex = 0; verbIndex < static_cast(HttpVerb::Max); ++verbIndex) { HttpVerb httpVerb = static_cast(verbIndex); std::optional verb = httpVerbFromBoost(verbMap[httpVerb]); EXPECT_EQ(verb, httpVerb); } } TEST(BoostToHttpVerbTest, InvalidCase) { std::optional verb = httpVerbFromBoost(BoostVerb::unknown); EXPECT_FALSE(verb.has_value()); } TEST(HttpVerbToStringTest, ValidCase) { std::map verbMap = { {HttpVerb::Delete, "DELETE"}, {HttpVerb::Get, "GET"}, {HttpVerb::Head, "HEAD"}, {HttpVerb::Options, "OPTIONS"}, {HttpVerb::Patch, "PATCH"}, {HttpVerb::Post, "POST"}, {HttpVerb::Put, "PUT"}, }; for (int verbIndex = 0; verbIndex < static_cast(HttpVerb::Max); ++verbIndex) { HttpVerb httpVerb = static_cast(verbIndex); EXPECT_EQ(httpVerbToString(httpVerb), verbMap[httpVerb]); } }