Skip to content

Commit 97c504e

Browse files
committed
TestOptions: use getArrayLength() [skip ci]
1 parent d0cb31f commit 97c504e

1 file changed

Lines changed: 15 additions & 14 deletions

File tree

test/testoptions.cpp

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@
1616
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1717
*/
1818

19-
#include "options.h"
2019
#include "fixture.h"
20+
#include "options.h"
21+
#include "utils.h"
2122

2223
#include <functional>
2324
#include <set>
@@ -50,89 +51,89 @@ class TestOptions : public TestFixture {
5051

5152
void which_test() const {
5253
const char* argv[] = {"./test_runner", "TestClass"};
53-
options args(sizeof argv / sizeof argv[0], argv);
54+
options args(getArrayLength(argv), argv);
5455
ASSERT(std::set<std::string> {"TestClass"} == args.which_test());
5556
}
5657

5758

5859
void which_test_method() const {
5960
const char* argv[] = {"./test_runner", "TestClass::TestMethod"};
60-
options args(sizeof argv / sizeof argv[0], argv);
61+
options args(getArrayLength(argv), argv);
6162
ASSERT(std::set<std::string> {"TestClass::TestMethod"} == args.which_test());
6263
}
6364

6465

6566
void no_test_method() const {
6667
const char* argv[] = {"./test_runner"};
67-
options args(sizeof argv / sizeof argv[0], argv);
68+
options args(getArrayLength(argv), argv);
6869
ASSERT(std::set<std::string> {""} == args.which_test());
6970
}
7071

7172

7273
void not_quiet() const {
7374
const char* argv[] = {"./test_runner", "TestClass::TestMethod", "-v"};
74-
options args(sizeof argv / sizeof argv[0], argv);
75+
options args(getArrayLength(argv), argv);
7576
ASSERT_EQUALS(false, args.quiet());
7677
}
7778

7879

7980
void quiet() const {
8081
const char* argv[] = {"./test_runner", "TestClass::TestMethod", "-q"};
81-
options args(sizeof argv / sizeof argv[0], argv);
82+
options args(getArrayLength(argv), argv);
8283
ASSERT_EQUALS(true, args.quiet());
8384
}
8485

8586
void not_help() const {
8687
const char* argv[] = {"./test_runner", "TestClass::TestMethod", "-v"};
87-
options args(sizeof argv / sizeof argv[0], argv);
88+
options args(getArrayLength(argv), argv);
8889
ASSERT_EQUALS(false, args.help());
8990
}
9091

9192

9293
void help() const {
9394
const char* argv[] = {"./test_runner", "TestClass::TestMethod", "-h"};
94-
options args(sizeof argv / sizeof argv[0], argv);
95+
options args(getArrayLength(argv), argv);
9596
ASSERT_EQUALS(true, args.help());
9697
}
9798

9899

99100
void help_long() const {
100101
const char* argv[] = {"./test_runner", "TestClass::TestMethod", "--help"};
101-
options args(sizeof argv / sizeof argv[0], argv);
102+
options args(getArrayLength(argv), argv);
102103
ASSERT_EQUALS(true, args.help());
103104
}
104105

105106
void multiple_testcases() const {
106107
const char* argv[] = {"./test_runner", "TestClass::TestMethod", "TestClass::AnotherTestMethod"};
107-
options args(sizeof argv / sizeof argv[0], argv);
108+
options args(getArrayLength(argv), argv);
108109
std::set<std::string> expected {"TestClass::TestMethod", "TestClass::AnotherTestMethod"};
109110
ASSERT(expected == args.which_test());
110111
}
111112

112113
void multiple_testcases_ignore_duplicates() const {
113114
const char* argv[] = {"./test_runner", "TestClass::TestMethod", "TestClass"};
114-
options args(sizeof argv / sizeof argv[0], argv);
115+
options args(getArrayLength(argv), argv);
115116
std::set<std::string> expected {"TestClass"};
116117
ASSERT(expected == args.which_test());
117118
}
118119

119120
void invalid_switches() const {
120121
const char* argv[] = {"./test_runner", "TestClass::TestMethod", "-a", "-v", "-q"};
121-
options args(sizeof argv / sizeof argv[0], argv);
122+
options args(getArrayLength(argv), argv);
122123
std::set<std::string> expected {"TestClass::TestMethod"};
123124
ASSERT(expected == args.which_test());
124125
ASSERT_EQUALS(true, args.quiet());
125126
}
126127

127128
void summary() const {
128129
const char* argv[] = {"./test_runner", "TestClass::TestMethod", "-n"};
129-
options args(sizeof argv / sizeof argv[0], argv);
130+
options args(getArrayLength(argv), argv);
130131
ASSERT_EQUALS(false, args.summary());
131132
}
132133

133134
void dry_run() const {
134135
const char* argv[] = {"./test_runner", "TestClass::TestMethod", "-d"};
135-
options args(sizeof argv / sizeof argv[0], argv);
136+
options args(getArrayLength(argv), argv);
136137
ASSERT_EQUALS(true, args.dry_run());
137138
}
138139
};

0 commit comments

Comments
 (0)