Skip to content

Commit 892e1c7

Browse files
Final super game commit
1 parent 63718d2 commit 892e1c7

File tree

2 files changed

+17
-15
lines changed

2 files changed

+17
-15
lines changed

cpp/Platform.Collections.Tests/StackTests.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,16 @@
22

33
namespace Platform::Collections::Tests
44
{
5-
struct EmptyStack : public Stacks::IStack<int>
5+
TEST(StackTests, Concept)
6+
{
7+
Stacks::CStack<int> auto stack = std::stack<int>{};
8+
stack.push(1);
9+
ASSERT_EQ(stack.top(), 1);
10+
stack.pop();
11+
ASSERT_TRUE(stack.empty());
12+
}
13+
14+
struct EmptyStack : public Stacks::IStack<int>
615
{
716
bool empty() const {}
817

@@ -15,22 +24,13 @@ namespace Platform::Collections::Tests
1524
const int &top() const {}
1625
};
1726

18-
TEST(StackTests, Concept)
19-
{
20-
Stacks::CStack<int> auto stack = std::stack<int>{};
21-
stack.push(1);
22-
ASSERT_EQ(stack.top(), 1);
23-
stack.pop();
24-
ASSERT_TRUE(stack.empty());
25-
}
26-
2727
TEST(StackTests, Interface)
2828
{
29-
std::unique_ptr<Stack::IStack<int>> stack = std::make_unique<EmptyStack>();
29+
std::unique_ptr<Stacks::IStack<int>> stack = std::make_unique<EmptyStack>();
3030
}
3131

3232
TEST(StackTests, ConceptInterface)
3333
{
34-
Stacks::CStack<int> auto stack = EmptyStack{};
34+
Stacks::CStack<int> auto stack = EmptyStack{};
3535
}
3636
}

cpp/Platform.Collections/Stacks/CStack.h

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ namespace Platform::Collections::Stacks
66
concept CStack = requires(TSelf& self, TElement item)
77
{
88
{ self.push(item) };
9+
10+
{ self.pop() };
11+
12+
{ self.top() } -> std::same_as<TElement&>;
913
}
1014
&&
1115
requires(const TSelf& self, TElement item)
1216
{
1317
{ self.empty() } -> std::same_as<bool>;
1418

15-
{ self.pop() };
16-
17-
{ self.top() } -> std::same_as<TElement&>;
19+
{ self.top() } -> std::same_as<const TElement&>;
1820
};
1921
}

0 commit comments

Comments
 (0)