OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef PLATFORM_ASSERT_H_ | 5 #ifndef PLATFORM_ASSERT_H_ |
6 #define PLATFORM_ASSERT_H_ | 6 #define PLATFORM_ASSERT_H_ |
7 | 7 |
8 // TODO(5411406): include sstream for now, once we have a Utils::toString() | 8 // TODO(5411406): include sstream for now, once we have a Utils::toString() |
9 // implemented for all the primitive types we can replace the usage of | 9 // implemented for all the primitive types we can replace the usage of |
10 // sstream by Utils::toString() | 10 // sstream by Utils::toString() |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
137 } | 137 } |
138 | 138 |
139 | 139 |
140 template<typename E, typename A> | 140 template<typename E, typename A> |
141 void DynamicAssertionHelper::StringEquals(const E& expected, const A& actual) { | 141 void DynamicAssertionHelper::StringEquals(const E& expected, const A& actual) { |
142 std::ostringstream ess, ass; | 142 std::ostringstream ess, ass; |
143 ess << expected; | 143 ess << expected; |
144 ass << actual; | 144 ass << actual; |
145 std::string es = ess.str(), as = ass.str(); | 145 std::string es = ess.str(), as = ass.str(); |
146 if (as == es) return; | 146 if (as == es) return; |
147 Fail("expected: <\"%s\"> but was: <\"%s\">", es.c_str(), as.c_str()); | 147 Fail("expected:\n<\"%s\">\nbut was:\n<\"%s\">", es.c_str(), as.c_str()); |
148 } | 148 } |
149 | 149 |
150 | 150 |
151 template<typename E, typename A> | 151 template<typename E, typename A> |
152 void DynamicAssertionHelper::IsSubstring(const E& needle, const A& haystack) { | 152 void DynamicAssertionHelper::IsSubstring(const E& needle, const A& haystack) { |
153 std::ostringstream ess, ass; | 153 std::ostringstream ess, ass; |
154 ess << needle; | 154 ess << needle; |
155 ass << haystack; | 155 ass << haystack; |
156 std::string es = ess.str(), as = ass.str(); | 156 std::string es = ess.str(), as = ass.str(); |
157 if (as.find(es) != std::string::npos) return; | 157 if (as.find(es) != std::string::npos) return; |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
344 | 344 |
345 #define FAIL1(format, p1) \ | 345 #define FAIL1(format, p1) \ |
346 dart::Expect(__FILE__, __LINE__).Fail(format, (p1)) | 346 dart::Expect(__FILE__, __LINE__).Fail(format, (p1)) |
347 | 347 |
348 #define FAIL2(format, p1, p2) \ | 348 #define FAIL2(format, p1, p2) \ |
349 dart::Expect(__FILE__, __LINE__).Fail(format, (p1), (p2)) | 349 dart::Expect(__FILE__, __LINE__).Fail(format, (p1), (p2)) |
350 | 350 |
351 #endif // defined(TESTING) | 351 #endif // defined(TESTING) |
352 | 352 |
353 #endif // PLATFORM_ASSERT_H_ | 353 #endif // PLATFORM_ASSERT_H_ |
OLD | NEW |