Skip to content

Commit

Permalink
Reduce test failure output clutter
Browse files Browse the repository at this point in the history
Every single one of these must pass, and later failures tend to just contaminate the output with useless messaging.  Tighten down from `EXPECT` to `ASSERT` wherever successive failures reveal no additional information--which, in our case, is _all_ of them.
  • Loading branch information
codemercenary committed Jun 6, 2015
1 parent 7dfa15b commit 9858ab5
Show file tree
Hide file tree
Showing 28 changed files with 221 additions and 222 deletions.
4 changes: 2 additions & 2 deletions src/autowiring/test/AnySharedPointerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ TEST_F(AnySharedPointerTest, SlotReassignment) {

// Recast to another shared pointer, verify reference count goes down:
slot = sharedPointerB;
EXPECT_EQ(2, sharedPointerB.use_count()) << "Reference count was not incremented properly during a shared pointer hold";
ASSERT_EQ(2, sharedPointerB.use_count()) << "Reference count was not incremented properly during a shared pointer hold";
ASSERT_TRUE(sharedPointerA.unique()) << "Destructor was not properly invoked for a shared pointer slot";

// Now change the type completely, verify proper release:
Expand Down Expand Up @@ -128,7 +128,7 @@ TEST_F(AnySharedPointerTest, SlotDuplication) {
ASSERT_FALSE(slot1->empty()) << "A slot initialized from a shared pointer was incorrectly marked as empty";

// Verify the type came across:
EXPECT_EQ(typeid(auto_id<bool>), slot1->type()) << "Dynamic initialization did not correctly adjust the dynamic type";
ASSERT_EQ(typeid(auto_id<bool>), slot1->type()) << "Dynamic initialization did not correctly adjust the dynamic type";

// Now copy it over:
slot2 = slot1;
Expand Down
4 changes: 2 additions & 2 deletions src/autowiring/test/AutoConfigListingTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -187,8 +187,8 @@ TEST_F(AutoConfigListingTest, NestedContexts) {
ASSERT_EQ(42, *mcc_sibling->cfg) << "Config value not set in descendant context";
ASSERT_EQ(42, *mcc_inner->cfg) << "Config value not set in descendant context";
ASSERT_EQ(42, *mcc_leaf->cfg) << "Config value not set in desendant context";
EXPECT_TRUE(acm_middle->IsInherited("Namespace1.XYZ")) << "Inherited key not marked as such";
EXPECT_TRUE(acm_leaf->IsInherited("Namespace1.XYZ")) << "Inherited key not marked as such";
ASSERT_TRUE(acm_middle->IsInherited("Namespace1.XYZ")) << "Inherited key not marked as such";
ASSERT_TRUE(acm_leaf->IsInherited("Namespace1.XYZ")) << "Inherited key not marked as such";

// Set middle, inner shouldn't be able to be set from outer after this
bool callback_hit1 = false;
Expand Down
2 changes: 1 addition & 1 deletion src/autowiring/test/AutoConfigParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ struct MyConfigurableClass {
TEST_F(AutoConfigParserTest, VerifyCorrectDeconstruction) {
AutoRequired<MyConfigurableClass> mcc;

EXPECT_STREQ("Namespace1.XYZ", mcc->m_myName->m_key.c_str())
ASSERT_STREQ("Namespace1.XYZ", mcc->m_myName->m_key.c_str())
<< "Configuration variable name was not correctly extracted";
}
4 changes: 2 additions & 2 deletions src/autowiring/test/AutoConfigTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,8 @@ TEST_F(AutoConfigTest, NestedContexts) {
ASSERT_EQ(42, *mcc_sibling->cfg) << "Config value not set in descendant context";
ASSERT_EQ(42, *mcc_inner->cfg) << "Config value not set in descendant context";
ASSERT_EQ(42, *mcc_leaf->cfg) << "Config value not set in desendant context";
EXPECT_TRUE(mcc_middle->cfg->IsInherited()) << "Inherited key not marked as such";
EXPECT_TRUE(mcc_leaf->cfg->IsInherited()) << "Inherited key not marked as such";
ASSERT_TRUE(mcc_middle->cfg->IsInherited()) << "Inherited key not marked as such";
ASSERT_TRUE(mcc_leaf->cfg->IsInherited()) << "Inherited key not marked as such";

// Set middle, inner shouldn't be able to be set from outer after this
bool callback_hit1 = false;
Expand Down
4 changes: 2 additions & 2 deletions src/autowiring/test/AutoFilterSequencing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ class PrevFilter {
void AutoFilter(int current, auto_prev<int> prev) {
++m_called;
if (prev) {
EXPECT_EQ(m_prev_value, *prev) << "auto_prev isn't set to the previous value";
ASSERT_EQ(m_prev_value, *prev) << "auto_prev isn't set to the previous value";
} else {
m_num_empty_prev++;
}
Expand Down Expand Up @@ -279,7 +279,7 @@ class PrevPrevFilter {
void AutoFilter(int current, auto_prev<int, 2> prev) {
++m_called;
if (prev) {
EXPECT_EQ(m_prev_prev_value, *prev) << "auto_prev isn't set to the previous value";
ASSERT_EQ(m_prev_prev_value, *prev) << "auto_prev isn't set to the previous value";
} else {
m_num_empty_prev++;
}
Expand Down
43 changes: 21 additions & 22 deletions src/autowiring/test/AutoFilterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,13 @@ TEST_F(AutoFilterTest, VerifySimpleFilter) {
packet->Decorate(Decoration<0>());

// Verify that no hit takes place with inadequate decoration:
EXPECT_FALSE(filterA->m_called) << "Filter called prematurely with insufficient decoration";
ASSERT_FALSE(filterA->m_called) << "Filter called prematurely with insufficient decoration";

// Now decorate with the other requirement of the filter:
packet->Decorate(Decoration<1>());

// A hit should have taken place at this point:
EXPECT_LT(0, filterA->m_called) << "Filter was not called even though it was fully satisfied";
ASSERT_LT(0, filterA->m_called) << "Filter was not called even though it was fully satisfied";
}

template<int N>
Expand All @@ -76,7 +76,7 @@ TEST_F(AutoFilterTest, VerifyTypeUsage) {
ASSERT_EQ(0, filterA->m_called) << "AutoFilter called with incomplete arguments";
packet->Decorate(ChildDecoration<1>()); // Does not fulfill second requirement
ASSERT_EQ(0, filterA->m_called) << "AutoFilter using derived type";
EXPECT_NO_THROW(packet->Decorate(Decoration<1>(2))) << "Decoration with parent type conflicts with derived type";
ASSERT_NO_THROW(packet->Decorate(Decoration<1>(2))) << "Decoration with parent type conflicts with derived type";
ASSERT_EQ(1, filterA->m_called) << "AutoFilter was not called when all arguments were available";
ASSERT_EQ(2, filterA->m_one.i) << "AutoFilter was called using derived type instead of parent";
}
Expand Down Expand Up @@ -123,22 +123,22 @@ TEST_F(AutoFilterTest, VerifyNoMultiDecorate) {
// Obtain a packet and attempt redundant introduction:
auto packet = factory->NewPacket();
packet->Decorate(Decoration<0>());
EXPECT_ANY_THROW(packet->Decorate(Decoration<0>())) << "Redundant decoration did not throw an exception as expected";
ASSERT_ANY_THROW(packet->Decorate(Decoration<0>())) << "Redundant decoration did not throw an exception as expected";

// Verify that a call has not yet been made
EXPECT_FALSE(filterA->m_called) << "A call made on an idempotent packet decoration";
ASSERT_FALSE(filterA->m_called) << "A call made on an idempotent packet decoration";

// Now finish saturating the filter and ensure we get a call:
packet->Decorate(Decoration<1>());
EXPECT_LT(0, filterA->m_called) << "Filter was not called after being fully satisfied";
ASSERT_LT(0, filterA->m_called) << "Filter was not called after being fully satisfied";

//NOTE: A typedef will throw an exception
typedef Decoration<0> isDeco0type;
EXPECT_ANY_THROW(packet->Decorate(isDeco0type())) << "Typedef failed to throw exception";
ASSERT_ANY_THROW(packet->Decorate(isDeco0type())) << "Typedef failed to throw exception";

//NOTE: A shared_ptr to an existing type will throw an exception
auto sharedDeco0 = std::make_shared<Decoration<0>>();
EXPECT_ANY_THROW(packet->Decorate(sharedDeco0)) << "Reduction of shared_ptr to base type failed";
ASSERT_ANY_THROW(packet->Decorate(sharedDeco0)) << "Reduction of shared_ptr to base type failed";

//NOTE: Inheritance will not throw an exception
class ofDeco0alias: public Decoration<0> {};
Expand All @@ -150,9 +150,8 @@ TEST_F(AutoFilterTest, VerifyNoMultiDecorate) {

// Verify that DecorateImmedaite also yields an exception
Decoration<0> localDeco0;
EXPECT_ANY_THROW(packet->DecorateImmediate(localDeco0)) << "Redundant immediate decoration did not throw an exception as expected";

EXPECT_ANY_THROW(packet->DecorateImmediate(Decoration<2>(), Decoration<2>())) << "Repeated type in immediate decoration was not identified as an error";
ASSERT_ANY_THROW(packet->DecorateImmediate(localDeco0)) << "Redundant immediate decoration did not throw an exception as expected";
ASSERT_ANY_THROW(packet->DecorateImmediate(Decoration<2>(), Decoration<2>())) << "Repeated type in immediate decoration was not identified as an error";
}

TEST_F(AutoFilterTest, VerifyInterThreadDecoration) {
Expand All @@ -166,15 +165,15 @@ TEST_F(AutoFilterTest, VerifyInterThreadDecoration) {
packet->Decorate(Decoration<1>());

// Verify that the recipient has NOT yet received the message:
EXPECT_FALSE(filterB->m_called) << "A call was made to a thread which should not have been able to process it";
ASSERT_FALSE(filterB->m_called) << "A call was made to a thread which should not have been able to process it";

// Wake up the barrier and post a quit message:
filterB->Continue();
*filterB += [&filterB] { filterB->Stop(); };
filterB->Wait();

// Verify that the filter method has been called
EXPECT_LT(0, filterB->m_called) << "A deferred filter method was not called as expected";
ASSERT_LT(0, filterB->m_called) << "A deferred filter method was not called as expected";
}

TEST_F(AutoFilterTest, VerifyTeardownArrangement) {
Expand Down Expand Up @@ -231,14 +230,14 @@ TEST_F(AutoFilterTest, VerifyAntiDecorate) {
// Obtain a new packet and mark an unsatisfiable decoration:
auto packet = factory->NewPacket();
packet->Unsatisfiable<Decoration<0>>();
EXPECT_ANY_THROW(packet->Decorate(Decoration<0>())) << "Decoration succeeded on a decoration marked unsatisfiable";
ASSERT_ANY_THROW(packet->Decorate(Decoration<0>())) << "Decoration succeeded on a decoration marked unsatisfiable";
}

{
// Obtain a new packet and try to make a satisfied decoration unsatisfiable.
auto packet = factory->NewPacket();
packet->Decorate(Decoration<0>());
EXPECT_ANY_THROW(packet->Unsatisfiable<Decoration<0>>()) << "Succeeded in marking an already-existing decoration as unsatisfiable";
ASSERT_ANY_THROW(packet->Unsatisfiable<Decoration<0>>()) << "Succeeded in marking an already-existing decoration as unsatisfiable";
}
}

Expand Down Expand Up @@ -275,21 +274,21 @@ TEST_F(AutoFilterTest, VerifyReflexiveReciept) {
auto packet = factory->NewPacket();

// The mere act of obtaining a packet should have triggered filterD to be fired:
EXPECT_LT(0, filterD->m_called) << "Trivial filter with AutoPacket argument was not called as expected";
EXPECT_NO_THROW(packet->Get<Decoration<2>>()) << "Decoration on creation failed";
ASSERT_LT(0, filterD->m_called) << "Trivial filter with AutoPacket argument was not called as expected";
ASSERT_NO_THROW(packet->Get<Decoration<2>>()) << "Decoration on creation failed";

// The mere act of obtaining a packet should have triggered filterD to be fired:
EXPECT_LT(0, filterE->m_called) << "Trivial filter with no arguments was not called as expected";
ASSERT_LT(0, filterE->m_called) << "Trivial filter with no arguments was not called as expected";

// The mere act of obtaining a packet should have triggered filterD to be fired:
EXPECT_LT(0, filterD->m_called) << "Trivial filter was not called as expected";
ASSERT_LT(0, filterD->m_called) << "Trivial filter was not called as expected";

// Decorate--should satisfy filterC
packet->Decorate(Decoration<0>());
EXPECT_LT(0, filterC->m_called) << "FilterC should have been satisfied with one decoration";
ASSERT_LT(0, filterC->m_called) << "FilterC should have been satisfied with one decoration";

// FilterC should have also satisfied filterA:
EXPECT_LT(0, filterA->m_called) << "FilterA should have been satisfied by FilterC";
ASSERT_LT(0, filterA->m_called) << "FilterA should have been satisfied by FilterC";
}

TEST_F(AutoFilterTest, VerifyReferenceBasedInput) {
Expand Down Expand Up @@ -566,7 +565,7 @@ TEST_F(AutoFilterTest, PostHocSatisfactionAttempt) {

packet1->DecorateImmediate(Decoration<2>());

EXPECT_LT(0, fg2->m_called) << "An AutoFilter was not called when all of its inputs were simultaneously available";
ASSERT_LT(0, fg2->m_called) << "An AutoFilter was not called when all of its inputs were simultaneously available";
}

TEST_F(AutoFilterTest, AutoOutTest) {
Expand Down
2 changes: 1 addition & 1 deletion src/autowiring/test/AutoParameterTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ TEST_F(AutoParameterTest, VerifyCorrectDeconstruction) {
AutoRequired<MyParamClass1> mpc;
auto& param = mpc->m_param;
EXPECT_STREQ("AutoParam.MyParamClass1::MyIntParam1", param.m_key.c_str())
ASSERT_STREQ("AutoParam.MyParamClass1::MyIntParam1", param.m_key.c_str())
<< "Configuration variable name was not correctly extracted";
}
Expand Down
4 changes: 2 additions & 2 deletions src/autowiring/test/AutowiringTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -168,14 +168,14 @@ TEST_F(AutowiringTest, StaticNewWithArgs) {
AutoCreateContext ctxt;
ASSERT_NO_THROW(ctxt->Inject<StaticNewInt>()) << "Exception throws while injecting member";
AutowiredFast<StaticNewInt> obj(ctxt);
EXPECT_EQ(42, obj->getValue()) << "Wrong constructor called";
ASSERT_EQ(42, obj->getValue()) << "Wrong constructor called";
ctxt->SignalShutdown(true);
}
{
AutoCreateContext ctxt;
ASSERT_NO_THROW(auto obj = ctxt->Inject<StaticNewInt>(std::unique_ptr<int>(new int(1337)))) << "Exception throws while injecting member";
AutowiredFast<StaticNewInt> obj(ctxt);
EXPECT_EQ(1337, obj->getValue()) << "Wrong constructor called";
ASSERT_EQ(1337, obj->getValue()) << "Wrong constructor called";
ctxt->SignalShutdown(true);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/autowiring/test/AutowiringUtilitiesTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class Thread1:
virtual void Run(){
s_thread_specific_int.reset(new int(4));
std::this_thread::sleep_for(std::chrono::milliseconds(50));
EXPECT_EQ(4, *s_thread_specific_int);
ASSERT_EQ(4, *s_thread_specific_int);
}
};

Expand All @@ -28,7 +28,7 @@ class Thread2:
virtual void Run() {
s_thread_specific_int.reset(new int(3));
std::this_thread::sleep_for(std::chrono::milliseconds(50));
EXPECT_EQ(3, *s_thread_specific_int);
ASSERT_EQ(3, *s_thread_specific_int);
}
};

Expand All @@ -46,6 +46,6 @@ TEST_F(AutowiringUtilitiesTest, ThreadSpecificPtr) {

std::this_thread::sleep_for(std::chrono::milliseconds(50));

EXPECT_EQ(5, *s_thread_specific_int);
ASSERT_EQ(5, *s_thread_specific_int);
AutoCurrentContext()->SignalShutdown(true);
}
12 changes: 6 additions & 6 deletions src/autowiring/test/BoltTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ TEST_F(BoltTest, VerifySimpleInjection) {
// Verify that the SimpleObject didn't accidentally get injected out here:
{
Autowired<SimpleObject> so;
EXPECT_FALSE(so.IsAutowired()) << "Object was injected into an outer scope by a bolt";
ASSERT_FALSE(so.IsAutowired()) << "Object was injected into an outer scope by a bolt";
}

// Verify that the objecT DID get autowired where we expected it to be autowired
Expand All @@ -116,10 +116,10 @@ TEST_F(BoltTest, VerifyMapping) {
std::shared_ptr<CoreContext> createdContext = simpleCreator.CreateContext(L"Simple2").first;

// Verify we have a hit our bolt:
EXPECT_TRUE(myListener->hit) << "The listener callback was not hit as expected";
ASSERT_TRUE(myListener->hit) << "The listener callback was not hit as expected";

// Verify that the correct context was created:
EXPECT_EQ(createdContext, myListener->createdContext) << "The context set to current for the listener callback was not the context that got created";
ASSERT_EQ(createdContext, myListener->createdContext) << "The context set to current for the listener callback was not the context that got created";
}

TEST_F(BoltTest, VerifyCreationBubbling) {
Expand All @@ -143,7 +143,7 @@ TEST_F(BoltTest, VerifyCreationBubbling) {
simpleCreator->CreateContext(L"Simple");

// Check the listener to verify we had a hit:
EXPECT_TRUE(listener->hit) << "The listener callback was not hit as expected";
ASSERT_TRUE(listener->hit) << "The listener callback was not hit as expected";
}

TEST_F(BoltTest, VerifyMultipleInjection) {
Expand All @@ -156,7 +156,7 @@ TEST_F(BoltTest, VerifyMultipleInjection) {
// Verify that the SimpleObject didn't accidentally get injected out here:
{
Autowired<SimpleObject> so;
EXPECT_FALSE(so.IsAutowired()) << "Object was injected into an outer scope by a bolt";
ASSERT_FALSE(so.IsAutowired()) << "Object was injected into an outer scope by a bolt";
}

// Verify that the objecT DID get autowired where we expected it to be autowired
Expand All @@ -176,7 +176,7 @@ TEST_F(BoltTest, EmptyBolt) {
AutoCurrentContext ctxt;
AutoEnable<InjectsIntoEverything>();
Autowired<CountObject> so;
EXPECT_FALSE(so.IsAutowired()) << "CountObject injected into outer context";
ASSERT_FALSE(so.IsAutowired()) << "CountObject injected into outer context";

AutoCreateContext created;
{
Expand Down
Loading

0 comments on commit 9858ab5

Please sign in to comment.