Mercurial > hg > orthanc
diff UnitTests/main.cpp @ 452:80f7539147a2
WaitEmpty
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Thu, 04 Jul 2013 11:48:02 +0200 |
parents | 58b433bb9762 |
children | 30086c1aca30 |
line wrap: on
line diff
--- a/UnitTests/main.cpp Thu Jul 04 09:53:15 2013 +0200 +++ b/UnitTests/main.cpp Thu Jul 04 11:48:02 2013 +0200 @@ -419,18 +419,21 @@ TEST(SharedMessageQueue, Basic) { SharedMessageQueue q; + ASSERT_TRUE(q.WaitEmpty(0)); q.Enqueue(new DynamicInteger(10)); + ASSERT_FALSE(q.WaitEmpty(1)); q.Enqueue(new DynamicInteger(20)); q.Enqueue(new DynamicInteger(30)); q.Enqueue(new DynamicInteger(40)); std::auto_ptr<DynamicInteger> i; - i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(10))); ASSERT_EQ(10, i->GetValue()); - i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(10))); ASSERT_EQ(20, i->GetValue()); - i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(10))); ASSERT_EQ(30, i->GetValue()); - i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(10))); ASSERT_EQ(40, i->GetValue()); - - ASSERT_EQ(NULL, q.Dequeue(10)); + i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(10, i->GetValue()); + i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(20, i->GetValue()); + i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(30, i->GetValue()); + ASSERT_FALSE(q.WaitEmpty(1)); + i.reset(dynamic_cast<DynamicInteger*>(q.Dequeue(1))); ASSERT_EQ(40, i->GetValue()); + ASSERT_TRUE(q.WaitEmpty(0)); + ASSERT_EQ(NULL, q.Dequeue(1)); }