Chromium Code Reviews| Index: runtime/vm/assert.h |
| =================================================================== |
| --- runtime/vm/assert.h (revision 2291) |
| +++ runtime/vm/assert.h (working copy) |
| @@ -49,6 +49,9 @@ |
| void StringEquals(const E& expected, const A& actual); |
| template<typename E, typename A> |
| + void Substring(const E& needle, const A& haystack); |
|
srdjan
2011/12/12 22:12:50
IsSubstring?
turnidge
2011/12/12 22:20:33
Done.
|
| + |
| + template<typename E, typename A> |
| void LessThan(const E& left, const A& right); |
| template<typename E, typename A> |
| @@ -140,6 +143,18 @@ |
| template<typename E, typename A> |
| +void DynamicAssertionHelper::Substring(const E& needle, const A& haystack) { |
| + std::stringstream ess, ass; |
| + ess << needle; |
| + ass << haystack; |
| + std::string es = ess.str(), as = ass.str(); |
| + if (as.find(es) != std::string::npos) return; |
| + Fail("expected <\"%s\"> to be a substring of <\"%s\">", |
| + es.c_str(), as.c_str()); |
| +} |
| + |
| + |
| +template<typename E, typename A> |
| void DynamicAssertionHelper::LessThan(const E& left, const A& right) { |
| if (left < right) return; |
| std::stringstream ess, ass; |
| @@ -248,6 +263,9 @@ |
| #define EXPECT_STREQ(expected, actual) \ |
| dart::Expect(__FILE__, __LINE__).StringEquals((expected), (actual)) |
| +#define EXPECT_SUBSTRING(needle, haystack) \ |
| + dart::Expect(__FILE__, __LINE__).Substring((needle), (haystack)) |
| + |
| #define EXPECT_LT(left, right) \ |
| dart::Expect(__FILE__, __LINE__).LessThan((left), (right)) |