Skip to content

Commit

Permalink
Merge pull request #769 from leapmotion/test-awadvertise
Browse files Browse the repository at this point in the history
Add a test to assure post-hoc type advertisement behaviors are correct
  • Loading branch information
jdonald committed Oct 5, 2015
2 parents 456e538 + 935eed6 commit 038aa00
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/autowiring/test/AutowiringTest.cpp
Expand Up @@ -99,6 +99,8 @@ class DynamicCastDerivedType : public PublicBase, private PrivateBase {
public:
DynamicCastDerivedType(void) {}
~DynamicCastDerivedType(void) {}

FRIEND_TEST(AutowiringTest, PostHocTypeAdvertisement);
};

TEST_F(AutowiringTest, TestFailureOfDynamicCast) {
Expand All @@ -109,6 +111,21 @@ TEST_F(AutowiringTest, TestFailureOfDynamicCast) {
static_assert(!std::is_base_of<DynamicCastDerivedType, PrivateBase>::value, "is_base_of said a private base was a base");
}

TEST_F(AutowiringTest, PostHocTypeAdvertisement) {
AutoCurrentContext ctxt;
AutoRequired<DynamicCastDerivedType> dcdt;
Autowired<PrivateBase> pb;

ASSERT_FALSE(pb.IsAutowired()) << "Private base type was present in the context before it was advertised";
ctxt->Add(
std::shared_ptr<PrivateBase>{
dcdt,
static_cast<PrivateBase*>(dcdt.get())
}
);
ASSERT_TRUE(pb.IsAutowired()) << "Type was not autowired after an injection event took place that should have made it available";
}

class CompletelyUndefinedType;

TEST_F(AutowiringTest, CanAutowireCompletelyUndefinedType) {
Expand Down

0 comments on commit 038aa00

Please sign in to comment.