| OLD | NEW |
| 1 // Copyright 2008 Google Inc. All Rights Reserved. | 1 // Copyright 2008 Google Inc. All Rights Reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 27 | 27 |
| 28 #ifndef CCTEST_H_ | 28 #ifndef CCTEST_H_ |
| 29 #define CCTEST_H_ | 29 #define CCTEST_H_ |
| 30 | 30 |
| 31 #ifndef TEST | 31 #ifndef TEST |
| 32 #define TEST(Name) \ | 32 #define TEST(Name) \ |
| 33 static void Test##Name(); \ | 33 static void Test##Name(); \ |
| 34 CcTest register_test_##Name(Test##Name, __FILE__, #Name); \ | 34 CcTest register_test_##Name(Test##Name, __FILE__, #Name, true); \ |
| 35 static void Test##Name() |
| 36 #endif |
| 37 |
| 38 #ifndef DISABLED_TEST |
| 39 #define DISABLED_TEST(Name) \ |
| 40 static void Test##Name(); \ |
| 41 CcTest register_test_##Name(Test##Name, __FILE__, #Name, false); \ |
| 35 static void Test##Name() | 42 static void Test##Name() |
| 36 #endif | 43 #endif |
| 37 | 44 |
| 38 | 45 |
| 39 class CcTest { | 46 class CcTest { |
| 40 public: | 47 public: |
| 41 typedef void (TestFunction)(); | 48 typedef void (TestFunction)(); |
| 42 CcTest(TestFunction* callback, const char* file, const char* name); | 49 CcTest(TestFunction* callback, const char* file, const char* name, |
| 50 bool enabled); |
| 43 void Run() { callback_(); } | 51 void Run() { callback_(); } |
| 44 static int test_count(); | 52 static int test_count(); |
| 45 static CcTest* last() { return last_; } | 53 static CcTest* last() { return last_; } |
| 46 CcTest* prev() { return prev_; } | 54 CcTest* prev() { return prev_; } |
| 47 const char* file() { return file_; } | 55 const char* file() { return file_; } |
| 48 const char* name() { return name_; } | 56 const char* name() { return name_; } |
| 57 bool enabled() { return enabled_; } |
| 49 private: | 58 private: |
| 50 TestFunction* callback_; | 59 TestFunction* callback_; |
| 51 const char* file_; | 60 const char* file_; |
| 52 const char* name_; | 61 const char* name_; |
| 62 bool enabled_; |
| 53 static CcTest* last_; | 63 static CcTest* last_; |
| 54 CcTest* prev_; | 64 CcTest* prev_; |
| 55 }; | 65 }; |
| 56 | 66 |
| 57 #endif // ifndef CCTEST_H_ | 67 #endif // ifndef CCTEST_H_ |
| OLD | NEW |