Skip to content

Commit d42a909

Browse files
committed
reformatting
1 parent 0f6bdcb commit d42a909

File tree

3 files changed

+55
-54
lines changed

3 files changed

+55
-54
lines changed

.clang-format

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
BasedOnStyle: Google
2+
ColumnLimit: 100
3+
AccessModifierOffset: -2

include/gtest_mpi/gtest_mpi.hpp

+33-34
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,9 @@ class MPITestEnvironment : public ::testing::Environment {
8383
public:
8484
MPITestEnvironment() : ::testing::Environment() {}
8585

86-
MPITestEnvironment(const MPITestEnvironment&) = delete;
86+
MPITestEnvironment(const MPITestEnvironment &) = delete;
8787

88-
MPITestEnvironment(MPITestEnvironment&&) = default;
88+
MPITestEnvironment(MPITestEnvironment &&) = default;
8989

9090
static MPI_Comm GetComm() { return global_test_comm; }
9191

@@ -122,20 +122,20 @@ class PrettyMPIUnitTestResultPrinter : public ::testing::TestEventListener {
122122
}
123123

124124
// The following methods override what's in the TestEventListener class.
125-
void OnTestIterationStart(const ::testing::UnitTest& unit_test, int iteration) override;
126-
void OnEnvironmentsSetUpStart(const ::testing::UnitTest& unit_test) override;
127-
void OnTestCaseStart(const ::testing::TestCase& test_case) override;
128-
void OnTestStart(const ::testing::TestInfo& test_info) override;
129-
void OnTestPartResult(const ::testing::TestPartResult& result) override;
130-
void OnTestEnd(const ::testing::TestInfo& test_info) override;
131-
void OnTestCaseEnd(const ::testing::TestCase& test_case) override;
132-
void OnEnvironmentsTearDownStart(const ::testing::UnitTest& unit_test) override;
133-
void OnTestIterationEnd(const ::testing::UnitTest& unit_test, int iteration) override;
134-
135-
void OnEnvironmentsSetUpEnd(const ::testing::UnitTest& /*unit_test*/) override {}
136-
void OnEnvironmentsTearDownEnd(const ::testing::UnitTest& /*unit_test*/) override {}
137-
void OnTestProgramStart(const ::testing::UnitTest& /*unit_test*/) override {}
138-
void OnTestProgramEnd(const ::testing::UnitTest& /*unit_test*/) override {}
125+
void OnTestIterationStart(const ::testing::UnitTest &unit_test, int iteration) override;
126+
void OnEnvironmentsSetUpStart(const ::testing::UnitTest &unit_test) override;
127+
void OnTestCaseStart(const ::testing::TestCase &test_case) override;
128+
void OnTestStart(const ::testing::TestInfo &test_info) override;
129+
void OnTestPartResult(const ::testing::TestPartResult &result) override;
130+
void OnTestEnd(const ::testing::TestInfo &test_info) override;
131+
void OnTestCaseEnd(const ::testing::TestCase &test_case) override;
132+
void OnEnvironmentsTearDownStart(const ::testing::UnitTest &unit_test) override;
133+
void OnTestIterationEnd(const ::testing::UnitTest &unit_test, int iteration) override;
134+
135+
void OnEnvironmentsSetUpEnd(const ::testing::UnitTest & /*unit_test*/) override {}
136+
void OnEnvironmentsTearDownEnd(const ::testing::UnitTest & /*unit_test*/) override {}
137+
void OnTestProgramStart(const ::testing::UnitTest & /*unit_test*/) override {}
138+
void OnTestProgramEnd(const ::testing::UnitTest & /*unit_test*/) override {}
139139

140140
private:
141141
int rank_;
@@ -149,15 +149,15 @@ class PrettyMPIUnitTestResultPrinter : public ::testing::TestEventListener {
149149
};
150150

151151
// Taken / modified from Googletest
152-
void PrettyMPIUnitTestResultPrinter::OnTestIterationStart(const ::testing::UnitTest& unit_test,
152+
void PrettyMPIUnitTestResultPrinter::OnTestIterationStart(const ::testing::UnitTest &unit_test,
153153
int iteration) {
154154
using namespace ::testing;
155155
if (rank_ != 0) return;
156156

157157
if (GTEST_FLAG(repeat) != 1)
158158
printf("\nRepeating all tests (iteration %d) . . .\n\n", iteration + 1);
159159

160-
const char* const filter = GTEST_FLAG(filter).c_str();
160+
const char *const filter = GTEST_FLAG(filter).c_str();
161161

162162
// Prints the filter if it's not *. This reminds the user that some
163163
// tests may be skipped.
@@ -185,7 +185,7 @@ void PrettyMPIUnitTestResultPrinter::OnTestIterationStart(const ::testing::UnitT
185185
// Taken / modified from Googletest
186186
// Formats a source file path and a line number as they would appear
187187
// in an error message from the compiler used to compile this code.
188-
GTEST_API_ ::std::string FormatFileLocation(const char* file, int line) {
188+
GTEST_API_ ::std::string FormatFileLocation(const char *file, int line) {
189189
const std::string file_name(file == nullptr ? "unkown file" : file);
190190

191191
if (line < 0) {
@@ -200,15 +200,15 @@ GTEST_API_ ::std::string FormatFileLocation(const char* file, int line) {
200200

201201
// Taken / modified from Googletest
202202
void PrettyMPIUnitTestResultPrinter::OnEnvironmentsSetUpStart(
203-
const ::testing::UnitTest& /*unit_test*/) {
203+
const ::testing::UnitTest & /*unit_test*/) {
204204
if (rank_ != 0) return;
205205
ColoredPrintf(COLOR_GREEN, "[----------] ");
206206
printf("Global test environment set-up.\n");
207207
fflush(stdout);
208208
}
209209

210210
// Taken / modified from Googletest
211-
void PrettyMPIUnitTestResultPrinter::OnTestCaseStart(const ::testing::TestCase& test_case) {
211+
void PrettyMPIUnitTestResultPrinter::OnTestCaseStart(const ::testing::TestCase &test_case) {
212212
using namespace ::testing;
213213
if (rank_ != 0) return;
214214
const std::string counts = FormatCountableNoun(test_case.test_to_run_count(), "test", "tests");
@@ -223,7 +223,7 @@ void PrettyMPIUnitTestResultPrinter::OnTestCaseStart(const ::testing::TestCase&
223223
}
224224

225225
// Taken / modified from Googletest
226-
void PrettyMPIUnitTestResultPrinter::OnTestStart(const ::testing::TestInfo& test_info) {
226+
void PrettyMPIUnitTestResultPrinter::OnTestStart(const ::testing::TestInfo &test_info) {
227227
if (rank_ != 0) return;
228228
ColoredPrintf(COLOR_GREEN, "[ RUN ] ");
229229
printf("%s.%s", test_info.test_case_name(), test_info.name());
@@ -233,15 +233,15 @@ void PrettyMPIUnitTestResultPrinter::OnTestStart(const ::testing::TestInfo& test
233233
}
234234

235235
// Taken / modified from Googletest
236-
void PrettyMPIUnitTestResultPrinter::OnTestPartResult(const ::testing::TestPartResult& result) {
236+
void PrettyMPIUnitTestResultPrinter::OnTestPartResult(const ::testing::TestPartResult &result) {
237237
using namespace ::testing;
238238
// If the test part succeeded, we don't need to do anything.
239239
if (result.type() == TestPartResult::kSuccess) return;
240240
failed_results_.Add(result);
241241
}
242242

243243
// Taken / modified from Googletest
244-
void PrintFailedTestResultCollection(const TestPartResultCollection& collection, int rank) {
244+
void PrintFailedTestResultCollection(const TestPartResultCollection &collection, int rank) {
245245
for (std::size_t i = 0; i < collection.Size(); ++i) {
246246
std::string m =
247247
(::testing::Message()
@@ -256,7 +256,7 @@ void PrintFailedTestResultCollection(const TestPartResultCollection& collection,
256256
}
257257

258258
// Taken / modified from Googletest
259-
void PrettyMPIUnitTestResultPrinter::OnTestEnd(const ::testing::TestInfo& test_info) {
259+
void PrettyMPIUnitTestResultPrinter::OnTestEnd(const ::testing::TestInfo &test_info) {
260260
using namespace ::testing;
261261

262262
// check if any ranks failed
@@ -275,7 +275,7 @@ void PrettyMPIUnitTestResultPrinter::OnTestEnd(const ::testing::TestInfo& test_i
275275
}
276276

277277
int failed_globally = failed_locally;
278-
for (const auto& f : failed_flags_per_rank) {
278+
for (const auto &f : failed_flags_per_rank) {
279279
if (f) failed_globally = 1;
280280
}
281281

@@ -329,7 +329,7 @@ void PrettyMPIUnitTestResultPrinter::OnTestEnd(const ::testing::TestInfo& test_i
329329
}
330330

331331
// Taken / modified from Googletest
332-
void PrettyMPIUnitTestResultPrinter::OnTestCaseEnd(const ::testing::TestCase& test_case) {
332+
void PrettyMPIUnitTestResultPrinter::OnTestCaseEnd(const ::testing::TestCase &test_case) {
333333
using namespace ::testing;
334334
if (!GTEST_FLAG(print_time) || rank_ != 0) return;
335335

@@ -340,9 +340,9 @@ void PrettyMPIUnitTestResultPrinter::OnTestCaseEnd(const ::testing::TestCase& te
340340
fflush(stdout);
341341
}
342342

343-
static std::string FormatSet(const std::set<int>& s) {
343+
std::string FormatSet(const std::set<int> &s) {
344344
std::string res;
345-
for (const auto& val : s) {
345+
for (const auto &val : s) {
346346
res += std::to_string(val);
347347
if (val != *(--s.end())) {
348348
res += ", ";
@@ -353,8 +353,7 @@ static std::string FormatSet(const std::set<int>& s) {
353353
}
354354

355355
// Taken / modified from Googletest
356-
static void PrintFullTestCommentIfPresent(const std::string& type_param,
357-
const std::string& value_param) {
356+
void PrintFullTestCommentIfPresent(const std::string &type_param, const std::string &value_param) {
358357
if (!type_param.empty() || !value_param.empty()) {
359358
printf(", where ");
360359
if (!type_param.empty()) {
@@ -369,7 +368,7 @@ static void PrintFullTestCommentIfPresent(const std::string& type_param,
369368
}
370369

371370
// Taken / modified from Googletest
372-
void PrettyMPIUnitTestResultPrinter::OnTestIterationEnd(const ::testing::UnitTest& unit_test,
371+
void PrettyMPIUnitTestResultPrinter::OnTestIterationEnd(const ::testing::UnitTest &unit_test,
373372
int /*iteration*/) {
374373
using namespace ::testing;
375374
failed_results_.Reset();
@@ -390,7 +389,7 @@ void PrettyMPIUnitTestResultPrinter::OnTestIterationEnd(const ::testing::UnitTes
390389
if (num_failed_tests_) {
391390
ColoredPrintf(COLOR_RED, "[ FAILED ] ");
392391
printf("%s, listed below:\n", FormatTestCount(num_failed_tests_).c_str());
393-
for (const auto& prop : failed_test_properties_) {
392+
for (const auto &prop : failed_test_properties_) {
394393
if (!prop.should_run) continue;
395394
ColoredPrintf(COLOR_RED, "[ FAILED ] ");
396395
printf("%s.%s", prop.case_name.c_str(), prop.name.c_str());
@@ -414,7 +413,7 @@ void PrettyMPIUnitTestResultPrinter::OnTestIterationEnd(const ::testing::UnitTes
414413

415414
// Taken / modified from Googletest
416415
void PrettyMPIUnitTestResultPrinter::OnEnvironmentsTearDownStart(
417-
const ::testing::UnitTest& /*unit_test*/) {
416+
const ::testing::UnitTest & /*unit_test*/) {
418417
if (rank_ != 0) return;
419418
ColoredPrintf(COLOR_GREEN, "[----------] ");
420419
printf("Global MPI test environment tear-down\n");

include/gtest_mpi/gtest_mpi_internal.hpp

+19-20
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,9 @@ static const char kValueParamLabel[] = "GetParam()";
9696
enum GTestColor { COLOR_DEFAULT, COLOR_RED, COLOR_GREEN, COLOR_YELLOW };
9797

9898
// Taken / modified from Googletest
99-
static void PrintFullTestCommentIfPresent(const ::testing::TestInfo& test_info) {
100-
const char* const type_param = test_info.type_param();
101-
const char* const value_param = test_info.value_param();
99+
void PrintFullTestCommentIfPresent(const ::testing::TestInfo &test_info) {
100+
const char *const type_param = test_info.type_param();
101+
const char *const value_param = test_info.value_param();
102102

103103
if (type_param != NULL || value_param != NULL) {
104104
printf(", where ");
@@ -112,9 +112,9 @@ static void PrintFullTestCommentIfPresent(const ::testing::TestInfo& test_info)
112112
}
113113
}
114114

115-
bool CStringEquals(const char* l, const char* r) { return std::strcmp(l, r) == 0; }
115+
bool CStringEquals(const char *l, const char *r) { return std::strcmp(l, r) == 0; }
116116

117-
bool CaseInsensitiveCStringEquals(const char* l, const char* r) {
117+
bool CaseInsensitiveCStringEquals(const char *l, const char *r) {
118118
bool equal = true;
119119

120120
for (; equal && *l && *r; ++l, ++r) {
@@ -128,11 +128,11 @@ bool CaseInsensitiveCStringEquals(const char* l, const char* r) {
128128
// Taken / modified from Googletest
129129
bool ShouldUseColor(bool stdout_is_tty) {
130130
using namespace ::testing;
131-
const char* const gtest_color = GTEST_FLAG(color).c_str();
131+
const char *const gtest_color = GTEST_FLAG(color).c_str();
132132

133133
if (CaseInsensitiveCStringEquals(gtest_color, "auto")) {
134134
// On non-Windows platforms, we rely on the TERM variable.
135-
const char* const term = getenv("TERM");
135+
const char *const term = getenv("TERM");
136136
const bool term_supports_color =
137137
CStringEquals(term, "xterm") || CStringEquals(term, "xterm-color") ||
138138
CStringEquals(term, "xterm-256color") || CStringEquals(term, "screen") ||
@@ -152,7 +152,7 @@ bool ShouldUseColor(bool stdout_is_tty) {
152152
}
153153

154154
// Taken / modified from Googletest
155-
static const char* GetAnsiColorCode(GTestColor color) {
155+
const char *GetAnsiColorCode(GTestColor color) {
156156
switch (color) {
157157
case COLOR_RED:
158158
return "1";
@@ -166,7 +166,7 @@ static const char* GetAnsiColorCode(GTestColor color) {
166166
}
167167

168168
// Taken / modified from Googletest
169-
static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
169+
void ColoredPrintf(GTestColor color, const char *fmt, ...) {
170170
va_list args;
171171
va_start(args, fmt);
172172

@@ -186,10 +186,10 @@ static void ColoredPrintf(GTestColor color, const char* fmt, ...) {
186186
}
187187

188188
// Taken / modified from Googletest
189-
Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) {
189+
Int32 Int32FromEnvOrDie(const char *var, Int32 default_val) {
190190
using namespace ::testing;
191191
using namespace ::testing::internal;
192-
const char* str_val = getenv(var);
192+
const char *str_val = getenv(var);
193193
if (str_val == NULL) {
194194
return default_val;
195195
}
@@ -202,24 +202,23 @@ Int32 Int32FromEnvOrDie(const char* var, Int32 default_val) {
202202
}
203203

204204
// Taken / modified from Googletest
205-
static std::string FormatCountableNoun(int count, const char* singular_form,
206-
const char* plural_form) {
205+
std::string FormatCountableNoun(int count, const char *singular_form, const char *plural_form) {
207206
using namespace ::testing;
208207
return std::to_string(count) + " " + (count == 1 ? singular_form : plural_form);
209208
}
210209

211210
// Taken / modified from Googletest
212-
static std::string FormatTestCount(int test_count) {
211+
std::string FormatTestCount(int test_count) {
213212
return FormatCountableNoun(test_count, "test", "tests");
214213
}
215214

216215
// Taken / modified from Googletest
217-
static std::string FormatTestCaseCount(int test_case_count) {
216+
std::string FormatTestCaseCount(int test_case_count) {
218217
return FormatCountableNoun(test_case_count, "test case", "test cases");
219218
}
220219

221220
// Taken / modified from Googletest
222-
static const char* TestPartResultTypeToString(::testing::TestPartResult::Type type) {
221+
const char *TestPartResultTypeToString(::testing::TestPartResult::Type type) {
223222
switch (type) {
224223
case ::testing::TestPartResult::kSuccess:
225224
return "Success";
@@ -237,7 +236,7 @@ static const char* TestPartResultTypeToString(::testing::TestPartResult::Type ty
237236
}
238237

239238
// Taken / modified from Googletest
240-
bool ShouldShard(const char* total_shards_env, const char* shard_index_env,
239+
bool ShouldShard(const char *total_shards_env, const char *shard_index_env,
241240
bool in_subprocess_for_death_test) {
242241
using namespace ::testing;
243242
using namespace ::testing::internal;
@@ -291,7 +290,7 @@ struct TestInfoProperties {
291290
// which can be exchanged in a single MPI call
292291
class StringCollection {
293292
public:
294-
void Add(const char* s) {
293+
void Add(const char *s) {
295294
int size = 0;
296295
for (; *s != '\0'; ++s, ++size) {
297296
text.push_back(*s);
@@ -331,7 +330,7 @@ class StringCollection {
331330
prev_size = 0;
332331
}
333332

334-
const char* get_str(const int id) const { return text.data() + start_indices[id]; }
333+
const char *get_str(const int id) const { return text.data() + start_indices[id]; }
335334

336335
const std::size_t Size() const { return start_indices.size(); }
337336

@@ -375,7 +374,7 @@ struct TestPartResultCollection {
375374
file_names.Recv(comm, rank);
376375
}
377376

378-
void Add(const ::testing::TestPartResult& result) {
377+
void Add(const ::testing::TestPartResult &result) {
379378
types.push_back(result.type());
380379
line_numbers.push_back(result.line_number());
381380
summaries.Add(result.summary());

0 commit comments

Comments
 (0)