YSTest: cassert.cpp 源文件

YSTest PreAlpha_b700_20160611 The YSLib Test Project

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

- 文件列表
- 文件成员

cassert.cpp
浏览该文件的文档.
1 /*
2 © 2013-2015 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
28 #include "ystdex/cassert.h"
29 #include <exception> // for std::terminate;
30 #include <cstdarg>
31
32 namespace ystdex
33 {
34
35 void
36 yassert(const char* expr_str, const char* file, int line, const char* msg)
37 ynothrow
38 {
39 const auto chk_null([](const char* s) ynothrow{
40 return s && *s != char()? s : "<unknown>";
41 });
42
43 std::fprintf(stderr, "Assertion failed @ \"%s\":%i:\n"
44 " %s .\nMessage: \n%s\n", chk_null(file), line, chk_null(expr_str),
45 chk_null(msg));
46 std::terminate();
47 }
48
49 #if YB_Use_YTrace
50 void
51 ytrace(std::FILE* stream, std::uint8_t lv, std::uint8_t t, const char* file,
52 int line, const char* msg, ...) ynothrow
53 {
54 if(lv < t)
55 {
56 std::fprintf(stream, "Trace[%#X] @ \"%s\":%i:\n", unsigned(lv), file,
57 line);
58
59 std::va_list args;
60 va_start(args, msg);
61 std::vfprintf(stream, msg, args);
62 va_end(args);
63 }
64 }
65 #endif
66
67 } // namespace ystdex;
68
YSLib::lv
RecordLevel lv
Definition: YException.cpp:58
ynothrow
#define ynothrow
YSLib 无异常抛出保证：若支持 noexcept 关键字， 指定特定的 noexcept 异常规范。
Definition: ydef.h:740
ystdex::ytrace
void ytrace(std::FILE *, std::uint8_t, std::uint8_t, const char *, int, const char *,...)
YCLib 调试跟踪函数。
cassert.h
ISO C 断言/调试跟踪扩展。
ystdex::yassert
void yassert(const char *, const char *, int, const char *)
YBase 默认断言函数。
Definition: cassert.cpp:36
ystdex
特性测试宏。
Definition: ydef.h:796
platform::terminate
YB_NORETURN YF_API void terminate() ynothrow
异常终止函数。
Definition: YCommon.cpp:42
YSLib::char
char
Definition: ValueNode.h:851
CHRLib::args
_tParams && args
Definition: CharacterProcessing.h:538
CHRLib::s
_tDst const _tSrc * s
Definition: CharacterProcessing.h:140