AUnit  0.5.0
Unit testing framework for Arduino platforms inspired by ArduinoUnit and Google Test.
Assertion.cpp
1 /*
2 MIT License
3 
4 Copyright (c) 2018 Brian T. Park
5 
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
12 
13 The above copyright notice and this permission notice shall be included in all
14 copies or substantial portions of the Software.
15 
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22 SOFTWARE.
23 */
24 
25 #include <Arduino.h> // definition of Print
26 #include "Flash.h"
27 #include "Printer.h"
28 #include "Assertion.h"
29 
30 namespace aunit {
31 
32 namespace {
33 
34 // This can be a template function because it is accessed only through the
35 // various assertXxx() methods. Those assertXxx() methods are explicitly
36 // overloaded for the various types that we want to support.
37 //
38 // Prints something like the following:
39 // Assertion failed: (5) == (6), file Test.ino, line 820.
40 // Assertion passed: (6) == (6), file Test.ino, line 820.
41 template <typename A, typename B>
42 void printAssertionMessage(bool ok, const char* file, uint16_t line,
43  const A& lhs, const char *opName, const B& rhs) {
44 
45  // Don't use F() strings here because flash memory strings are not deduped by
46  // the compiler, so each template instantiation of this method causes a
47  // duplication of all the strings below. See
48  // https://github.com/mmurdoch/arduinounit/issues/70
49  // for more info.
50  Print* printer = Printer::getPrinter();
51  printer->print("Assertion ");
52  printer->print(ok ? "passed" : "failed");
53  printer->print(": (");
54  printer->print(lhs);
55  printer->print(") ");
56  printer->print(opName);
57  printer->print(" (");
58  printer->print(rhs);
59  printer->print(')');
60  // reuse string in MataAssertion::printAssertionTestStatusMessage()
61  printer->print(", file ");
62  printer->print(file);
63  printer->print(", line ");
64  printer->print(line);
65  printer->println('.');
66 }
67 
68 // Special version of (bool, bool) because Arduino Print.h converts
69 // bool into int, which prints out "(1) == (0)", which isn't as useful.
70 // This prints "(true) == (false)".
71 void printAssertionMessage(bool ok, const char* file, uint16_t line,
72  bool lhs, const char *opName, bool rhs) {
73 
74  // Don't use F() strings here. Same reason as above.
75  Print* printer = Printer::getPrinter();
76  printer->print("Assertion ");
77  printer->print(ok ? "passed" : "failed");
78  printer->print(": (");
79  printer->print(lhs ? "true" : "false");
80  printer->print(") ");
81  printer->print(opName);
82  printer->print(" (");
83  printer->print(rhs ? "true" : "false");
84  printer->print(')');
85  printer->print(", file ");
86  printer->print(file);
87  printer->print(", line ");
88  printer->print(line);
89  printer->println('.');
90 }
91 
92 // Special version for assertTrue(arg) and assertFalse(arg).
93 // Prints:
94 // "Assertion passed/failed: (arg) is true"
95 // "Assertion passed/failed: (arg) is false"
96 void printAssertionBoolMessage(bool ok, const char* file, uint16_t line,
97  bool arg, bool value) {
98 
99  // Don't use F() strings here. Same reason as above.
100  Print* printer = Printer::getPrinter();
101  printer->print("Assertion ");
102  printer->print(ok ? "passed" : "failed");
103  printer->print(": (");
104  printer->print(arg ? "true" : "false");
105  printer->print(") is ");
106  printer->print(value ? "true" : "false");
107  printer->print(", file ");
108  printer->print(file);
109  printer->print(", line ");
110  printer->print(line);
111  printer->println('.');
112 }
113 
114 } // namespace
115 
117  return (ok && isVerbosity(Verbosity::kAssertionPassed)) ||
119 }
120 
121 bool Assertion::assertionBool(const char* file, uint16_t line, bool arg,
122  bool value) {
123  if (isDone()) return false;
124  bool ok = (arg == value);
125  if (isOutputEnabled(ok)) {
126  printAssertionBoolMessage(ok, file, line, arg, value);
127  }
128  setPassOrFail(ok);
129  return ok;
130 }
131 
132 bool Assertion::assertion(const char* file, uint16_t line, bool lhs,
133  const char* opName, bool (*op)(bool lhs, bool rhs),
134  bool rhs) {
135  if (isDone()) return false;
136  bool ok = op(lhs, rhs);
137  if (isOutputEnabled(ok)) {
138  printAssertionMessage(ok, file, line, lhs, opName, rhs);
139  }
140  setPassOrFail(ok);
141  return ok;
142 }
143 
144 bool Assertion::assertion(const char* file, uint16_t line, char lhs,
145  const char* opName, bool (*op)(char lhs, char rhs),
146  char rhs) {
147  if (isDone()) return false;
148  bool ok = op(lhs, rhs);
149  if (isOutputEnabled(ok)) {
150  printAssertionMessage(ok, file, line, lhs, opName, rhs);
151  }
152  setPassOrFail(ok);
153  return ok;
154 }
155 
156 bool Assertion::assertion(const char* file, uint16_t line, int lhs,
157  const char* opName, bool (*op)(int lhs, int rhs),
158  int rhs) {
159  if (isDone()) return false;
160  bool ok = op(lhs, rhs);
161  if (isOutputEnabled(ok)) {
162  printAssertionMessage(ok, file, line, lhs, opName, rhs);
163  }
164  setPassOrFail(ok);
165  return ok;
166 }
167 
168 bool Assertion::assertion(const char* file, uint16_t line, unsigned int lhs,
169  const char* opName, bool (*op)(unsigned int lhs, unsigned int rhs),
170  unsigned int rhs) {
171  if (isDone()) return false;
172  bool ok = op(lhs, rhs);
173  if (isOutputEnabled(ok)) {
174  printAssertionMessage(ok, file, line, lhs, opName, rhs);
175  }
176  setPassOrFail(ok);
177  return ok;
178 }
179 
180 bool Assertion::assertion(const char* file, uint16_t line, long lhs,
181  const char* opName, bool (*op)(long lhs, long rhs),
182  long rhs) {
183  if (isDone()) return false;
184  bool ok = op(lhs, rhs);
185  if (isOutputEnabled(ok)) {
186  printAssertionMessage(ok, file, line, lhs, opName, rhs);
187  }
188  setPassOrFail(ok);
189  return ok;
190 }
191 
192 bool Assertion::assertion(const char* file, uint16_t line, unsigned long lhs,
193  const char* opName, bool (*op)(unsigned long lhs, unsigned long rhs),
194  unsigned long rhs) {
195  if (isDone()) return false;
196  bool ok = op(lhs, rhs);
197  if (isOutputEnabled(ok)) {
198  printAssertionMessage(ok, file, line, lhs, opName, rhs);
199  }
200  setPassOrFail(ok);
201  return ok;
202 }
203 
204 bool Assertion::assertion(const char* file, uint16_t line, double lhs,
205  const char* opName, bool (*op)(double lhs, double rhs),
206  double rhs) {
207  if (isDone()) return false;
208  bool ok = op(lhs, rhs);
209  if (isOutputEnabled(ok)) {
210  printAssertionMessage(ok, file, line, lhs, opName, rhs);
211  }
212  setPassOrFail(ok);
213  return ok;
214 }
215 
216 bool Assertion::assertion(const char* file, uint16_t line, const char* lhs,
217  const char* opName, bool (*op)(const char* lhs, const char* rhs),
218  const char* rhs) {
219  if (isDone()) return false;
220  bool ok = op(lhs, rhs);
221  if (isOutputEnabled(ok)) {
222  printAssertionMessage(ok, file, line, lhs, opName, rhs);
223  }
224  setPassOrFail(ok);
225  return ok;
226 }
227 
228 bool Assertion::assertion(const char* file, uint16_t line, const char* lhs,
229  const char *opName, bool (*op)(const char* lhs, const String& rhs),
230  const String& rhs) {
231  if (isDone()) return false;
232  bool ok = op(lhs, rhs);
233  if (isOutputEnabled(ok)) {
234  printAssertionMessage(ok, file, line, lhs, opName, rhs);
235  }
236  setPassOrFail(ok);
237  return ok;
238 }
239 
240 bool Assertion::assertion(const char* file, uint16_t line, const char* lhs,
241  const char *opName,
242  bool (*op)(const char* lhs, const __FlashStringHelper* rhs),
243  const __FlashStringHelper* rhs) {
244  if (isDone()) return false;
245  bool ok = op(lhs, rhs);
246  if (isOutputEnabled(ok)) {
247  printAssertionMessage(ok, file, line, lhs, opName, rhs);
248  }
249  setPassOrFail(ok);
250  return ok;
251 }
252 
253 bool Assertion::assertion(const char* file, uint16_t line, const String& lhs,
254  const char *opName, bool (*op)(const String& lhs, const char* rhs),
255  const char* rhs) {
256  if (isDone()) return false;
257  bool ok = op(lhs, rhs);
258  if (isOutputEnabled(ok)) {
259  printAssertionMessage(ok, file, line, lhs, opName, rhs);
260  }
261  setPassOrFail(ok);
262  return ok;
263 }
264 
265 bool Assertion::assertion(const char* file, uint16_t line, const String& lhs,
266  const char *opName, bool (*op)(const String& lhs, const String& rhs),
267  const String& rhs) {
268  if (isDone()) return false;
269  bool ok = op(lhs, rhs);
270  if (isOutputEnabled(ok)) {
271  printAssertionMessage(ok, file, line, lhs, opName, rhs);
272  }
273  setPassOrFail(ok);
274  return ok;
275 }
276 
277 bool Assertion::assertion(const char* file, uint16_t line, const String& lhs,
278  const char *opName,
279  bool (*op)(const String& lhs, const __FlashStringHelper* rhs),
280  const __FlashStringHelper* rhs) {
281  if (isDone()) return false;
282  bool ok = op(lhs, rhs);
283  if (isOutputEnabled(ok)) {
284  printAssertionMessage(ok, file, line, lhs, opName, rhs);
285  }
286  setPassOrFail(ok);
287  return ok;
288 }
289 
290 bool Assertion::assertion(const char* file, uint16_t line,
291  const __FlashStringHelper* lhs, const char *opName,
292  bool (*op)(const __FlashStringHelper* lhs, const char* rhs),
293  const char* rhs) {
294  if (isDone()) return false;
295  bool ok = op(lhs, rhs);
296  if (isOutputEnabled(ok)) {
297  printAssertionMessage(ok, file, line, lhs, opName, rhs);
298  }
299  setPassOrFail(ok);
300  return ok;
301 }
302 
303 bool Assertion::assertion(const char* file, uint16_t line,
304  const __FlashStringHelper* lhs, const char *opName,
305  bool (*op)(const __FlashStringHelper* lhs, const String& rhs),
306  const String& rhs) {
307  if (isDone()) return false;
308  bool ok = op(lhs, rhs);
309  if (isOutputEnabled(ok)) {
310  printAssertionMessage(ok, file, line, lhs, opName, rhs);
311  }
312  setPassOrFail(ok);
313  return ok;
314 }
315 
316 bool Assertion::assertion(const char* file, uint16_t line,
317  const __FlashStringHelper* lhs, const char *opName,
318  bool (*op)(const __FlashStringHelper* lhs, const __FlashStringHelper* rhs),
319  const __FlashStringHelper* rhs) {
320  if (isDone()) return false;
321  bool ok = op(lhs, rhs);
322  if (isOutputEnabled(ok)) {
323  printAssertionMessage(ok, file, line, lhs, opName, rhs);
324  }
325  setPassOrFail(ok);
326  return ok;
327 }
328 
329 namespace {
330 
331 // Verbose versions of above which accept the string arguments of the
332 // assertXxx() macros, so that the error messages are more verbose.
333 //
334 // Prints something like the following:
335 // Assertion failed: (x=5) == (y=6), file Test.ino, line 820.
336 // Assertion passed: (x=6) == (y=6), file Test.ino, line 820.
337 template <typename A, typename B>
338 void printAssertionMessageVerbose(bool ok, const char* file,
339  uint16_t line, const A& lhs, internal::FlashStringType lhsString,
340  const char *opName, const B& rhs, internal::FlashStringType rhsString) {
341 
342  // Don't use F() strings here because flash memory strings are not deduped by
343  // the compiler, so each template instantiation of this method causes a
344  // duplication of all the strings below. See
345  // https://github.com/mmurdoch/arduinounit/issues/70
346  // for more info.
347  Print* printer = Printer::getPrinter();
348  printer->print("Assertion ");
349  printer->print(ok ? "passed" : "failed");
350  printer->print(": (");
351  printer->print(lhsString);
352  printer->print('=');
353  printer->print(lhs);
354  printer->print(") ");
355  printer->print(opName);
356  printer->print(" (");
357  printer->print(rhsString);
358  printer->print('=');
359  printer->print(rhs);
360  printer->print(')');
361  // reuse string in MataAssertion::printAssertionTestStatusMessage()
362  printer->print(", file ");
363  printer->print(file);
364  printer->print(", line ");
365  printer->print(line);
366  printer->println('.');
367 }
368 
369 // Special version of (bool, bool) because Arduino Print.h converts
370 // bool into int, which prints out "(1) == (0)", which isn't as useful.
371 // This prints "(x=true) == (y=false)".
372 void printAssertionMessageVerbose(bool ok, const char* file,
373  uint16_t line, bool lhs, internal::FlashStringType lhsString,
374  const char *opName, bool rhs, internal::FlashStringType rhsString) {
375 
376  // Don't use F() strings here. Same reason as above.
377  Print* printer = Printer::getPrinter();
378  printer->print("Assertion ");
379  printer->print(ok ? "passed" : "failed");
380  printer->print(": (");
381  printer->print(lhsString);
382  printer->print('=');
383  printer->print(lhs ? "true" : "false");
384  printer->print(") ");
385  printer->print(opName);
386  printer->print(" (");
387  printer->print(rhsString);
388  printer->print('=');
389  printer->print(rhs ? "true" : "false");
390  printer->print(')');
391  printer->print(", file ");
392  printer->print(file);
393  printer->print(", line ");
394  printer->print(line);
395  printer->println('.');
396 }
397 
398 // Special version for assertTrue(arg) and assertFalse(arg).
399 // Prints:
400 // "Assertion passed/failed: (x=arg) is true"
401 // "Assertion passed/failed: (x=arg) is false"
402 void printAssertionBoolMessageVerbose(bool ok, const char* file,
403  uint16_t line, bool arg, internal::FlashStringType argString, bool value) {
404 
405  // Don't use F() strings here. Same reason as above.
406  Print* printer = Printer::getPrinter();
407  printer->print("Assertion ");
408  printer->print(ok ? "passed" : "failed");
409  printer->print(": (");
410  printer->print(argString);
411  printer->print('=');
412  printer->print(arg ? "true" : "false");
413  printer->print(") is ");
414  printer->print(value ? "true" : "false");
415  printer->print(", file ");
416  printer->print(file);
417  printer->print(", line ");
418  printer->print(line);
419  printer->println('.');
420 }
421 
422 } // namespace
423 
424 bool Assertion::assertionBoolVerbose(const char* file, uint16_t line, bool arg,
425  internal::FlashStringType argString, bool value) {
426  if (isDone()) return false;
427  bool ok = (arg == value);
428  if (isOutputEnabled(ok)) {
429  printAssertionBoolMessageVerbose(ok, file, line, arg, argString, value);
430  }
431  setPassOrFail(ok);
432  return ok;
433 }
434 
435 bool Assertion::assertionVerbose(const char* file, uint16_t line, bool lhs,
436  internal::FlashStringType lhsString, const char* opName,
437  bool (*op)(bool lhs, bool rhs), bool rhs,
438  internal::FlashStringType rhsString) {
439  if (isDone()) return false;
440  bool ok = op(lhs, rhs);
441  if (isOutputEnabled(ok)) {
442  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
443  rhsString);
444  }
445  setPassOrFail(ok);
446  return ok;
447 }
448 
449 bool Assertion::assertionVerbose(const char* file, uint16_t line, char lhs,
450  internal::FlashStringType lhsString, const char* opName,
451  bool (*op)(char lhs, char rhs), char rhs,
452  internal::FlashStringType rhsString) {
453  if (isDone()) return false;
454  bool ok = op(lhs, rhs);
455  if (isOutputEnabled(ok)) {
456  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
457  rhsString);
458  }
459  setPassOrFail(ok);
460  return ok;
461 }
462 
463 bool Assertion::assertionVerbose(const char* file, uint16_t line, int lhs,
464  internal::FlashStringType lhsString, const char* opName,
465  bool (*op)(int lhs, int rhs), int rhs,
466  internal::FlashStringType rhsString) {
467  if (isDone()) return false;
468  bool ok = op(lhs, rhs);
469  if (isOutputEnabled(ok)) {
470  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
471  rhsString);
472  }
473  setPassOrFail(ok);
474  return ok;
475 }
476 
477 bool Assertion::assertionVerbose(const char* file, uint16_t line,
478  unsigned int lhs, internal::FlashStringType lhsString, const char* opName,
479  bool (*op)(unsigned int lhs, unsigned int rhs),
480  unsigned int rhs, internal::FlashStringType rhsString) {
481  if (isDone()) return false;
482  bool ok = op(lhs, rhs);
483  if (isOutputEnabled(ok)) {
484  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
485  rhsString);
486  }
487  setPassOrFail(ok);
488  return ok;
489 }
490 
491 bool Assertion::assertionVerbose(const char* file, uint16_t line, long lhs,
492  internal::FlashStringType lhsString, const char* opName,
493  bool (*op)(long lhs, long rhs), long rhs,
494  internal::FlashStringType rhsString) {
495  if (isDone()) return false;
496  bool ok = op(lhs, rhs);
497  if (isOutputEnabled(ok)) {
498  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
499  rhsString);
500  }
501  setPassOrFail(ok);
502  return ok;
503 }
504 
505 bool Assertion::assertionVerbose(const char* file, uint16_t line,
506  unsigned long lhs, internal::FlashStringType lhsString, const char* opName,
507  bool (*op)(unsigned long lhs, unsigned long rhs),
508  unsigned long rhs, internal::FlashStringType rhsString) {
509  if (isDone()) return false;
510  bool ok = op(lhs, rhs);
511  if (isOutputEnabled(ok)) {
512  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
513  rhsString);
514  }
515  setPassOrFail(ok);
516  return ok;
517 }
518 
519 bool Assertion::assertionVerbose(const char* file, uint16_t line, double lhs,
520  internal::FlashStringType lhsString, const char* opName,
521  bool (*op)(double lhs, double rhs), double rhs,
522  internal::FlashStringType rhsString) {
523  if (isDone()) return false;
524  bool ok = op(lhs, rhs);
525  if (isOutputEnabled(ok)) {
526  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
527  rhsString);
528  }
529  setPassOrFail(ok);
530  return ok;
531 }
532 
533 bool Assertion::assertionVerbose(const char* file, uint16_t line,
534  const char* lhs, internal::FlashStringType lhsString, const char* opName,
535  bool (*op)(const char* lhs, const char* rhs),
536  const char* rhs, internal::FlashStringType rhsString) {
537  if (isDone()) return false;
538  bool ok = op(lhs, rhs);
539  if (isOutputEnabled(ok)) {
540  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
541  rhsString);
542  }
543  setPassOrFail(ok);
544  return ok;
545 }
546 
547 bool Assertion::assertionVerbose(const char* file, uint16_t line,
548  const char* lhs, internal::FlashStringType lhsString,
549  const char *opName, bool (*op)(const char* lhs, const String& rhs),
550  const String& rhs, internal::FlashStringType rhsString) {
551  if (isDone()) return false;
552  bool ok = op(lhs, rhs);
553  if (isOutputEnabled(ok)) {
554  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
555  rhsString);
556  }
557  setPassOrFail(ok);
558  return ok;
559 }
560 
561 bool Assertion::assertionVerbose(const char* file, uint16_t line,
562  const char* lhs, internal::FlashStringType lhsString, const char *opName,
563  bool (*op)(const char* lhs, const __FlashStringHelper* rhs),
564  const __FlashStringHelper* rhs, internal::FlashStringType rhsString) {
565  if (isDone()) return false;
566  bool ok = op(lhs, rhs);
567  if (isOutputEnabled(ok)) {
568  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
569  rhsString);
570  }
571  setPassOrFail(ok);
572  return ok;
573 }
574 
575 bool Assertion::assertionVerbose(const char* file, uint16_t line,
576  const String& lhs, internal::FlashStringType lhsString, const char *opName,
577  bool (*op)(const String& lhs, const char* rhs),
578  const char* rhs, internal::FlashStringType rhsString) {
579  if (isDone()) return false;
580  bool ok = op(lhs, rhs);
581  if (isOutputEnabled(ok)) {
582  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
583  rhsString);
584  }
585  setPassOrFail(ok);
586  return ok;
587 }
588 
589 bool Assertion::assertionVerbose(const char* file, uint16_t line,
590  const String& lhs, internal::FlashStringType lhsString, const char *opName,
591  bool (*op)(const String& lhs, const String& rhs),
592  const String& rhs, internal::FlashStringType rhsString) {
593  if (isDone()) return false;
594  bool ok = op(lhs, rhs);
595  if (isOutputEnabled(ok)) {
596  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
597  rhsString);
598  }
599  setPassOrFail(ok);
600  return ok;
601 }
602 
603 bool Assertion::assertionVerbose(const char* file, uint16_t line,
604  const String& lhs, internal::FlashStringType lhsString, const char *opName,
605  bool (*op)(const String& lhs, const __FlashStringHelper* rhs),
606  const __FlashStringHelper* rhs, internal::FlashStringType rhsString) {
607  if (isDone()) return false;
608  bool ok = op(lhs, rhs);
609  if (isOutputEnabled(ok)) {
610  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
611  rhsString);
612  }
613  setPassOrFail(ok);
614  return ok;
615 }
616 
617 bool Assertion::assertionVerbose(const char* file, uint16_t line,
618  const __FlashStringHelper* lhs, internal::FlashStringType lhsString,
619  const char *opName,
620  bool (*op)(const __FlashStringHelper* lhs, const char* rhs),
621  const char* rhs, internal::FlashStringType rhsString) {
622  if (isDone()) return false;
623  bool ok = op(lhs, rhs);
624  if (isOutputEnabled(ok)) {
625  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
626  rhsString);
627  }
628  setPassOrFail(ok);
629  return ok;
630 }
631 
632 bool Assertion::assertionVerbose(const char* file, uint16_t line,
633  const __FlashStringHelper* lhs, internal::FlashStringType lhsString,
634  const char *opName,
635  bool (*op)(const __FlashStringHelper* lhs, const String& rhs),
636  const String& rhs, internal::FlashStringType rhsString) {
637  if (isDone()) return false;
638  bool ok = op(lhs, rhs);
639  if (isOutputEnabled(ok)) {
640  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
641  rhsString);
642  }
643  setPassOrFail(ok);
644  return ok;
645 }
646 
647 bool Assertion::assertionVerbose(const char* file, uint16_t line,
648  const __FlashStringHelper* lhs, internal::FlashStringType lhsString,
649  const char *opName,
650  bool (*op)(const __FlashStringHelper* lhs, const __FlashStringHelper* rhs),
651  const __FlashStringHelper* rhs, internal::FlashStringType rhsString) {
652  if (isDone()) return false;
653  bool ok = op(lhs, rhs);
654  if (isOutputEnabled(ok)) {
655  printAssertionMessageVerbose(ok, file, line, lhs, lhsString, opName, rhs,
656  rhsString);
657  }
658  setPassOrFail(ok);
659  return ok;
660 }
661 
662 }
void setPassOrFail(bool ok)
Set the status to Passed or Failed depending on ok.
Definition: Test.cpp:50
bool isOutputEnabled(bool ok)
Returns true if an assertion message should be printed.
Definition: Assertion.cpp:116
bool isVerbosity(uint8_t verbosity)
Determine if any of the given verbosity is enabled.
Definition: Test.h:261
static const uint8_t kAssertionPassed
Print assertXxx() passed message.
Definition: Verbosity.h:40
bool isDone()
Return true if test has been asserted.
Definition: Test.h:196
static Print * getPrinter()
Get the output printer used by the various assertion() methods and the TestRunner.
Definition: Printer.h:52
static const uint8_t kAssertionFailed
Print assertXxx() failed message.
Definition: Verbosity.h:43
Flash strings (using F() macro) on the ESP8266 platform cannot be placed in an inline context...