MCPcopy Create free account
hub / github.com/OpenNI/OpenNI / TEST

Function TEST

Testing/OpenNITester/QueueTests.cpp:37–100  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35typedef XnQueueT<XnQueueTestStruct*> XnQueueTestStructPtr_Queue;
36
37TEST(QueueTests, TestAll)
38{
39 XnStatus nRetVal = XN_STATUS_OK;
40
41 XnQueueTestStruct_Queue queue;
42
43 XnQueueTestStruct temp1;
44 temp1.nValue = 2;
45 temp1.dValue = 4.2;
46 nRetVal = queue.Push(temp1);
47 EXPECT_EQ(nRetVal, XN_STATUS_OK);
48 EXPECT_EQ(queue.Size(), 1);
49
50 XnQueueTestStruct& rTop = queue.Top();
51 // make sure we got same values
52 EXPECT_EQ(rTop.nValue, temp1.nValue);
53 EXPECT_EQ(rTop.dValue, temp1.dValue);
54
55 // make sure element is still in the queue
56 EXPECT_EQ(queue.Size(), 1);
57
58 // make sure the reference is to the actual stored element
59 rTop.nValue = 5;
60
61 XnQueueTestStruct& rTop2 = queue.Top();
62 EXPECT_EQ(rTop2.nValue, 5);
63
64 // add another one
65 XnQueueTestStruct temp2;
66 temp2.nValue = 13;
67 temp2.dValue = 0.6;
68 nRetVal = queue.Push(temp2);
69 EXPECT_EQ(nRetVal, XN_STATUS_OK);
70 EXPECT_EQ(queue.Size(), 2);
71
72 // make sure top is still temp1
73 XnQueueTestStruct& rTop3 = queue.Top();
74 EXPECT_EQ(rTop3.nValue, 5);
75 EXPECT_EQ(rTop3.dValue, temp1.dValue);
76
77 // pop an element
78 XnQueueTestStruct top;
79 nRetVal = queue.Pop(top);
80 EXPECT_EQ(nRetVal, XN_STATUS_OK);
81 // make sure this is the top
82 EXPECT_EQ(top.nValue, 5);
83 EXPECT_EQ(top.dValue, temp1.dValue);
84 // and that size was reduced
85 EXPECT_EQ(queue.Size(), 1);
86
87 // make sure top is temp2
88 XnQueueTestStruct& rTop4 = queue.Top();
89 EXPECT_EQ(rTop4.nValue, temp2.nValue);
90 EXPECT_EQ(rTop4.dValue, temp2.dValue);
91
92 // pop it
93 nRetVal = queue.Pop(top);
94 EXPECT_EQ(nRetVal, XN_STATUS_OK);

Callers

nothing calls this directly

Calls 3

PushMethod · 0.45
SizeMethod · 0.45
PopMethod · 0.45

Tested by

no test coverage detected