Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: runtime/vm/assert.h

Issue 8851008: Add support for interrupting an isolate in the vm. Interrupts are (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: '' Created 9 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: runtime/vm/assert.h
===================================================================
--- runtime/vm/assert.h (revision 2528)
+++ runtime/vm/assert.h (working copy)
@@ -49,6 +49,9 @@
void StringEquals(const E& expected, const A& actual);
template<typename E, typename A>
+ void IsSubstring(const E& needle, const A& haystack);
+
+ 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::IsSubstring(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__).IsSubstring((needle), (haystack))
+
#define EXPECT_LT(left, right) \
dart::Expect(__FILE__, __LINE__).LessThan((left), (right))

Powered by Google App Engine
This is Rietveld 408576698