Skip to content

Commit 6967c81

Browse files
committed
Fix formatting
1 parent e71cabf commit 6967c81

File tree

2 files changed

+56
-56
lines changed

2 files changed

+56
-56
lines changed

examples/test/gtest_ext.h

+28-28
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// This file contains implementations that extend the functionality of the
22
// google test framework
33
// Version: 0.1.1-beta
4-
4+
55
#include <gtest/gtest.h>
66
#include <random>
77
#include <string>
@@ -10,7 +10,7 @@
1010
#include <chrono>
1111
#include <map>
1212
#include "termcolor/termcolor.hpp"
13-
13+
1414
class SkipListener : public ::testing::EmptyTestEventListener
1515
{
1616
private:
@@ -30,7 +30,7 @@ class SkipListener : public ::testing::EmptyTestEventListener
3030
}
3131
}
3232
};
33-
33+
3434
// Run and retrieves the output of an executable program from
3535
// the command line.
3636
//
@@ -49,7 +49,7 @@ std::string exec_program(std::string prog_name, std::string input)
4949
pclose(fp);
5050
return output;
5151
}
52-
52+
5353
// Converts a double value to a formatted string
5454
//
5555
// @param val value to be formatted
@@ -62,7 +62,7 @@ std::string to_string_double(double val, const int prec = 2)
6262
out << std::fixed << std::setprecision(prec) << val;
6363
return out.str();
6464
}
65-
65+
6666
// Generate a string with random values from an alphanumeric character set
6767
//
6868
// @param max_length length of string to generate
@@ -80,7 +80,7 @@ std::string generate_string(int max_length){
8080
}
8181
return ret;
8282
}
83-
83+
8484
std::string expose_special_characters(const std::string &source) {
8585
if(source.length() == 0) {
8686
return "<empty>";
@@ -99,7 +99,7 @@ std::string expose_special_characters(const std::string &source) {
9999
}
100100
return exposed_string.str();
101101
}
102-
102+
103103
// This macro is used to simulate the standard input (cin) for a code block
104104
//
105105
// @param input simulated input
@@ -113,7 +113,7 @@ std::string expose_special_characters(const std::string &source) {
113113
std::cin.rdbuf(old_input_buf); \
114114
std::cout.rdbuf(old_output_buf); \
115115
}
116-
116+
117117
::testing::AssertionResult AssertExecStdOut(const char* prog_name_expr,
118118
const char* prog_input_expr,
119119
const char* prog_output_expr,
@@ -156,36 +156,36 @@ ::testing::AssertionResult AssertExecStdOut(const char* prog_name_expr,
156156
}
157157
exec_diff = expose_special_characters(exec_diff);
158158
prog_diff = expose_special_characters(prog_diff);
159-
159+
160160
std::ostringstream error_str_stream;
161161
std::ostringstream exec_str_stream;
162162
exec_str_stream << termcolor::colorize << termcolor::green
163163
<< exec_output.substr(0, pos)
164164
<< termcolor::red << exec_output.substr(pos)
165165
<< termcolor::reset;
166-
166+
167167
std::ostringstream prog_str_stream;
168168
prog_str_stream << termcolor::colorize << termcolor::green
169169
<< prog_output.substr(0, pos)
170170
<< termcolor::red << prog_output.substr(pos)
171171
<< termcolor::reset;
172-
172+
173173
error_str_stream << "Your program's output did not match the expected "
174174
<< "output starting on line " << line_pos + 1
175175
<< " character " << char_pos
176176
<< ".\nExpected " << prog_diff
177177
<< " instead of " << exec_diff
178178
//<< "\n\nExpected output: \n" << expose_special_characters(prog_str_stream.str())
179179
<< "\n\nExpected output: \n" << prog_str_stream.str()
180-
<< "\n\nYour program's output: \n"
180+
<< "\n\nYour program's output: \n"
181181
//<< expose_special_characters(exec_str_stream.str()) << "\n\nTest Input: \n"
182-
<< exec_str_stream.str() << "\n\nTest Input: \n"
182+
<< exec_str_stream.str() << "\n\nInput: \n"
183183
<< prog_input ;
184-
184+
185185
return ::testing::AssertionFailure() << error_str_stream.str();
186186
}
187187
}
188-
188+
189189
// This macro checks if the output of an executable program matches an expected
190190
// output.
191191
//
@@ -194,7 +194,7 @@ ::testing::AssertionResult AssertExecStdOut(const char* prog_name_expr,
194194
// @param output expected output of the program
195195
#define ASSERT_EXECEQ(prog_name, input, output) \
196196
EXPECT_PRED_FORMAT3(AssertExecStdOut, prog_name, input, output)
197-
197+
198198
template <typename T>
199199
::testing::AssertionResult AssertExecMatcher(const char* prog_name_expr,
200200
const char* prog_input_expr,
@@ -207,25 +207,25 @@ ::testing::AssertionResult AssertExecMatcher(const char* prog_name_expr,
207207
<< "': Make sure your executable file"
208208
<< " is called '" << prog_name << "'";
209209
}
210-
210+
211211
std::string exec_output = exec_program(prog_name, prog_input);
212212
// based on https://github.com/google/googletest/blob/fb49e6c164490a227bbb7cf5223b846c836a0305/googlemock/include/gmock/gmock-matchers.h#L1304
213213
// create a predicate formatter that can be used to run the matcher
214214
auto pred_formatter = ::testing::internal::MakePredicateFormatterFromMatcher(matcher);
215215
// where: matcher_expr is the stringized matcher (e.g., StartsWith("Hello"))
216216
// exec_output is the expected output, in this case the program output
217-
return pred_formatter(matcher_expr, exec_output) << "\n Input: "
217+
return pred_formatter(matcher_expr, exec_output) << "\n Input: "
218218
<< prog_input;
219219
}
220-
220+
221221
// This macro checks if the output of an executable follows the pattern defined
222222
// in the gMock matcher
223223
// @param prog_name name of the executable file
224224
// @param input keyboard input sent to the program
225225
// @param matcher gMock matcher used to test the executable's output
226226
#define ASSERT_EXECTHAT(prog_name, input, matcher) \
227227
EXPECT_PRED_FORMAT3(AssertExecMatcher, prog_name, input, matcher)
228-
228+
229229
::testing::AssertionResult AssertExecExit(const char* prog_name_expr,
230230
const char* prog_input_expr,
231231
const char* prog_max_dur,
@@ -237,7 +237,7 @@ ::testing::AssertionResult AssertExecExit(const char* prog_name_expr,
237237
<< "': Make sure your executable file"
238238
<< " is called '" << prog_name << "'";
239239
}
240-
240+
241241
std::promise<bool> completed;
242242
auto stmt_future = completed.get_future();
243243
std::thread([&](std::promise<bool>& completed) {
@@ -246,15 +246,15 @@ ::testing::AssertionResult AssertExecExit(const char* prog_name_expr,
246246
}, std::ref(completed)).detach();
247247
if(stmt_future.wait_for(std::chrono::seconds(max_dur)) == std::future_status::timeout) {
248248
return ::testing::AssertionFailure()
249-
<< "Test Input: " << prog_input
249+
<< "Input: " << prog_input
250250
<< "\n the program took more than " << max_dur
251251
<< " seconds to exit. Check for infinite loops or "
252252
<< "unnecessary inputs.";
253253
} else {
254254
return ::testing::AssertionSuccess();
255255
}
256256
}
257-
257+
258258
// This macro checks whether the executable program exits given the provided
259259
// input.
260260
//
@@ -265,8 +265,8 @@ ::testing::AssertionResult AssertExecExit(const char* prog_name_expr,
265265
// input
266266
#define ASSERT_EXECEXIT(prog_name, input, duration) \
267267
EXPECT_PRED_FORMAT3(AssertExecExit, prog_name, input, duration)
268-
269-
268+
269+
270270
// Version of ASSERT_EXECIO_EQ that uses google mock's matchers
271271
//
272272
// @param prog_name name of the executable file
@@ -278,7 +278,7 @@ ::testing::AssertionResult AssertExecExit(const char* prog_name_expr,
278278
} \
279279
ASSERT_THAT(main_output(prog_name, input), matcher) << " Input: " << input; \
280280
}
281-
281+
282282
// This macro asserts that the result of performing the statement
283283
// is equal to the expected value in the standard output (cout)
284284
//
@@ -295,7 +295,7 @@ ::testing::AssertionResult AssertExecExit(const char* prog_name_expr,
295295
std::string your_output = output_ss.str(); \
296296
ASSERT_EQ(your_output, expected); \
297297
}
298-
298+
299299
// Version of ASSERT_SIO_EQ that uses google mock's matchers
300300
//
301301
// @param expected expected string value
@@ -311,7 +311,7 @@ ::testing::AssertionResult AssertExecExit(const char* prog_name_expr,
311311
std::string your_output = output_ss.str(); \
312312
ASSERT_THAT(your_output, expected); \
313313
}
314-
314+
315315
// This macro checks whether a function executes within a given time
316316
//
317317
// A thread is created to run the statement and update the status of a promise

0 commit comments

Comments
 (0)