YSTest: test.h 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

- 首页
- 相关页面
- 模块
- 命名空间
- 类
- 文件

- 文件列表
- 文件成员

test.h
浏览该文件的文档.
1 /*
2 © 2014 FrankHB.
3
4 This file is part of the YSLib project, and may only be used,
5 modified, and distributed under the terms of the YSLib project
6 license, LICENSE.TXT. By continuing to use, modify, or distribute
7 this file you indicate that you have read the license and
8 understand and accept it fully.
9 */
10
33 #ifndef YB_INC_ytest_test_h_
34 #define YB_INC_ytest_test_h_ 1
35
36 #include "../ydef.h"
37 #include <string>
38 #include <functional>
39
44 namespace ytest
45 {
46
47 using ystdex::size_t;
48
53 template<typename _type, typename _func, typename... _tParams>
54 bool
55 expect(const _type& result, _func&& f, _tParams&&... args)
56 {
57 return yforward(f)(yforward(args)...) == result;
58 }
59
60
65 class YB_API group_guard
66 {
67 public:
68 std::string subject;
69 size_t pass_n = 0;
70 size_t fail_n = 0;
71 std::function<void(group_guard&)> on_end{};
72
74 group_guard(const std::string&);
76 group_guard(const std::string&, std::function<void(group_guard&)>,
77 std::function<void(group_guard&)>);
78 group_guard(group_guard&&) = default;
83 ~group_guard();
84
85 template<typename _fPass, typename _fFail>
86 std::function<void(bool)>
87 get(_fPass pass, _fFail fail)
88 {
89 return [=](bool b){
90 if(b)
91 {
92 ++pass_n;
93 pass();
94 }
95 else
96 {
97 ++fail_n;
98 fail();
99 }
100 };
101 }
102 };
103
104 } // namespace ytest;
105
106 #endif
107
ytest::group_guard
测试组 RAII 辅助对象。
Definition: test.h:65
platform::containers::string
basic_string< char > string
Definition: Container.h:101
platform::size_t
YF_API size_t
Definition: FileIO.h:1262
YB_API
#define YB_API
YBase 应用程序编程接口：用于向库文件约定链接。
Definition: ydef.h:566
ytest::expect
bool expect(const _type &result, _func &&f, _tParams &&...args)
判断可调用对象的应用求值结果是否符合预期值。
Definition: test.h:55
ytest
YFramework 基础测试库命名空间。
Definition: test.h:44
ytest::group_guard::subject
std::string subject
Definition: test.h:68
yforward
#define yforward(_expr)
根据参数类型使用 std::forward 传递对应参数。
Definition: ydef.h:969
YSLib::IO::f
const string &path const String &path _func f
Definition: YSLib/Service/FileSystem.h:430
CHRLib::args
_tParams && args
Definition: CharacterProcessing.h:538