nlib
ParamType.h
[詳解]
1 
2 /*---------------------------------------------------------------------------*
3 
4  Project: CrossRoad
5  Copyright (C)2012-2016 Nintendo. All rights reserved.
6 
7  These coded instructions, statements, and computer programs contain
8  proprietary information of Nintendo of America Inc. and/or Nintendo
9  Company Ltd., and are protected by Federal copyright law. They may
10  not be disclosed to third parties or copied or duplicated in any form,
11  in whole or in part, without the prior written consent of Nintendo.
12 
13  *---------------------------------------------------------------------------*/
14 
15 #pragma once
16 #ifndef INCLUDE_NN_NLIB_TESTING_PARAMTYPE_H_
17 #define INCLUDE_NN_NLIB_TESTING_PARAMTYPE_H_
18 
19 #include "nn/nlib/Config.h"
20 #include "nn/nlib/testing/NTest.h"
21 #include "nn/nlib/testing/ParamTypeTypes.h"
22 
23 NLIB_NAMESPACE_BEGIN
24 namespace testing {
25 
26 template <template <class Tmpl> class TEST_CASE, class LIST> // NOLINT
27 class TypedTestLoop {
28  public:
29  static bool AddTestInfo(const char* test_case, const char* test_name, int index) {
30  // NOTE: Executed before main function.
31  // This traverses LIST, and AddTestInfo for each type.
32  typedef typename LIST::Head T;
33  typedef typename LIST::Tail TL;
34  typedef TEST_CASE<T> TestCaseType;
35 
36  ::nlib_ns::testing::TestInfo::AddTestInfo<TestCaseType>(test_case, test_name, index,
37  TestCaseType::SetUpTestCase,
38  TestCaseType::TearDownTestCase);
39  return TypedTestLoop<TEST_CASE, TL>::AddTestInfo(test_case, test_name, index + 1);
40  }
41 };
42 
43 template <template <class Tmpl> class TEST_CASE>
44 class TypedTestLoop<TEST_CASE, Tp0> {
45  public:
46  static bool AddTestInfo(const char* test_case, const char* test_name, int index) {
47  NLIB_UNUSED(test_case);
48  NLIB_UNUSED(test_name);
49  NLIB_UNUSED(index);
50  return true;
51  }
52 };
53 
54 #define NLIB_TESTING_TYPELIST(test_case) ntest_type_params_##test_case##_
55 
56 } // namespace testing
57 NLIB_NAMESPACE_END
58 
59 #define TYPED_TEST_CASE(test_case, types) typedef types::type NLIB_TESTING_TYPELIST(test_case)
60 
61 #define TYPED_TEST(test_case, test_name) \
62 template<class T> \
63 class NLIB_TESTING_CLASS_NAME_(test_case, test_name) \
64  : public test_case<T> { \
65 public: \
66  typedef test_case<T> TestFixture; \
67  typedef T TypeParam; \
68  NLIB_TESTING_CLASS_NAME_(test_case, test_name)() {} \
69 private: \
70  virtual void TestBody(); \
71  NLIB_DISALLOW_COPY_AND_ASSIGN(NLIB_TESTING_CLASS_NAME_(test_case, test_name)); \
72 }; \
73 bool ntest_typed_test_##test_case##test_name##_ = ::nlib_ns::testing::TypedTestLoop< \
74  NLIB_TESTING_CLASS_NAME_(test_case, test_name), \
75  NLIB_TESTING_TYPELIST(test_case)>::AddTestInfo(#test_case, #test_name, 1); \
76 template<class T> \
77 void NLIB_TESTING_CLASS_NAME_(test_case, test_name)<T>::TestBody()
78 
79 #endif // INCLUDE_NN_NLIB_TESTING_PARAMTYPE_H_
開発環境別の設定が書かれるファイルです。
基本的な単体テスト用マクロが定義されています。