MCPcopy Create free account
hub / github.com/DanielChappuis/reactphysics3d / testConstructor

Method testConstructor

test/tests/containers/TestStack.h:65–103  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63 }
64
65 void testConstructor() {
66
67 // ----- Constructors ----- //
68
69 Stack<std::string> stack1(mAllocator);
70 rp3d_test(stack1.capacity() == 0);
71 rp3d_test(stack1.size() == 0);
72
73 Stack<std::string> stack2(mAllocator, 100);
74 rp3d_test(stack2.capacity() >= 100);
75 rp3d_test(stack2.size() == 0);
76
77 // ----- Copy Constructors ----- //
78 Stack<std::string> stack3(stack2);
79 rp3d_test(stack3.capacity() == stack2.capacity());
80 rp3d_test(stack3.size() == stack2.size());
81
82 Stack<int> stack4(mAllocator);
83 stack4.push(10);
84 stack4.push(20);
85 stack4.push(30);
86 rp3d_test(stack4.capacity() >= 3);
87 rp3d_test(stack4.size() == 3);
88 stack4.push(40);
89 rp3d_test(stack4.size() == 4);
90 rp3d_test(stack4.top() == 40);
91
92 Stack<int> stack5(stack4);
93 rp3d_test(stack5.capacity() == stack4.capacity());
94 rp3d_test(stack5.size() == stack4.size());
95 rp3d_test(stack5.top() == 40);
96 rp3d_test(stack5.pop() == 40);
97 rp3d_test(stack5.size() == 3);
98 rp3d_test(stack5.pop() == 30);
99 rp3d_test(stack5.top() == 20);
100 rp3d_test(stack5.pop() == 20);
101 rp3d_test(stack5.pop() == 10);
102 rp3d_test(stack5.size() == 0);
103 }
104
105 void testPushPop() {
106

Callers

nothing calls this directly

Calls 4

pushMethod · 0.80
popMethod · 0.80
capacityMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected