Skip to content

Commit 73af3d9

Browse files
committed
🐛 Support comparing raw char arrays
1 parent 325599e commit 73af3d9

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

include/GUnit/GAssert.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -165,6 +165,10 @@ class op {
165165
return comp<TLhs>{info_, lhs};
166166
}
167167

168+
comp<std::string> operator<<(const char* lhs) const {
169+
return comp<std::string>{info_, std::string{lhs}};
170+
}
171+
168172
private:
169173
info info_{};
170174
};

include/GUnit/GSteps.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -388,7 +388,7 @@ class Steps : public ::testing::EmptyTestEventListener {
388388
return Step<-1, true>{*this, {"Then", File::c_str(), line}, pattern};
389389
}
390390

391-
// clang-format off
391+
// clang-format off
392392
#if defined(__clang__)
393393
#pragma clang diagnostic ignored "-Wdollar-in-identifier-extension"
394394
#endif

test/GAssert.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,4 +50,9 @@ TEST(GAssert, ShouldSupportASSERT) {
5050

5151
ASSERT(42.0 == 42.);
5252
ASSERT(2*21 == i);
53+
54+
ASSERT("42" == std::string{"42"});
55+
ASSERT(std::string{"42"} == "42");
56+
ASSERT("42" != std::string{});
57+
ASSERT(std::string{} != "42");
5358
}

0 commit comments

Comments
 (0)