Skip to content

Commit 7ddf364

Browse files
committed
Updated the comments and style of the List unit tests.
1 parent 7e02079 commit 7ddf364

File tree

1 file changed

+40
-51
lines changed

1 file changed

+40
-51
lines changed

‎src/test/list_test.cpp

Lines changed: 40 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,55 @@
11
#include <sstream>
22
#include <string>
3-
#include <type_traits>
43

54
#include <gtest/gtest.h>
65

76
#include "../h/list.h"
87

9-
108
using namespace ctgl;
119

12-
13-
// Convenient Type Aliases
14-
// -----------------------------------------------------------------------------
15-
template <typename T, typename U>
16-
using RemoveType = decltype(remove(T{}, U{}));
17-
18-
template <typename T>
19-
using FrontType = decltype(front(T{}));
20-
21-
template <typename T>
22-
using UniqueType = decltype(unique(T{}));
23-
24-
25-
// Unit Tests
26-
// -----------------------------------------------------------------------------
27-
// Tests for the size() function.
10+
// Unit tests for the ctgl::list::size() function.
2811
TEST(ListTest, Size) {
29-
EXPECT_EQ(size(List<>{}), 0);
30-
EXPECT_EQ(size(List<int>{}), 1);
31-
EXPECT_EQ(size(List<int, float, double>{}), 3);
32-
EXPECT_EQ(size(List<int, int>{}), 2);
12+
// Empty
13+
EXPECT_EQ(list::size(List<>{}), 0);
14+
15+
// Not Empty
16+
EXPECT_EQ(list::size(List<int>{}), 1);
17+
EXPECT_EQ(list::size(List<int, int>{}), 2);
18+
EXPECT_EQ(list::size(List<int, float, double>{}), 3);
3319
}
3420

35-
// Tests for the empty() function.
21+
// Unit tests for the ctgl::list::empty() function.
3622
TEST(ListTest, Empty) {
23+
// Empty
3724
EXPECT_TRUE(empty(List<>{}));
25+
26+
// Not Empty
3827
EXPECT_FALSE(empty(List<int>{}));
3928
EXPECT_FALSE(empty(List<int, bool>{}));
4029
}
4130

42-
// Tests for the remove() function.
31+
// Unit tests for the ctgl::list::remove() function.
4332
TEST(ListTest, Remove) {
4433
// Empty
45-
EXPECT_TRUE((std::is_same<RemoveType<int, List<>>, List<>>::value));
34+
EXPECT_EQ(remove(int{}, List<>{}), List<>{});
4635

4736
// Single
48-
EXPECT_TRUE((std::is_same<RemoveType<int, List<int>>, List<>>::value));
49-
EXPECT_TRUE((std::is_same<RemoveType<bool, List<int>>, List<int>>::value));
37+
EXPECT_EQ(remove(int{}, List<int>{}), List<>{});
38+
EXPECT_EQ(remove(bool{}, List<int>{}), List<int>{});
5039

5140
// Multiple
52-
EXPECT_TRUE((std::is_same<RemoveType<int, List<int, int>>, List<>>::value));
53-
EXPECT_TRUE((std::is_same<RemoveType<int, List<int, float, int>>, List<float>>::value));
54-
EXPECT_TRUE((std::is_same<RemoveType<int, List<float, double>>, List<float, double>>::value));
41+
EXPECT_EQ(remove(int{}, List<int, int>{}), List<>{});
42+
EXPECT_EQ(remove(int{}, List<int, float, int>{}), List<float>{});
43+
EXPECT_EQ(remove(int{}, List<float, double>{}), (List<float, double>{}));
5544
}
5645

57-
// Tests for the front() function.
46+
// Unit tests for the ctgl::list::front() function.
5847
TEST(ListTest, Front) {
59-
EXPECT_TRUE((std::is_same<FrontType<List<int>>, int>::value));
60-
EXPECT_TRUE((std::is_same<FrontType<List<int, float, double>>, int>::value));
48+
EXPECT_EQ(front(List<int>{}), int{});
49+
EXPECT_EQ(front(List<int, float, double>{}), int{});
6150
}
6251

