Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 1 | #include "src/processing.hpp" |
| 2 | |
| 3 | #include <gtest/gtest.h> |
| 4 | |
| 5 | // Verify if name does not start with a : that it is returned |
| 6 | TEST(WellKnownName, NameNotStartColon) |
| 7 | { |
| 8 | boost::container::flat_map<std::string, std::string> owners; |
| 9 | const std::string request = "test"; |
Brad Bishop | a098a37 | 2022-05-05 15:19:04 -0400 | [diff] [blame] | 10 | std::string wellKnown; |
Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 11 | |
Brad Bishop | a098a37 | 2022-05-05 15:19:04 -0400 | [diff] [blame] | 12 | EXPECT_TRUE(getWellKnown(owners, request, wellKnown)); |
| 13 | EXPECT_EQ(wellKnown, request); |
Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 14 | } |
| 15 | |
| 16 | // Verify if name is not found, false is returned |
| 17 | TEST(WellKnownName, NameNotFound) |
| 18 | { |
| 19 | boost::container::flat_map<std::string, std::string> owners; |
| 20 | const std::string request = ":test"; |
Brad Bishop | a098a37 | 2022-05-05 15:19:04 -0400 | [diff] [blame] | 21 | std::string wellKnown; |
Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 22 | |
Brad Bishop | a098a37 | 2022-05-05 15:19:04 -0400 | [diff] [blame] | 23 | EXPECT_FALSE(getWellKnown(owners, request, wellKnown)); |
| 24 | EXPECT_TRUE(wellKnown.empty()); |
Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 25 | } |
| 26 | |
| 27 | // Verify if name is found, true is returned and name is correct |
| 28 | TEST(WellKnownName, NameFound) |
| 29 | { |
| 30 | boost::container::flat_map<std::string, std::string> owners; |
| 31 | const std::string request = ":1.25"; |
Brad Bishop | a098a37 | 2022-05-05 15:19:04 -0400 | [diff] [blame] | 32 | std::string wellKnown; |
Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 33 | |
| 34 | owners[request] = "test"; |
Brad Bishop | a098a37 | 2022-05-05 15:19:04 -0400 | [diff] [blame] | 35 | EXPECT_TRUE(getWellKnown(owners, request, wellKnown)); |
| 36 | EXPECT_EQ(wellKnown, "test"); |
Andrew Geissler | 3b025e6 | 2019-02-01 10:33:54 -0600 | [diff] [blame] | 37 | } |