| 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 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 if (MatchesFilter(#name, test_filter)) { \ | 306 if (MatchesFilter(#name, test_filter)) { \ |
| 307 set_callback_type(PP_OPTIONAL); \ | 307 set_callback_type(PP_OPTIONAL); \ |
| 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, CheckResourcesAndVars(error_message)); \ | 316 instance_->LogTest(#name, error_message); \ |
| 317 } | 317 } |
| 318 | 318 |
| 319 // Helper macros for checking values in tests, and returning a location | 319 // Helper macros for checking values in tests, and returning a location |
| 320 // description of the test fails. | 320 // description of the test fails. |
| 321 #define ASSERT_TRUE(cmd) \ | 321 #define ASSERT_TRUE(cmd) \ |
| 322 if (!(cmd)) { \ | 322 if (!(cmd)) { \ |
| 323 return MakeFailureMessage(__FILE__, __LINE__, #cmd); \ | 323 return MakeFailureMessage(__FILE__, __LINE__, #cmd); \ |
| 324 } | 324 } |
| 325 #define ASSERT_FALSE(cmd) ASSERT_TRUE(!(cmd)) | 325 #define ASSERT_FALSE(cmd) ASSERT_TRUE(!(cmd)) |
| 326 #define ASSERT_EQ(a, b) ASSERT_TRUE((a) == (b)) | 326 #define ASSERT_EQ(a, b) ASSERT_TRUE((a) == (b)) |
| 327 #define ASSERT_NE(a, b) ASSERT_TRUE((a) != (b)) | 327 #define ASSERT_NE(a, b) ASSERT_TRUE((a) != (b)) |
| 328 | 328 |
| 329 #define ASSERT_DOUBLE_EQ(a, b) ASSERT_TRUE( \ | 329 #define ASSERT_DOUBLE_EQ(a, b) ASSERT_TRUE( \ |
| 330 std::fabs((a)-(b)) <= std::numeric_limits<double>::epsilon()) | 330 std::fabs((a)-(b)) <= std::numeric_limits<double>::epsilon()) |
| 331 | 331 |
| 332 // Runs |function| as a subtest and asserts that it has passed. | 332 // Runs |function| as a subtest and asserts that it has passed. |
| 333 #define ASSERT_SUBTEST_SUCCESS(function) \ | 333 #define ASSERT_SUBTEST_SUCCESS(function) \ |
| 334 do { \ | 334 do { \ |
| 335 std::string result = (function); \ | 335 std::string result = (function); \ |
| 336 if (!result.empty()) \ | 336 if (!result.empty()) \ |
| 337 return result; \ | 337 return result; \ |
| 338 } while (false) | 338 } while (false) |
| 339 | 339 |
| 340 #define PASS() return std::string() | 340 #define PASS() return std::string() |
| 341 | 341 |
| 342 #endif // PPAPI_TESTS_TEST_CASE_H_ | 342 #endif // PPAPI_TESTS_TEST_CASE_H_ |
| OLD | NEW |