blob: 6d9cee031cbf3c8729ce12672d24b22b053b6a9b [file] [log] [blame]
Andrew Geissler3b025e62019-02-01 10:33:54 -06001#include "src/processing.hpp"
2
3#include <gtest/gtest.h>
4
5// Verify if name does not start with a : that it is returned
6TEST(WellKnownName, NameNotStartColon)
7{
8 boost::container::flat_map<std::string, std::string> owners;
9 const std::string request = "test";
Brad Bishopa098a372022-05-05 15:19:04 -040010 std::string wellKnown;
Andrew Geissler3b025e62019-02-01 10:33:54 -060011
Brad Bishopa098a372022-05-05 15:19:04 -040012 EXPECT_TRUE(getWellKnown(owners, request, wellKnown));
13 EXPECT_EQ(wellKnown, request);
Andrew Geissler3b025e62019-02-01 10:33:54 -060014}
15
16// Verify if name is not found, false is returned
17TEST(WellKnownName, NameNotFound)
18{
19 boost::container::flat_map<std::string, std::string> owners;
20 const std::string request = ":test";
Brad Bishopa098a372022-05-05 15:19:04 -040021 std::string wellKnown;
Andrew Geissler3b025e62019-02-01 10:33:54 -060022
Brad Bishopa098a372022-05-05 15:19:04 -040023 EXPECT_FALSE(getWellKnown(owners, request, wellKnown));
24 EXPECT_TRUE(wellKnown.empty());
Andrew Geissler3b025e62019-02-01 10:33:54 -060025}
26
27// Verify if name is found, true is returned and name is correct
28TEST(WellKnownName, NameFound)
29{
30 boost::container::flat_map<std::string, std::string> owners;
31 const std::string request = ":1.25";
Brad Bishopa098a372022-05-05 15:19:04 -040032 std::string wellKnown;
Andrew Geissler3b025e62019-02-01 10:33:54 -060033
34 owners[request] = "test";
Brad Bishopa098a372022-05-05 15:19:04 -040035 EXPECT_TRUE(getWellKnown(owners, request, wellKnown));
36 EXPECT_EQ(wellKnown, "test");
Andrew Geissler3b025e62019-02-01 10:33:54 -060037}