Frobby  0.9.5
macroes.h
Go to the documentation of this file.
1 /* Frobby: Software for monomial ideal computations.
2  Copyright (C) 2009 Bjarke Hammersholt Roune (www.broune.com)
3 
4  This program is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  This program is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with this program. If not, see http://www.gnu.org/licenses/.
16 */
17 #ifndef MACROES_GUARD
18 #define MACROES_GUARD
19 
20 #define GET_TEST_SUITE(SUITE) \
21  getTestSuite_##SUITE##_()
22 
23 class TestSuite;
25 
26 #define TEST_SUITE(SUITE) TEST_SUITE2(root, SUITE)
27 
28 #define TEST_SUITE2(PARENT, SUITE) \
29  TestSuite& GET_TEST_SUITE(PARENT); \
30  TestSuite& GET_TEST_SUITE(SUITE) { \
31  static TestSuite suite(#SUITE); \
32  return suite; \
33  } \
34  class _Helper_Suite_##SUITE { \
35  public: \
36  _Helper_Suite_##SUITE() { \
37  GET_TEST_SUITE(PARENT).add(&GET_TEST_SUITE(SUITE)); \
38  } \
39  } _Helper_Suite_##SUITE;
40 
41 #define TEST(SUITE, TEST_NAME) \
42  TestSuite& GET_TEST_SUITE(SUITE); \
43  class _testCase_##SUITE##_##TEST_NAME : public TestCase { \
44  public: \
45  void run(const char* __nameOfTest, bool _printDots); \
46  _testCase_##SUITE##_##TEST_NAME(): \
47  TestCase(#TEST_NAME) {} \
48  }; \
49  class _Helper_testCase_##SUITE##_##TEST_NAME { \
50  public: \
51  _Helper_testCase_##SUITE##_##TEST_NAME() { \
52  static _testCase_##SUITE##_##TEST_NAME test; \
53  GET_TEST_SUITE(SUITE).add(&test); \
54  } \
55  } static _helper_testCase_##SUITE##_##TEST_NAME; \
56  void _testCase_##SUITE##_##TEST_NAME::run \
57  (const char* __nameOfTest, bool __printDots)
58 
59 #define FRIEND_TEST(SUITE, TEST_NAME) \
60  friend class _testCase_##SUITE##_##TEST_NAME
61 
62 #endif
Represents a collection of tests, be they individual tests or yet other collections of tests.
Definition: TestSuite.h:28
#define GET_TEST_SUITE(SUITE)
Definition: macroes.h:20