63-
// Tests for the contains() function.
52+
// Unit tests for the ctgl::list::contains() function.
6453
TEST(ListTest, Contains) {
6554
// Empty
6655
EXPECT_FALSE(contains(int{}, List<>{}));
@@ -74,22 +63,22 @@ TEST(ListTest, Contains) {
7463
EXPECT_FALSE(contains(bool{}, List<int, float, double>{}));
7564
}
7665

77-
// Tests for the unique() function.
66+
// Unit tests for the ctgl::list::unique() function.
7867
TEST(ListTest, Unique) {
7968
// Empty
80-
EXPECT_TRUE((std::is_same<UniqueType<List<>>, List<>>::value));
69+
EXPECT_EQ(unique(List<>{}), List<>{});
8170

8271
// Identity
83-
EXPECT_TRUE((std::is_same<UniqueType<List<int>>, List<int>>::value));
84-
EXPECT_TRUE((std::is_same<UniqueType<List<int, double>>, List<int, double>>::value));
72+
EXPECT_EQ(unique(List<int>{}), List<int>{});
73+
EXPECT_EQ(unique(List<int, double>{}), (List<int, double>{}));
8574

8675
// Duplicates
87-
EXPECT_TRUE((std::is_same<UniqueType<List<int, int>>, List<int>>::value));
88-
EXPECT_TRUE((std::is_same<UniqueType<List<int, bool, int>>, List<bool, int>>::value));
89-
EXPECT_TRUE((std::is_same<UniqueType<List<bool, int, bool, int>>, List<bool, int>>::value));
76+
EXPECT_EQ(unique(List<int, int>{}), List<int>{});
77+
EXPECT_EQ(unique(List<int, bool, int>{}), (List<bool, int>{}));
78+
EXPECT_EQ(unique(List<bool, int, bool, int>{}), (List<bool, int>{}));
9079
}
9180

92-
// Tests for the "==" operator.
81+
// Unit tests for the ctgl::list::"==" operator.
9382
TEST(ListTest, Equals) {
9483
// Empty
9584
EXPECT_TRUE(List<>{} == List<>{});
@@ -110,23 +99,23 @@ TEST(ListTest, Equals) {
11099
EXPECT_FALSE((List<int, bool>{}) == (List<bool, int>{}));
111100
}
112101

113-
// Tests for the "+" operator.
102+
// Unit tests for the ctgl::list::"+" operator.
114103
TEST(ListTest, Plus) {
115104
// Empty
116-
EXPECT_TRUE(List<>{} + List<>{} == List<>{});
105+
EXPECT_EQ(List<>{} + List<>{}, List<>{});
117106

118107
// Single
119-
EXPECT_TRUE(int{} + List<>{} == List<int>{});
120-
EXPECT_TRUE(List<>{} + int{} == List<int>{});
108+
EXPECT_EQ(int{} + List<>{}, List<int>{});
109+
EXPECT_EQ(List<>{} + int{}, List<int>{});
121110

122111
// Multiple
123-
EXPECT_TRUE((int{} + List<int>{} == List<int, int>{}));
124-
EXPECT_TRUE((int{} + List<bool>{} == List<int, bool>{}));
125-
EXPECT_TRUE((List<int>{} + bool{} == List<int, bool>{}));
126-
EXPECT_TRUE((List<int>{} + List<bool>{} == List<int, bool>{}));
112+
EXPECT_EQ(int{} + List<int>{}, (List<int, int>{}));
113+
EXPECT_EQ(int{} + List<bool>{}, (List<int, bool>{}));
114+
EXPECT_EQ(List<int>{} + bool{}, (List<int, bool>{}));
115+
EXPECT_EQ(List<int>{} + List<bool>{}, (List<int, bool>{}));
127116
}
128117

129-
// Tests for the "<<" operator.
118+
// Unit tests for the ctgl::list::"<<" operator.
130119
TEST(ListTest, OutputStream) {
131120
{ // Empty
132121
std::ostringstream stream;

0 commit comments

Comments
 (0)