Skip to content

Commit

Permalink
Adding passing unit test for Boltable, in which Boltable is declared …
Browse files Browse the repository at this point in the history
…before target context.
  • Loading branch information
Gabriel Hare committed Aug 5, 2014
1 parent 5501b5e commit d695ea1
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions src/autowiring/test/BoltTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -194,3 +194,32 @@ TEST_F(BoltTest, EmptyBolt) {
ASSERT_EQ(1, innerSo->count) << "ContextCreated() called incorrect number of times";
}
}

class PipelineBoltable: public Boltable<Pipeline> {
static int numCons;
static int numDest;

public:
static int ConstructedNum() {return numCons;}
static int DestructedNum() {return numDest;}

PipelineBoltable() {++numCons;}
~PipelineBoltable() {++numDest;}
};
int PipelineBoltable::numCons = 0;
int PipelineBoltable::numDest = 0;

TEST_F(BoltTest, BoltBeforeContext) {
AutoCurrentContext ctxt;
AutoEnable<PipelineBoltable>();
ASSERT_EQ(0, PipelineBoltable::ConstructedNum()) << "Instantiated Boltable without context";
auto otherCtx = ctxt->Create<OtherContext>();
ASSERT_EQ(0, PipelineBoltable::ConstructedNum()) << "Instantiated on creation of unmatched context";

{
auto created = ctxt->Create<Pipeline>();
ASSERT_EQ(1, PipelineBoltable::ConstructedNum()) << "Failed to instantiate on creation of matching context";
}
ASSERT_EQ(1, PipelineBoltable::DestructedNum()) << "Failed to be destroyed with matching context";
}

0 comments on commit d695ea1

Please sign in to comment.