OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef PPAPI_TESTS_TEST_CASE_H_ | 5 #ifndef PPAPI_TESTS_TEST_CASE_H_ |
6 #define PPAPI_TESTS_TEST_CASE_H_ | 6 #define PPAPI_TESTS_TEST_CASE_H_ |
7 | 7 |
8 #include <cmath> | 8 #include <cmath> |
9 #include <limits> | 9 #include <limits> |
10 #include <set> | 10 #include <set> |
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 uint32_t objects = testing_interface_->GetLiveObjectsForInstance( \ | 308 uint32_t objects = testing_interface_->GetLiveObjectsForInstance( \ |
309 instance_->pp_instance()); \ | 309 instance_->pp_instance()); \ |
310 std::string error_message = Test##name(); \ | 310 std::string error_message = Test##name(); \ |
311 if (error_message.empty() && \ | 311 if (error_message.empty() && \ |
312 testing_interface_->GetLiveObjectsForInstance( \ | 312 testing_interface_->GetLiveObjectsForInstance( \ |
313 instance_->pp_instance()) != objects) \ | 313 instance_->pp_instance()) != objects) \ |
314 error_message = MakeFailureMessage(__FILE__, __LINE__, \ | 314 error_message = MakeFailureMessage(__FILE__, __LINE__, \ |
315 "reference leak check"); \ | 315 "reference leak check"); \ |
316 instance_->LogTest(#name, error_message); \ | 316 instance_->LogTest(#name, error_message); \ |
317 } | 317 } |
| 318 // TODO(dmichael): Add CheckResourcesAndVars above when Windows tests pass |
| 319 // cleanly. crbug.com/173503 |
318 | 320 |
319 // Helper macros for checking values in tests, and returning a location | 321 // Helper macros for checking values in tests, and returning a location |
320 // description of the test fails. | 322 // description of the test fails. |
321 #define ASSERT_TRUE(cmd) \ | 323 #define ASSERT_TRUE(cmd) \ |
322 if (!(cmd)) { \ | 324 if (!(cmd)) { \ |
323 return MakeFailureMessage(__FILE__, __LINE__, #cmd); \ | 325 return MakeFailureMessage(__FILE__, __LINE__, #cmd); \ |
324 } | 326 } |
325 #define ASSERT_FALSE(cmd) ASSERT_TRUE(!(cmd)) | 327 #define ASSERT_FALSE(cmd) ASSERT_TRUE(!(cmd)) |
326 #define ASSERT_EQ(a, b) ASSERT_TRUE((a) == (b)) | 328 #define ASSERT_EQ(a, b) ASSERT_TRUE((a) == (b)) |
327 #define ASSERT_NE(a, b) ASSERT_TRUE((a) != (b)) | 329 #define ASSERT_NE(a, b) ASSERT_TRUE((a) != (b)) |
328 | 330 |
329 #define ASSERT_DOUBLE_EQ(a, b) ASSERT_TRUE( \ | 331 #define ASSERT_DOUBLE_EQ(a, b) ASSERT_TRUE( \ |
330 std::fabs((a)-(b)) <= std::numeric_limits<double>::epsilon()) | 332 std::fabs((a)-(b)) <= std::numeric_limits<double>::epsilon()) |
331 | 333 |
332 // Runs |function| as a subtest and asserts that it has passed. | 334 // Runs |function| as a subtest and asserts that it has passed. |
333 #define ASSERT_SUBTEST_SUCCESS(function) \ | 335 #define ASSERT_SUBTEST_SUCCESS(function) \ |
334 do { \ | 336 do { \ |
335 std::string result = (function); \ | 337 std::string result = (function); \ |
336 if (!result.empty()) \ | 338 if (!result.empty()) \ |
337 return result; \ | 339 return result; \ |
338 } while (false) | 340 } while (false) |
339 | 341 |
340 #define PASS() return std::string() | 342 #define PASS() return std::string() |
341 | 343 |
342 #endif // PPAPI_TESTS_TEST_CASE_H_ | 344 #endif // PPAPI_TESTS_TEST_CASE_H_ |
OLD | NEW |