#include "catch/catch.hpp" #include #include namespace bts { int security_tests = 0; namespace securities { TEST_CASE ("Security name formatting tests" , "[securities]") { SECTION("FB") { std::string example = "GE:FB 02Y H0"; std::regex rx ("(\\w+)\\:FB (\\d+)Y (\\w+)"); std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; } SECTION("BS") { std::string example = "GE:BS 2YH0 2YH2"; std::regex rx("(\\w+)\\:BS (\\d+)Y(\\w+) (\\d+)Y(\\w+)"); std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; } SECTION("BF") { std::string example = "GE:BF Z4-U5-M6"; std::regex rx("(\\w+)\\:BF (\\w+)-(\\w+)-(\\w+)"); std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; } SECTION("CF") { std::string example = "GE:CF H0H1H2H3"; std::regex rx("(\\w+)\\:CF (\\w\\w)(\\w\\w)(\\w\\w)(\\w\\w)"); std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; } SECTION("DF") { std::string example = "GE:DF Z7H8M8U8"; std::regex rx("(\\w+)\\:DF (\\w\\w)(\\w\\w)(\\w\\w)(\\w\\w)"); std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; } SECTION("MP") { std::string example = "GE:MP H0 1YM0"; std::regex rx("(\\w+)\\:MP (\\w\\w) \\w\\w(\\w\\w)"); std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; } SECTION("PB") { std::string example = "GE:PB Z7-Z8-Z9"; std::regex rx("(\\w+)\\:PB (\\w\\w)-(\\w\\w)-(\\w\\w)"); std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; } SECTION("PS") { std::string example = "GE:PS H0-H1"; std::regex rx("(\\w+)\\:PS (\\w\\w)-(\\w\\w)"); std::smatch matches; REQUIRE(std::regex_match(example,matches,rx)); // for (auto const &m : matches) // std::cout << "match: " << m.str() << "\n"; } } }}