-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Align assertion statements; change some stderr to stdout and flush #322
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,24 +49,20 @@ class Test | |
~ReporterTAP() {} | ||
|
||
void onTestRunInit(int numTests) { | ||
cerr << "TAP version 13" << endl; | ||
cerr << 1 << ".." << numTests << endl; // we know how many tests, in advance | ||
cout << "TAP version 13" << endl << flush; | ||
cout << 1 << ".." << numTests << endl << flush; // we know how many tests, in advance | ||
mTestCounter = 0; | ||
} | ||
|
||
void onTestStart(TestData td) { | ||
mAssertCounter = 0; | ||
++mTestCounter; | ||
cerr << "# Subtest: " << td.name << endl; | ||
cout << "# Subtest: " << td.name << endl << flush; | ||
} | ||
|
||
void onTestEnd(TestData td) { | ||
cerr << " 1.." << mAssertCounter << endl; | ||
if (td.result == RESULT_PASS) { | ||
cerr << "ok " << mTestCounter << " - " << td.name << endl; | ||
} else { | ||
cerr << "not ok " << mTestCounter << " - " << td.name << endl; | ||
} | ||
cout << " 1.." << mAssertCounter << endl << flush; | ||
cout << (td.result == RESULT_PASS ? "ok " : "not ok ") << mTestCounter << " - " << td.name << endl << flush; | ||
} | ||
|
||
// non-comparative assert | ||
|
@@ -76,8 +72,10 @@ class Test | |
const char* description, | ||
bool pass | ||
) { | ||
cerr << " " << (pass ? "" : "not ") << "ok " << ++mAssertCounter << " - " << description << endl; | ||
if (!pass) { | ||
if (pass) { | ||
cout << " ok " << ++mAssertCounter << " - " << description << endl << flush; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation is off here. |
||
} else { | ||
cout << " not ok " << ++mAssertCounter << " - " << description << endl << flush; | ||
cerr << " ---" << endl; | ||
cerr << " at:" << endl; | ||
cerr << " file: " << file << endl; | ||
|
@@ -99,9 +97,12 @@ class Test | |
const char* rhsLabel, | ||
const B &rhs | ||
) { | ||
cerr << " " << (pass ? "" : "not ") << "ok " << ++mAssertCounter << " - "; | ||
cerr << description << " " << lhsLabel << " " << opLabel << " " << rhsLabel << endl; | ||
if (!pass) { | ||
if (pass) { | ||
cout << " ok " << ++mAssertCounter << " - "; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Indentation is off here. |
||
cout << description << " " << lhsLabel << " " << opLabel << " " << rhsLabel << endl << flush; | ||
} else { | ||
cout << " not ok " << ++mAssertCounter << " - "; | ||
cout << description << " " << lhsLabel << " " << opLabel << " " << rhsLabel << endl << flush; | ||
cerr << " ---" << endl; | ||
cerr << " operator: " << opLabel << endl; | ||
cerr << " " << lhsRelevance << ": " << lhs << endl; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,17 +44,17 @@ | |
#define assertFalse(arg) arduinoCITestBehaviorExp(false, "False " #arg, !(arg)) | ||
#define assertNull(arg) arduinoCITestBehaviorExp(false, "Null " #arg, ((void*)NULL == (void*)(arg))) | ||
#define assertNotNull(arg) arduinoCITestBehaviorExp(false, "NotNull " #arg, ((void*)NULL != (void*)(arg))) | ||
#define assertEqual(arg1,arg2) arduinoCIAssertOp("Equal","expected",arg1,compareEqual,"==","actual",arg2) | ||
#define assertNotEqual(arg1,arg2) arduinoCIAssertOp("NotEqual","unwanted",arg1,compareNotEqual,"!=","actual",arg2) | ||
#define assertComparativeEquivalent(arg1,arg2) arduinoCIAssertOp("ComparativeEquivalent","expected",arg1,compareEquivalent,"!<>","actual",arg2) | ||
#define assertComparativeNotEquivalent(arg1,arg2) arduinoCIAssertOp("ComparativeNotEquivalent","unwanted",arg1,compareNotEquivalent,"<>","actual",arg2) | ||
#define assertLess(arg1,arg2) arduinoCIAssertOp("Less","lowerBound",arg1,compareLess,"<","actual",arg2) | ||
#define assertMore(arg1,arg2) arduinoCIAssertOp("More","upperBound",arg1,compareMore,">","actual",arg2) | ||
#define assertLessOrEqual(arg1,arg2) arduinoCIAssertOp("LessOrEqual","lowerBound",arg1,compareLessOrEqual,"<=","actual",arg2) | ||
#define assertMoreOrEqual(arg1,arg2) arduinoCIAssertOp("MoreOrEqual","upperBound",arg1,compareMoreOrEqual,">=","actual",arg2) | ||
#define assertEqual(arg1,arg2) arduinoCIAssertOp("Equal","expected",arg1,compareEqual,"=="," actual",arg2) | ||
#define assertNotEqual(arg1,arg2) arduinoCIAssertOp("NotEqual","unwanted",arg1,compareNotEqual,"!="," actual",arg2) | ||
#define assertComparativeEquivalent(arg1,arg2) arduinoCIAssertOp("ComparativeEquivalent","expected",arg1,compareEquivalent,"!<>"," actual",arg2) | ||
#define assertComparativeNotEquivalent(arg1,arg2) arduinoCIAssertOp("ComparativeNotEquivalent","unwanted",arg1,compareNotEquivalent,"<>"," actual",arg2) | ||
#define assertLess(arg1,arg2) arduinoCIAssertOp("Less","lowerBound",arg1,compareLess,"<"," actual",arg2) | ||
#define assertMore(arg1,arg2) arduinoCIAssertOp("More","upperBound",arg1,compareMore,">"," actual",arg2) | ||
#define assertLessOrEqual(arg1,arg2) arduinoCIAssertOp("LessOrEqual","lowerBound",arg1,compareLessOrEqual,"<="," actual",arg2) | ||
#define assertMoreOrEqual(arg1,arg2) arduinoCIAssertOp("MoreOrEqual","upperBound",arg1,compareMoreOrEqual,">="," actual",arg2) | ||
|
||
#define assertEqualFloat(arg1, arg2, arg3) arduinoCIAssertOp("EqualFloat", "epsilon", arg3, compareMoreOrEqual, ">=", "actualDifference", fabs(arg1 - arg2)) | ||
#define assertNotEqualFloat(arg1, arg2, arg3) arduinoCIAssertOp("NotEqualFloat", "epsilon", arg3, compareLessOrEqual, "<=", "insufficientDifference", fabs(arg1 - arg2)) | ||
#define assertEqualFloat(arg1, arg2, arg3) arduinoCIAssertOp("EqualFloat", " epsilon", arg3, compareMoreOrEqual, ">=", "actualDifference", fabs(arg1 - arg2)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should either add some comments explaining how the extra spaces work, or possibly work around it entirely by making it part of the macro. |
||
#define assertNotEqualFloat(arg1, arg2, arg3) arduinoCIAssertOp("NotEqualFloat", " epsilon", arg3, compareLessOrEqual, "<=", "insufficientDifference", fabs(arg1 - arg2)) | ||
#define assertInfinity(arg) arduinoCITestBehaviorExp(false, "Infinity " #arg, isinf(arg)) | ||
#define assertNotInfinity(arg) arduinoCITestBehaviorExp(false, "NotInfinity " #arg, !isinf(arg)) | ||
#define assertNAN(arg) arduinoCITestBehaviorExp(false, "NAN " #arg, isnan(arg)) | ||
|
@@ -66,17 +66,17 @@ | |
#define assureFalse(arg) arduinoCITestBehaviorExp(true, "False " #arg, !(arg)) | ||
#define assureNull(arg) arduinoCITestBehaviorExp(true, "Null " #arg, ((void*)NULL == (void*)(arg))) | ||
#define assureNotNull(arg) arduinoCITestBehaviorExp(true, "NotNull " #arg, ((void*)NULL != (void*)(arg))) | ||
#define assureEqual(arg1,arg2) arduinoCIAssureOp("Equal","expected",arg1,compareEqual,"==","actual",arg2) | ||
#define assureNotEqual(arg1,arg2) arduinoCIAssureOp("NotEqual","unwanted",arg1,compareNotEqual,"!=","actual",arg2) | ||
#define assureComparativeEquivalent(arg1,arg2) arduinoCIAssureOp("ComparativeEquivalent","expected",arg1,compareEquivalent,"!<>","actual",arg2) | ||
#define assureComparativeNotEquivalent(arg1,arg2) arduinoCIAssureOp("ComparativeNotEquivalent","unwanted",arg1,compareNotEquivalent,"<>","actual",arg2) | ||
#define assureLess(arg1,arg2) arduinoCIAssureOp("Less","lowerBound",arg1,compareLess,"<","actual",arg2) | ||
#define assureMore(arg1,arg2) arduinoCIAssureOp("More","upperBound",arg1,compareMore,">","actual",arg2) | ||
#define assureLessOrEqual(arg1,arg2) arduinoCIAssureOp("LessOrEqual","lowerBound",arg1,compareLessOrEqual,"<=","actual",arg2) | ||
#define assureMoreOrEqual(arg1,arg2) arduinoCIAssureOp("MoreOrEqual","upperBound",arg1,compareMoreOrEqual,">=","actual",arg2) | ||
#define assureEqual(arg1,arg2) arduinoCIAssureOp("Equal","expected",arg1,compareEqual,"=="," actual",arg2) | ||
#define assureNotEqual(arg1,arg2) arduinoCIAssureOp("NotEqual","unwanted",arg1,compareNotEqual,"!="," actual",arg2) | ||
#define assureComparativeEquivalent(arg1,arg2) arduinoCIAssureOp("ComparativeEquivalent","expected",arg1,compareEquivalent,"!<>"," actual",arg2) | ||
#define assureComparativeNotEquivalent(arg1,arg2) arduinoCIAssureOp("ComparativeNotEquivalent","unwanted",arg1,compareNotEquivalent,"<>"," actual",arg2) | ||
#define assureLess(arg1,arg2) arduinoCIAssureOp("Less","lowerBound",arg1,compareLess,"<"," actual",arg2) | ||
#define assureMore(arg1,arg2) arduinoCIAssureOp("More","upperBound",arg1,compareMore,">"," actual",arg2) | ||
#define assureLessOrEqual(arg1,arg2) arduinoCIAssureOp("LessOrEqual","lowerBound",arg1,compareLessOrEqual,"<="," actual",arg2) | ||
#define assureMoreOrEqual(arg1,arg2) arduinoCIAssureOp("MoreOrEqual","upperBound",arg1,compareMoreOrEqual,">="," actual",arg2) | ||
|
||
#define assureEqualFloat(arg1, arg2, arg3) arduinoCIAssureOp("EqualFloat", "epsilon", arg3, compareMoreOrEqual, ">=", "actualDifference", fabs(arg1 - arg2)) | ||
#define assureNotEqualFloat(arg1, arg2, arg3) arduinoCIAssureOp("NotEqualFloat", "epsilon", arg3, compareLessOrEqual, "<=", "insufficientDifference", fabs(arg1 - arg2)) | ||
#define assureEqualFloat(arg1, arg2, arg3) arduinoCIAssureOp("EqualFloat", " epsilon", arg3, compareMoreOrEqual, ">=", "actualDifference", fabs(arg1 - arg2)) | ||
#define assureNotEqualFloat(arg1, arg2, arg3) arduinoCIAssureOp("NotEqualFloat", " epsilon", arg3, compareLessOrEqual, "<=", "insufficientDifference", fabs(arg1 - arg2)) | ||
#define assureInfinity(arg) arduinoCITestBehaviorExp(true, "Infinity " #arg, isinf(arg)) | ||
#define assureNotInfinity(arg) arduinoCITestBehaviorExp(true, "NotInfinity " #arg, !isinf(arg)) | ||
#define assureNAN(arg) arduinoCITestBehaviorExp(true, "NAN " #arg, isnan(arg)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe I am being picky, but it would be great if you could split up the current commit (4bf8b53) into two separate commits, one for each entry here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you post a screenshot of the before/after alignment? I'm not sure what this change is addressing