Skip to content

Commit

Permalink
Add two additional tests to AutoConfigTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Walter Gray committed Jul 6, 2016
1 parent 7809396 commit 41ee407
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/autowiring/test/AutoConfigTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ namespace {
}
};

class DuplicateClass {
public:
autowiring::config<std::string> a { "Hello world" };

static autowiring::config_descriptor GetConfigDescriptor(void) {
return{
{ "a", "Field A description 2", &DuplicateClass::a, aw::default_value<std::string>("Hello universe!")}
};
}
};

class BadClass {
public:
autowiring::config_descriptor GetConfigDescriptor(void) { return{}; }
Expand Down Expand Up @@ -191,6 +202,33 @@ TEST_F(AutoConfigTest, ContextSetAfter) {
ASSERT_EQ(mcc->b, 10442);
}

TEST_F(AutoConfigTest, ContextGetSimple) {
AutoCurrentContext ctxt;
AutoRequired<MyConfigurableClass> mcc;

mcc->b = 10442;
EXPECT_EQ("10442", ctxt->Config.Get("b")) << "Value not set in the context correctly";

ctxt->Config.Set("b", "10443");
EXPECT_EQ(10443, mcc->b);
}

TEST_F(AutoConfigTest, ContextMultiReference) {
AutoCurrentContext ctxt;
AutoRequired<MyConfigurableClass> mcc;
AutoRequired<DuplicateClass> dc;

const auto expectStr1 = "Hello Multiverse";
mcc->a = expectStr1;
EXPECT_STREQ(expectStr1, dc->a->c_str());
EXPECT_STREQ(expectStr1, ctxt->Config.Get("a").c_str());

const auto expectStr2 = "Hello Universe 616";
ctxt->Config.Set("a", expectStr2);
EXPECT_STREQ(expectStr2, mcc->a->c_str());
EXPECT_STREQ(expectStr2, dc->a->c_str());
}

namespace {
class slider
{
Expand Down

0 comments on commit 41ee407

Please sign in to comment.