├── .gitattributes ├── .github └── funding.yml ├── .gitignore ├── .travis.yml ├── LICENSE ├── README.md ├── _gnu-make └── Makefile ├── _ios-xcode ├── .gitignore ├── Assert-Info.plist └── Assert.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ └── contents.xcworkspacedata ├── _mac-xcode ├── .gitignore └── Assert.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ └── contents.xcworkspacedata ├── _win-vs14 ├── .gitignore ├── Assert.sln ├── Common.props ├── Debug.props ├── Release.props ├── UnitTest.props ├── example.vcxproj ├── test-no-exceptions.vcxproj ├── test-no-stl.vcxproj ├── test.vcxproj ├── x64.props └── x86.props ├── example └── main.cpp ├── src ├── ppk_assert.cpp └── ppk_assert.h └── test ├── gtest ├── gtest-all.cc └── gtest.h └── ppk_assert_test.cpp /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | 3 | # sources 4 | *.h text diff=cpp 5 | *.c text diff=cpp 6 | *.cpp text diff=cpp 7 | *.rb text diff=ruby 8 | *.html text diff=html 9 | *.m text diff=objc 10 | 11 | # shell scripts 12 | *.sh eol=lf 13 | 14 | # GNU Makefile 15 | Makefile text eol=lf 16 | 17 | # Autotools 18 | *.am text eol=lf 19 | 20 | # Android 21 | *.mk text eol=lf 22 | 23 | # Xcode files 24 | *.pbxproj text eol=lf merge=union 25 | 26 | # Visual Studio files 27 | *.sln text eol=crlf merge=union 28 | *.vcxproj text eol=crlf merge=union 29 | *.vcxproj.filters text eol=crlf merge=union 30 | *.props text eol=crlf 31 | -------------------------------------------------------------------------------- /.github/funding.yml: -------------------------------------------------------------------------------- 1 | github: gpakosz 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | *~ 3 | *.swp 4 | 5 | /bin 6 | /_gnu-make/assert.txt 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | compiler: 3 | - clang 4 | - gcc 5 | env: 6 | - TARGET=build 7 | - TARGET=test 8 | script: make -C ./_gnu-make $TARGET 9 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- 2 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 3 | Version 2, December 2004 4 | 5 | Copyright (C) 2004 Sam Hocevar 6 | 7 | Everyone is permitted to copy and distribute verbatim or modified 8 | copies of this license document, and changing it is allowed as long 9 | as the name is changed. 10 | 11 | DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE 12 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 13 | 14 | 0. You just DO WHAT THE FUCK YOU WANT TO. 15 | 1. Bla bla bla 16 | 2. Montesqieu et camembert, vive la France, zut alors! 17 | 18 | -------------------------------------------------------------------------------- 19 | 20 | WTFPLv2 is very permissive, see http://www.wtfpl.net/faq/ 21 | 22 | However, if this WTFPLV2 is REALLY a blocker and is the reason you can't use 23 | this project, contact me and I'll dual license it. 24 | 25 | -------------------------------------------------------------------------------- 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Assert: a cross platform drop-in + self-contained C++ assertion library 2 | [![Build Status](https://travis-ci.org/gpakosz/PPK_ASSERT.png?branch=master)](https://travis-ci.org/gpakosz/PPK_ASSERT) 3 | 4 | ## TLDR 5 | 6 | #include 7 | #include 8 | 9 | int main() 10 | { 11 | float min = 0.0f; 12 | float max = 1.0f; 13 | float v = 2.0f; 14 | BOOST_ASSERT_MSG(v > min && v < max, static_cast(std::ostringstream().flush() << \ 15 | "invalid value: " << v << ", must be between " << min << " and " << max).str().c_str()); 16 | return 0; 17 | } 18 | 19 | **vs** 20 | 21 | #include 22 | 23 | int main() 24 | { 25 | float min = 0.0f; 26 | float max = 1.0f; 27 | float v = 2.0f; 28 | PPK_ASSERT(v > min && v < max, "invalid value: %f, must be between %f and %f", v, min, max); 29 | 30 | return 0; 31 | } 32 | 33 | Now which do you prefer? I know which I prefer. 34 | 35 | Just drop `ppk_assert.h` and `ppk_assert.cpp` into your build and get 36 | started. (see also [customizing compilation]) 37 | 38 | [customizing compilation]: #customizing-compilation 39 | 40 | ## Why? 41 | 42 | It all started with the need to provide a meaningful message when assertions 43 | fire. There is a well-known hack with standard `assert` to inject a message next 44 | to the expression being tested: 45 | 46 | assert(expression && "message"); 47 | 48 | But it's limited to string literals. I wanted improve on `assert()` by 49 | providing the following features: 50 | 51 | - being able to format a message that would also contain the values for 52 | different variables around the point of failure 53 | - having different levels of severity 54 | - being able to selectively ignore assertions while debugging 55 | - being able to break into the debugger at the exact point an assertion fires 56 | (that is in your own source code, instead of somewhere deep inside `assert` 57 | implementation) 58 | - no memory allocation 59 | - no unused variables warning when assertions are disabled 60 | 61 | -------------------------------------------------------------------------------- 62 | 63 | ## What? 64 | 65 | The library is designed to be lightweight would you decide to keep assertions 66 | enabled even in release builds (`#define PPK_ASSERT_ENABLED 1`). 67 | 68 | By default, each assertion eats up `sizeof(bool)` of stack, used to keep track 69 | whether the assertion should be ignored for the remaining lifetime of the 70 | program. You can disable this feature (see [customizing compilation]). 71 | 72 | ### Message Formatting 73 | 74 | The library provides `printf` like formatting: 75 | 76 | PPK_ASSERT(expression); 77 | PPK_ASSERT(expression, message, ...); 78 | 79 | E.g: 80 | 81 | PPK_ASSERT(validate(v, min, max), "invalid value: %f, must be between %f and %f", v, min, max); 82 | 83 | ### Levels Of Severity 84 | 85 | This library defines different levels of severity: 86 | 87 | - `PPK_ASSERT_WARNING` 88 | - `PPK_ASSERT_DEBUG` 89 | - `PPK_ASSERT_ERROR` 90 | - `PPK_ASSERT_FATAL` 91 | 92 | When you use `PPK_ASSERT`, the severity level is determined by the 93 | `PPK_ASSERT_DEFAULT_LEVEL` preprocessor token. 94 | 95 | You can also add your own additional severity levels by using: 96 | 97 | PPK_ASSERT_CUSTOM(level, expression); 98 | PPK_ASSERT_CUSTOM(level, expression, message, ...); 99 | 100 | ### Default Assertion Handler 101 | 102 | The default handler associates a predefined behavior to each of the different 103 | levels: 104 | 105 | - `WARNING <= level < DEBUG`: print the assertion message to `stderr` 106 | - `DEBUG <= level < ERROR`: print the assertion message to `stderr` and prompt 107 | the user for action (disabled by default on iOS and Android) 108 | - `ERROR <= level < FATAL`: throw an `AssertionException` 109 | - `FATAL < level`: abort the program 110 | 111 | If you know you're going to launch your program from within a login shell 112 | session on iOS or Android (e.g. through SSH), define the 113 | `PPK_ASSERT_DEFAULT_HANDLER_STDIN` preprocessor token. 114 | 115 | When prompting for user action, the default handler prints the following 116 | message on `stderr`: 117 | 118 | `Press (I)gnore / Ignore (F)orever / Ignore (A)ll / (D)ebug / A(b)ort:` 119 | 120 | And waits for input on `stdin`: 121 | 122 | - Ignore: ignore the current assertion 123 | - Ignore Forever: remember the file and line where the assertion fired and 124 | ignore it for the remaining execution of the program 125 | - Ignore All: ignore all remaining assertions (all files and lines) 126 | - Debug: break into the debugger if attached, otherwise `abort()` (on Windows, 127 | the system will prompt the user to attach a debugger) 128 | - Abort: call `abort()` immediately 129 | 130 | Under the Windows platform, the default handler also uses `OutputDebugString` 131 | and in the case of a GUI application allocates a console upon encountering the 132 | first failed assertion. 133 | 134 | Under the Android platform, the default handler also sends log messages to the 135 | in-kernel log buffer, which can later be accessed through the `logcat` utility. 136 | 137 | The default handler supports optional logging to a file (suggested by 138 | [@nothings]): 139 | 140 | - `#define PPK_ASSERT_LOG_FILE "/tmp/assert.txt"` 141 | - to truncate the log file upon each program invocation, `#define 142 | PPK_ASSERT_LOG_FILE_TRUNCATE` 143 | 144 | [@nothings]: https://twitter.com/nothings 145 | 146 | ### Providing Your Own Handler 147 | 148 | If you want to change the default behavior, e.g. by opening a dialog box or 149 | logging assertions to a database, you can provide a custom handler with the 150 | following signature: 151 | 152 | typedef AssertAction::AssertAction (*AssertHandler)(const char* file, 153 | int line, 154 | const char* function, 155 | const char* expression, 156 | int level, 157 | const char* message); 158 | 159 | Your handler will be called with the proper information filled and needs to 160 | return the action to be performed: 161 | 162 | PPK_ASSERT_ACTION_NONE, 163 | PPK_ASSERT_ACTION_ABORT, 164 | PPK_ASSERT_ACTION_BREAK, 165 | PPK_ASSERT_ACTION_IGNORE, 166 | PPK_ASSERT_ACTION_IGNORE_LINE, 167 | PPK_ASSERT_ACTION_IGNORE_ALL, 168 | PPK_ASSERT_ACTION_THROW 169 | 170 | To install your custom handler, call: 171 | 172 | ppk::assert::implementation::setAssertHandler(customHandler); 173 | 174 | ### Unused Return Values 175 | 176 | The library provides `PPK_ASSERT_USED` that fires an assertion when an unused 177 | return value reaches end of scope: 178 | 179 | PPK_ASSERT_USED(int) foo(); 180 | 181 | When calling `foo()`, 182 | 183 | { 184 | foo(); 185 | 186 | // ... 187 | 188 | bar(); 189 | 190 | // ... 191 | 192 | baz(); 193 | } <- assertion fires, caused by unused `foo()` return value reaching end of scope 194 | 195 | Just like `PPK_ASSERT`, `PPK_ASSERT_USED` uses 196 | `PPK_ASSERT_DEFAULT_LEVEL`. If you want more control on the severity, use one 197 | of: 198 | 199 | PPK_ASSERT_USED_WARNING(type) 200 | PPK_ASSERT_USED_DEBUG(type) 201 | PPK_ASSERT_USED_ERROR(type) 202 | PPK_ASSERT_USED_FATAL(type) 203 | PPK_ASSERT_USED_CUSTOM(level, type) 204 | 205 | Arguably, unused return values are better of detected by the compiler. For 206 | instance GCC and Clang allow you to mark function with attributes: 207 | 208 | __attribute__((warn_unused_result)) int foo(); 209 | 210 | Which will emit the following warning in case the return value is not used: 211 | 212 | warning: ignoring return value of function declared with warn_unused_result attribute [-Wunused-result] 213 | 214 | However there is no MSVC++ equivalent. Well there is `__checkReturn` but it 215 | supposedly only have effect when running static code analysis and I failed to 216 | make it work with Visual Studio 2013 Express. Wrapping `PPK_ASSERT_USED` 217 | around a return type is a cheap way to debug a program where you suspect a 218 | function return value is being ignored and shouldn't have been. 219 | 220 | ### Compile-time assertions 221 | 222 | PPK_STATIC_ASSERT(expression) 223 | PPK_STATIC_ASSERT(expression, message) 224 | 225 | In case of compile-time assertions, the message must be a string literal and 226 | can't be formated like with run-time assertions, e.g: 227 | 228 | PPK_STATIC_ASSERT(sizeof(foo) > sizeof(bar), "size mismatch"); 229 | 230 | When compiled with a C++11 capable compiler, `PPK_STATIC_ASSERT` defers to 231 | `static_assert`. Contrary to `static_assert`, it's possible to use 232 | `PPK_STATIC_ASSERT` without a message. 233 | 234 | ## Customizing compilation 235 | 236 | In order to use `PPK_ASSERT` in your own project, you just have to bring in 237 | the two `ppk_assert.h` and `ppk_assert.cpp` files. **It's that simple**. 238 | 239 | You can customize the library's behavior by defining the following macros: 240 | 241 | - `#define PPK_ASSERT_ENABLED 1` or `#define PPK_ASSERT_ENABLED 0`: enable 242 | or disable assertions, otherwise enabled state is based on `NDEBUG` 243 | preprocessor token being defined 244 | - `PPK_ASSERT_DEFAULT_LEVEL`: default level to use when using the 245 | `PPK_ASSERT` macro 246 | - `PPK_ASSERT_DISABLE_STL`: `AssertionException` won't inherit from 247 | `std::exception` 248 | - `PPK_ASSERT_DISABLE_EXCEPTIONS`: the library won't throw exceptions on 249 | `ERROR` level but instead rely on a user provided `throwException` function 250 | that will likely `abort()` the program 251 | - `PPK_ASSERT_MESSAGE_BUFFER_SIZE` 252 | - `PPK_ASSERT_DISABLE_IGNORE_LINE`: disables the injection of a `static bool` 253 | variable used to keep track whether the assertion should be ignored for the 254 | remaining lifetime of the program 255 | - `PPK_ASSERT_DEBUG_BREAK`: lets you redefine programmatic breakpoints 256 | 257 | If you want to use a different prefix, provide your own header that includes 258 | `ppk_assert.h` and define the following: 259 | 260 | // custom prefix 261 | #define ASSERT PPK_ASSERT 262 | #define ASSERT_WARNING PPK_ASSERT_WARNING 263 | #define ASSERT_DEBUG PPK_ASSERT_DEBUG 264 | #define ASSERT_ERROR PPK_ASSERT_ERROR 265 | #define ASSERT_FATAL PPK_ASSERT_FATAL 266 | #define ASSERT_CUSTOM PPK_ASSERT_CUSTOM 267 | #define ASSERT_USED PPK_ASSERT_USED 268 | #define ASSERT_USED_WARNING PPK_ASSERT_USED_WARNING 269 | #define ASSERT_USED_DEBUG PPK_ASSERT_USED_DEBUG 270 | #define ASSERT_USED_ERROR PPK_ASSERT_USED_ERROR 271 | #define ASSERT_USED_FATAL PPK_ASSERT_USED_FATAL 272 | #define ASSERT_USED_CUSTOM PPK_ASSERT_USED_CUSTOM 273 | 274 | 275 | ### Compiling for Windows 276 | 277 | There is a Visual Studio 2015 solution in the `_win-vs14/` folder. 278 | 279 | ### Compiling for Linux or Mac 280 | 281 | There is a GNU Make 3.81 `MakeFile` in the `_gnu-make/` folder: 282 | 283 | $ make -j -C _gnu-make/ 284 | 285 | ### Compiling for Mac 286 | 287 | See above if you want to compile from command line. Otherwise there is an Xcode 288 | project located in the `_mac-xcode/` folder. 289 | 290 | ### Compiling for iOS 291 | 292 | There is an Xcode project located in the `_ios-xcode/` folder. 293 | 294 | If you prefer compiling from command line and deploying to a jailbroken device 295 | through SSH, use: 296 | 297 | $ make -j -C _gnu-make/ binsubdir=ios CXX="$(xcrun --sdk iphoneos --find clang++) -isysroot $(xcrun --sdk iphoneos --show-sdk-path) -arch armv7 -arch armv7s -arch arm64" CPPFLAGS=-DPPK_ASSERT_DEFAULT_HANDLER_STDIN postbuild="codesign -s 'iPhone Developer'" 298 | 299 | ### Compiling for Android 300 | 301 | You will have to install the Android NDK, and point the `$NDK_ROOT` environment 302 | variable to the NDK path: e.g. `export NDK_ROOT=/opt/android-ndk` (without a 303 | trailing `/` character). 304 | 305 | Next, the easy way is to make a standalone Android toolchain with the following 306 | command: 307 | 308 | $ $NDK_ROOT/build/tools/make_standalone_toolchain.py --arch=arm --install-dir=/tmp/android-toolchain 309 | 310 | Now you can compile the self test and self benchmark programs by running: 311 | 312 | $ make -j -C _gnu-make/ binsubdir=android CXX=/tmp/android-toolchain/bin/clang++ LDFLAGS='-llog' CPPFLAGS=-DPPK_ASSERT_DEFAULT_HANDLER_STDIN 313 | 314 | -------------------------------------------------------------------------------- 315 | 316 | ## Credits Where It's Due: 317 | 318 | This assertion library has been lingering in my pet codebase for years. It has 319 | greatly been inspired by [Andrei Alexandrescu][@incomputable]'s CUJ articles: 320 | 321 | - [Assertions][assertions] 322 | - [Enhancing Assertions][enhancing-assertions] 323 | 324 | [assertions]: http://www.drdobbs.com/assertions/184403861 325 | [enhancing-assertions]: http://www.drdobbs.com/cpp/enhancing-assertions/184403745 326 | [@incomputable]: https://twitter.com/incomputable 327 | 328 | I learnt the `PPK_UNUSED` trick from [Branimir Karadžić][@bkaradzic]. 329 | 330 | Finally, [`__VA_NARG__` has been invented by Laurent Deniau][__VA_NARG__]. 331 | 332 | [@bkaradzic]: https://twitter.com/bkaradzic 333 | [__VA_NARG__]: https://groups.google.com/d/msg/comp.std.c/d-6Mj5Lko_s/5R6bMWTEbzQJ 334 | 335 | 336 | -------------------------------------------------------------------------------- 337 | 338 | If you find this library useful and decide to use it in your own projects please 339 | drop me a line [@gpakosz]. 340 | 341 | [@gpakosz]: https://twitter.com/gpakosz 342 | -------------------------------------------------------------------------------- /_gnu-make/Makefile: -------------------------------------------------------------------------------- 1 | .PHONY: build test clean 2 | 3 | # directories 4 | ifeq ($(realpath .),) 5 | $(error your version of Make doesn't support $$(realpath names...) - please use GNU Make 3.81 or later) 6 | endif 7 | 8 | ifeq ($(platform),) 9 | __uname_s := $(shell sh -c 'uname -s 2>/dev/null | tr [A-Z] [a-z] || echo unknown-platform') 10 | 11 | platform := $(__uname_s) 12 | ifeq ($(__uname_s),darwin) 13 | override platform := mac 14 | endif 15 | ifeq ($(__uname_s),sunos) 16 | override platform := solaris 17 | endif 18 | endif 19 | ifeq ($(architecture),) 20 | __uname_m := $(shell sh -c 'uname -m 2>/dev/null | tr [A-Z] [a-z] || echo unknown-architecture') 21 | 22 | architecture := $(__uname_m) 23 | endif 24 | 25 | prefix := $(realpath ..) 26 | srcdir := $(realpath ../src) 27 | exampledir := $(realpath ../example) 28 | testdir := $(realpath ../test) 29 | buildir := $(realpath .)/build 30 | binsubdir := $(platform)-$(architecture) 31 | bindir := $(prefix)/bin/$(binsubdir) 32 | 33 | CPPFLAGS := -DPPK_ASSERT_LOG_FILE=\"assert.txt\" -DPPK_ASSERT_LOG_FILE_TRUNCATE 34 | CXXFLAGS := -O2 -g -Wall -Wextra -pedantic -Wno-variadic-macros -Werror 35 | 36 | GTEST_CXXFLAGS := -std=c++03 -Wno-pedantic 37 | ifeq ($(platform),linux) 38 | GTEST_CXXFLAGS += -pthread 39 | endif 40 | 41 | .PHONY: build-test 42 | build: build-test 43 | build-test: $(bindir)/test $(bindir)/test-no-stl $(bindir)/test-no-exceptions 44 | 45 | $(bindir)/test: $(srcdir)/ppk_assert.cpp $(srcdir)/ppk_assert.h $(testdir)/ppk_assert_test.cpp $(testdir)/gtest/gtest-all.cc $(testdir)/gtest/gtest.h 46 | mkdir -p $(@D) 47 | $(CXX) -I $(srcdir) -I$(testdir) $(CPPFLAGS) $(CXXFLAGS) $(GTEST_CXXFLAGS) $(filter-out %.h,$^) $(LDFLAGS) -o $@ 48 | $(if $(postbuild),$(postbuild) $@) 49 | 50 | $(bindir)/test-no-stl: $(srcdir)/ppk_assert.cpp $(srcdir)/ppk_assert.h $(testdir)/ppk_assert_test.cpp $(testdir)/gtest/gtest-all.cc $(testdir)/gtest/gtest.h 51 | mkdir -p $(@D) 52 | $(CXX) -I $(srcdir) -I$(testdir) $(CPPFLAGS) -DPPK_ASSERT_DISABLE_STL $(CXXFLAGS) $(GTEST_CXXFLAGS) $(filter-out %.h,$^) $(LDFLAGS) -o $@ 53 | $(if $(postbuild),$(postbuild) $@) 54 | 55 | $(bindir)/test-no-exceptions: $(srcdir)/ppk_assert.cpp $(srcdir)/ppk_assert.h $(testdir)/ppk_assert_test.cpp $(testdir)/gtest/gtest-all.cc $(testdir)/gtest/gtest.h 56 | mkdir -p $(@D) 57 | $(CXX) -I $(srcdir) -I$(testdir) $(CPPFLAGS) -DPPK_ASSERT_DISABLE_EXCEPTIONS $(CXXFLAGS) $(GTEST_CXXFLAGS) $(filter-out %.h,$^) $(LDFLAGS) -o $@ 58 | $(if $(postbuild),$(postbuild) $@) 59 | 60 | .PHONY: build-example 61 | build: build-example 62 | build-example: $(bindir)/example 63 | 64 | $(bindir)/example: $(srcdir)/ppk_assert.cpp $(srcdir)/ppk_assert.h $(exampledir)/main.cpp 65 | mkdir -p $(@D) 66 | $(CXX) -I $(srcdir) $(CPPFLAGS) $(CXXFLAGS) $(filter-out %.h,$^) $(LDFLAGS) -o $@ 67 | $(if $(postbuild),$(postbuild) $@) 68 | 69 | .PHONY: test 70 | test : build-test 71 | $(bindir)/test 72 | $(bindir)/test-no-stl 73 | $(bindir)/test-no-exceptions 74 | 75 | clean: 76 | rm -rf $(buildir) 77 | rm -rf $(bindir) 78 | -------------------------------------------------------------------------------- /_ios-xcode/.gitignore: -------------------------------------------------------------------------------- 1 | xcuserdata/ 2 | xcshareddata/ 3 | -------------------------------------------------------------------------------- /_ios-xcode/Assert-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | net.pempek.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /_ios-xcode/Assert.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1A7A0B55182FABD30099EA41 /* ppk_assert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A7335C7182EC34E00691A33 /* ppk_assert.cpp */; }; 11 | 1A7A0B56182FABD70099EA41 /* ppk_assert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A7335C7182EC34E00691A33 /* ppk_assert.cpp */; }; 12 | 1A7A0B57182FABDA0099EA41 /* gtest-all.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A7335C9182EC35700691A33 /* gtest-all.cc */; }; 13 | 1A7A0B58182FABDD0099EA41 /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A7335CB182EC36200691A33 /* main.cpp */; }; 14 | 1A7A0B5B182FAC380099EA41 /* ppk_assert_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A7A0B59182FAC350099EA41 /* ppk_assert_test.cpp */; }; 15 | 1A7A0B7418316DD60099EA41 /* ppk_assert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A7335C7182EC34E00691A33 /* ppk_assert.cpp */; }; 16 | 1A7A0B7518316DD60099EA41 /* gtest-all.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A7335C9182EC35700691A33 /* gtest-all.cc */; }; 17 | 1A7A0B7618316DD60099EA41 /* ppk_assert_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A7A0B59182FAC350099EA41 /* ppk_assert_test.cpp */; }; 18 | 1A7A0B8018316E220099EA41 /* ppk_assert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A7335C7182EC34E00691A33 /* ppk_assert.cpp */; }; 19 | 1A7A0B8118316E220099EA41 /* gtest-all.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A7335C9182EC35700691A33 /* gtest-all.cc */; }; 20 | 1A7A0B8218316E220099EA41 /* ppk_assert_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A7A0B59182FAC350099EA41 /* ppk_assert_test.cpp */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXFileReference section */ 24 | 1A7335C7182EC34E00691A33 /* ppk_assert.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ppk_assert.cpp; sourceTree = ""; }; 25 | 1A7335C8182EC34E00691A33 /* ppk_assert.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ppk_assert.h; sourceTree = ""; }; 26 | 1A7335C9182EC35700691A33 /* gtest-all.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = "gtest-all.cc"; sourceTree = ""; }; 27 | 1A7335CA182EC35700691A33 /* gtest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = gtest.h; sourceTree = ""; }; 28 | 1A7335CB182EC36200691A33 /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 29 | 1A7A0B53182FAB5C0099EA41 /* Assert-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "Assert-Info.plist"; sourceTree = ""; }; 30 | 1A7A0B59182FAC350099EA41 /* ppk_assert_test.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ppk_assert_test.cpp; sourceTree = ""; }; 31 | 1A7A0B7C18316DD60099EA41 /* test copy.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "test copy.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 1A7A0B8818316E220099EA41 /* test-no-stl copy.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "test-no-stl copy.app"; sourceTree = BUILT_PRODUCTS_DIR; }; 33 | 1A98F9C917A4018400BF09FF /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 34 | 1A98F9F617A408F000BF09FF /* test.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = test.app; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | /* End PBXFileReference section */ 36 | 37 | /* Begin PBXFrameworksBuildPhase section */ 38 | 1A7A0B7718316DD60099EA41 /* Frameworks */ = { 39 | isa = PBXFrameworksBuildPhase; 40 | buildActionMask = 2147483647; 41 | files = ( 42 | ); 43 | runOnlyForDeploymentPostprocessing = 0; 44 | }; 45 | 1A7A0B8318316E220099EA41 /* Frameworks */ = { 46 | isa = PBXFrameworksBuildPhase; 47 | buildActionMask = 2147483647; 48 | files = ( 49 | ); 50 | runOnlyForDeploymentPostprocessing = 0; 51 | }; 52 | 1A98F9C617A4018400BF09FF /* Frameworks */ = { 53 | isa = PBXFrameworksBuildPhase; 54 | buildActionMask = 2147483647; 55 | files = ( 56 | ); 57 | runOnlyForDeploymentPostprocessing = 0; 58 | }; 59 | 1A98F9F117A408F000BF09FF /* Frameworks */ = { 60 | isa = PBXFrameworksBuildPhase; 61 | buildActionMask = 2147483647; 62 | files = ( 63 | ); 64 | runOnlyForDeploymentPostprocessing = 0; 65 | }; 66 | /* End PBXFrameworksBuildPhase section */ 67 | 68 | /* Begin PBXGroup section */ 69 | 1A7335C3182EC2E000691A33 /* src */ = { 70 | isa = PBXGroup; 71 | children = ( 72 | 1A7335C7182EC34E00691A33 /* ppk_assert.cpp */, 73 | 1A7335C8182EC34E00691A33 /* ppk_assert.h */, 74 | ); 75 | name = src; 76 | path = ../src; 77 | sourceTree = ""; 78 | }; 79 | 1A7335C4182EC30100691A33 /* example */ = { 80 | isa = PBXGroup; 81 | children = ( 82 | 1A7335CB182EC36200691A33 /* main.cpp */, 83 | ); 84 | name = example; 85 | path = ../example; 86 | sourceTree = ""; 87 | }; 88 | 1A7335C5182EC30600691A33 /* test */ = { 89 | isa = PBXGroup; 90 | children = ( 91 | 1A7A0B59182FAC350099EA41 /* ppk_assert_test.cpp */, 92 | 1A7335C6182EC31900691A33 /* gtest */, 93 | ); 94 | name = test; 95 | path = ../test; 96 | sourceTree = ""; 97 | }; 98 | 1A7335C6182EC31900691A33 /* gtest */ = { 99 | isa = PBXGroup; 100 | children = ( 101 | 1A7335C9182EC35700691A33 /* gtest-all.cc */, 102 | 1A7335CA182EC35700691A33 /* gtest.h */, 103 | ); 104 | path = gtest; 105 | sourceTree = ""; 106 | }; 107 | 1A98F9C017A4018400BF09FF = { 108 | isa = PBXGroup; 109 | children = ( 110 | 1A7A0B53182FAB5C0099EA41 /* Assert-Info.plist */, 111 | 1A7335C3182EC2E000691A33 /* src */, 112 | 1A7335C5182EC30600691A33 /* test */, 113 | 1A7335C4182EC30100691A33 /* example */, 114 | 1A98F9CA17A4018400BF09FF /* Products */, 115 | ); 116 | sourceTree = ""; 117 | }; 118 | 1A98F9CA17A4018400BF09FF /* Products */ = { 119 | isa = PBXGroup; 120 | children = ( 121 | 1A98F9C917A4018400BF09FF /* example.app */, 122 | 1A98F9F617A408F000BF09FF /* test.app */, 123 | 1A7A0B7C18316DD60099EA41 /* test copy.app */, 124 | 1A7A0B8818316E220099EA41 /* test-no-stl copy.app */, 125 | ); 126 | name = Products; 127 | sourceTree = ""; 128 | }; 129 | /* End PBXGroup section */ 130 | 131 | /* Begin PBXNativeTarget section */ 132 | 1A7A0B7218316DD60099EA41 /* test-no-stl */ = { 133 | isa = PBXNativeTarget; 134 | buildConfigurationList = 1A7A0B7918316DD60099EA41 /* Build configuration list for PBXNativeTarget "test-no-stl" */; 135 | buildPhases = ( 136 | 1A7A0B7318316DD60099EA41 /* Sources */, 137 | 1A7A0B7718316DD60099EA41 /* Frameworks */, 138 | 1A7A0B7818316DD60099EA41 /* Resources */, 139 | ); 140 | buildRules = ( 141 | ); 142 | dependencies = ( 143 | ); 144 | name = "test-no-stl"; 145 | productName = Assert; 146 | productReference = 1A7A0B7C18316DD60099EA41 /* test copy.app */; 147 | productType = "com.apple.product-type.application"; 148 | }; 149 | 1A7A0B7E18316E220099EA41 /* test-no-exceptions */ = { 150 | isa = PBXNativeTarget; 151 | buildConfigurationList = 1A7A0B8518316E220099EA41 /* Build configuration list for PBXNativeTarget "test-no-exceptions" */; 152 | buildPhases = ( 153 | 1A7A0B7F18316E220099EA41 /* Sources */, 154 | 1A7A0B8318316E220099EA41 /* Frameworks */, 155 | 1A7A0B8418316E220099EA41 /* Resources */, 156 | ); 157 | buildRules = ( 158 | ); 159 | dependencies = ( 160 | ); 161 | name = "test-no-exceptions"; 162 | productName = Assert; 163 | productReference = 1A7A0B8818316E220099EA41 /* test-no-stl copy.app */; 164 | productType = "com.apple.product-type.application"; 165 | }; 166 | 1A98F9C817A4018400BF09FF /* example */ = { 167 | isa = PBXNativeTarget; 168 | buildConfigurationList = 1A98F9E617A4018400BF09FF /* Build configuration list for PBXNativeTarget "example" */; 169 | buildPhases = ( 170 | 1A98F9C517A4018400BF09FF /* Sources */, 171 | 1A98F9C617A4018400BF09FF /* Frameworks */, 172 | 1A98F9C717A4018400BF09FF /* Resources */, 173 | ); 174 | buildRules = ( 175 | ); 176 | dependencies = ( 177 | ); 178 | name = example; 179 | productName = Assert; 180 | productReference = 1A98F9C917A4018400BF09FF /* example.app */; 181 | productType = "com.apple.product-type.application"; 182 | }; 183 | 1A98F9EE17A408F000BF09FF /* test */ = { 184 | isa = PBXNativeTarget; 185 | buildConfigurationList = 1A98F9F317A408F000BF09FF /* Build configuration list for PBXNativeTarget "test" */; 186 | buildPhases = ( 187 | 1A98F9EF17A408F000BF09FF /* Sources */, 188 | 1A98F9F117A408F000BF09FF /* Frameworks */, 189 | 1A98F9F217A408F000BF09FF /* Resources */, 190 | ); 191 | buildRules = ( 192 | ); 193 | dependencies = ( 194 | ); 195 | name = test; 196 | productName = Assert; 197 | productReference = 1A98F9F617A408F000BF09FF /* test.app */; 198 | productType = "com.apple.product-type.application"; 199 | }; 200 | /* End PBXNativeTarget section */ 201 | 202 | /* Begin PBXProject section */ 203 | 1A98F9C117A4018400BF09FF /* Project object */ = { 204 | isa = PBXProject; 205 | attributes = { 206 | LastUpgradeCheck = 0460; 207 | ORGANIZATIONNAME = "Gregory Pakosz"; 208 | }; 209 | buildConfigurationList = 1A98F9C417A4018400BF09FF /* Build configuration list for PBXProject "Assert" */; 210 | compatibilityVersion = "Xcode 3.2"; 211 | developmentRegion = English; 212 | hasScannedForEncodings = 0; 213 | knownRegions = ( 214 | en, 215 | ); 216 | mainGroup = 1A98F9C017A4018400BF09FF; 217 | productRefGroup = 1A98F9CA17A4018400BF09FF /* Products */; 218 | projectDirPath = ""; 219 | projectRoot = ""; 220 | targets = ( 221 | 1A98F9C817A4018400BF09FF /* example */, 222 | 1A98F9EE17A408F000BF09FF /* test */, 223 | 1A7A0B7218316DD60099EA41 /* test-no-stl */, 224 | 1A7A0B7E18316E220099EA41 /* test-no-exceptions */, 225 | ); 226 | }; 227 | /* End PBXProject section */ 228 | 229 | /* Begin PBXResourcesBuildPhase section */ 230 | 1A7A0B7818316DD60099EA41 /* Resources */ = { 231 | isa = PBXResourcesBuildPhase; 232 | buildActionMask = 2147483647; 233 | files = ( 234 | ); 235 | runOnlyForDeploymentPostprocessing = 0; 236 | }; 237 | 1A7A0B8418316E220099EA41 /* Resources */ = { 238 | isa = PBXResourcesBuildPhase; 239 | buildActionMask = 2147483647; 240 | files = ( 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | }; 244 | 1A98F9C717A4018400BF09FF /* Resources */ = { 245 | isa = PBXResourcesBuildPhase; 246 | buildActionMask = 2147483647; 247 | files = ( 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | }; 251 | 1A98F9F217A408F000BF09FF /* Resources */ = { 252 | isa = PBXResourcesBuildPhase; 253 | buildActionMask = 2147483647; 254 | files = ( 255 | ); 256 | runOnlyForDeploymentPostprocessing = 0; 257 | }; 258 | /* End PBXResourcesBuildPhase section */ 259 | 260 | /* Begin PBXSourcesBuildPhase section */ 261 | 1A7A0B7318316DD60099EA41 /* Sources */ = { 262 | isa = PBXSourcesBuildPhase; 263 | buildActionMask = 2147483647; 264 | files = ( 265 | 1A7A0B7418316DD60099EA41 /* ppk_assert.cpp in Sources */, 266 | 1A7A0B7518316DD60099EA41 /* gtest-all.cc in Sources */, 267 | 1A7A0B7618316DD60099EA41 /* ppk_assert_test.cpp in Sources */, 268 | ); 269 | runOnlyForDeploymentPostprocessing = 0; 270 | }; 271 | 1A7A0B7F18316E220099EA41 /* Sources */ = { 272 | isa = PBXSourcesBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | 1A7A0B8018316E220099EA41 /* ppk_assert.cpp in Sources */, 276 | 1A7A0B8118316E220099EA41 /* gtest-all.cc in Sources */, 277 | 1A7A0B8218316E220099EA41 /* ppk_assert_test.cpp in Sources */, 278 | ); 279 | runOnlyForDeploymentPostprocessing = 0; 280 | }; 281 | 1A98F9C517A4018400BF09FF /* Sources */ = { 282 | isa = PBXSourcesBuildPhase; 283 | buildActionMask = 2147483647; 284 | files = ( 285 | 1A7A0B58182FABDD0099EA41 /* main.cpp in Sources */, 286 | 1A7A0B55182FABD30099EA41 /* ppk_assert.cpp in Sources */, 287 | ); 288 | runOnlyForDeploymentPostprocessing = 0; 289 | }; 290 | 1A98F9EF17A408F000BF09FF /* Sources */ = { 291 | isa = PBXSourcesBuildPhase; 292 | buildActionMask = 2147483647; 293 | files = ( 294 | 1A7A0B56182FABD70099EA41 /* ppk_assert.cpp in Sources */, 295 | 1A7A0B57182FABDA0099EA41 /* gtest-all.cc in Sources */, 296 | 1A7A0B5B182FAC380099EA41 /* ppk_assert_test.cpp in Sources */, 297 | ); 298 | runOnlyForDeploymentPostprocessing = 0; 299 | }; 300 | /* End PBXSourcesBuildPhase section */ 301 | 302 | /* Begin XCBuildConfiguration section */ 303 | 1A7A0B7A18316DD60099EA41 /* Debug */ = { 304 | isa = XCBuildConfiguration; 305 | buildSettings = { 306 | GCC_PREPROCESSOR_DEFINITIONS = ( 307 | PPK_ASSERT_DISABLE_STL, 308 | "$(inherited)", 309 | ); 310 | HEADER_SEARCH_PATHS = ( 311 | ../src, 312 | ../test, 313 | "$(inherited)", 314 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 315 | ); 316 | PRODUCT_NAME = "test copy"; 317 | WRAPPER_EXTENSION = app; 318 | }; 319 | name = Debug; 320 | }; 321 | 1A7A0B7B18316DD60099EA41 /* Release */ = { 322 | isa = XCBuildConfiguration; 323 | buildSettings = { 324 | GCC_PREPROCESSOR_DEFINITIONS = ( 325 | PPK_ASSERT_DISABLE_STL, 326 | "$(inherited)", 327 | ); 328 | HEADER_SEARCH_PATHS = ( 329 | ../src, 330 | ../test, 331 | "$(inherited)", 332 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 333 | ); 334 | PRODUCT_NAME = "test copy"; 335 | WRAPPER_EXTENSION = app; 336 | }; 337 | name = Release; 338 | }; 339 | 1A7A0B8618316E220099EA41 /* Debug */ = { 340 | isa = XCBuildConfiguration; 341 | buildSettings = { 342 | GCC_PREPROCESSOR_DEFINITIONS = ( 343 | PPK_ASSERT_DISABLE_STL, 344 | "$(inherited)", 345 | ); 346 | HEADER_SEARCH_PATHS = ( 347 | ../src, 348 | ../test, 349 | "$(inherited)", 350 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 351 | ); 352 | PRODUCT_NAME = "test-no-stl copy"; 353 | WRAPPER_EXTENSION = app; 354 | }; 355 | name = Debug; 356 | }; 357 | 1A7A0B8718316E220099EA41 /* Release */ = { 358 | isa = XCBuildConfiguration; 359 | buildSettings = { 360 | GCC_PREPROCESSOR_DEFINITIONS = ( 361 | PPK_ASSERT_DISABLE_STL, 362 | "$(inherited)", 363 | ); 364 | HEADER_SEARCH_PATHS = ( 365 | ../src, 366 | ../test, 367 | "$(inherited)", 368 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 369 | ); 370 | PRODUCT_NAME = "test-no-stl copy"; 371 | WRAPPER_EXTENSION = app; 372 | }; 373 | name = Release; 374 | }; 375 | 1A98F9E417A4018400BF09FF /* Debug */ = { 376 | isa = XCBuildConfiguration; 377 | buildSettings = { 378 | ALWAYS_SEARCH_USER_PATHS = NO; 379 | CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; 380 | CLANG_CXX_LIBRARY = "libc++"; 381 | CLANG_WARN_CONSTANT_CONVERSION = YES; 382 | CLANG_WARN_EMPTY_BODY = YES; 383 | CLANG_WARN_ENUM_CONVERSION = YES; 384 | CLANG_WARN_INT_CONVERSION = YES; 385 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 386 | CODE_SIGN_IDENTITY = "iPhone Developer"; 387 | COPY_PHASE_STRIP = NO; 388 | GCC_C_LANGUAGE_STANDARD = gnu99; 389 | GCC_DYNAMIC_NO_PIC = NO; 390 | GCC_OPTIMIZATION_LEVEL = 0; 391 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 392 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 393 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 394 | GCC_WARN_UNUSED_VARIABLE = YES; 395 | INFOPLIST_FILE = "Assert-Info.plist"; 396 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 397 | ONLY_ACTIVE_ARCH = YES; 398 | PRODUCT_NAME = "$(TARGET_NAME)"; 399 | SDKROOT = iphoneos; 400 | TARGETED_DEVICE_FAMILY = "1,2"; 401 | }; 402 | name = Debug; 403 | }; 404 | 1A98F9E517A4018400BF09FF /* Release */ = { 405 | isa = XCBuildConfiguration; 406 | buildSettings = { 407 | ALWAYS_SEARCH_USER_PATHS = NO; 408 | CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; 409 | CLANG_CXX_LIBRARY = "libc++"; 410 | CLANG_WARN_CONSTANT_CONVERSION = YES; 411 | CLANG_WARN_EMPTY_BODY = YES; 412 | CLANG_WARN_ENUM_CONVERSION = YES; 413 | CLANG_WARN_INT_CONVERSION = YES; 414 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 415 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 416 | COPY_PHASE_STRIP = YES; 417 | GCC_C_LANGUAGE_STANDARD = gnu99; 418 | GCC_OPTIMIZATION_LEVEL = 2; 419 | GCC_PREPROCESSOR_DEFINITIONS = NDEBUG; 420 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 421 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 422 | GCC_WARN_UNUSED_VARIABLE = YES; 423 | INFOPLIST_FILE = "Assert-Info.plist"; 424 | IPHONEOS_DEPLOYMENT_TARGET = 5.0; 425 | OTHER_CFLAGS = "-DNS_BLOCK_ASSERTIONS=1"; 426 | PRODUCT_NAME = "$(TARGET_NAME)"; 427 | SDKROOT = iphoneos; 428 | TARGETED_DEVICE_FAMILY = "1,2"; 429 | VALIDATE_PRODUCT = YES; 430 | }; 431 | name = Release; 432 | }; 433 | 1A98F9E717A4018400BF09FF /* Debug */ = { 434 | isa = XCBuildConfiguration; 435 | buildSettings = { 436 | HEADER_SEARCH_PATHS = ( 437 | ../src, 438 | "$(inherited)", 439 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 440 | ); 441 | WRAPPER_EXTENSION = app; 442 | }; 443 | name = Debug; 444 | }; 445 | 1A98F9E817A4018400BF09FF /* Release */ = { 446 | isa = XCBuildConfiguration; 447 | buildSettings = { 448 | HEADER_SEARCH_PATHS = ( 449 | ../src, 450 | "$(inherited)", 451 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 452 | ); 453 | WRAPPER_EXTENSION = app; 454 | }; 455 | name = Release; 456 | }; 457 | 1A98F9F417A408F000BF09FF /* Debug */ = { 458 | isa = XCBuildConfiguration; 459 | buildSettings = { 460 | HEADER_SEARCH_PATHS = ( 461 | ../src, 462 | ../test, 463 | "$(inherited)", 464 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 465 | ); 466 | WRAPPER_EXTENSION = app; 467 | }; 468 | name = Debug; 469 | }; 470 | 1A98F9F517A408F000BF09FF /* Release */ = { 471 | isa = XCBuildConfiguration; 472 | buildSettings = { 473 | HEADER_SEARCH_PATHS = ( 474 | ../src, 475 | ../test, 476 | "$(inherited)", 477 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 478 | ); 479 | WRAPPER_EXTENSION = app; 480 | }; 481 | name = Release; 482 | }; 483 | /* End XCBuildConfiguration section */ 484 | 485 | /* Begin XCConfigurationList section */ 486 | 1A7A0B7918316DD60099EA41 /* Build configuration list for PBXNativeTarget "test-no-stl" */ = { 487 | isa = XCConfigurationList; 488 | buildConfigurations = ( 489 | 1A7A0B7A18316DD60099EA41 /* Debug */, 490 | 1A7A0B7B18316DD60099EA41 /* Release */, 491 | ); 492 | defaultConfigurationIsVisible = 0; 493 | defaultConfigurationName = Release; 494 | }; 495 | 1A7A0B8518316E220099EA41 /* Build configuration list for PBXNativeTarget "test-no-exceptions" */ = { 496 | isa = XCConfigurationList; 497 | buildConfigurations = ( 498 | 1A7A0B8618316E220099EA41 /* Debug */, 499 | 1A7A0B8718316E220099EA41 /* Release */, 500 | ); 501 | defaultConfigurationIsVisible = 0; 502 | defaultConfigurationName = Release; 503 | }; 504 | 1A98F9C417A4018400BF09FF /* Build configuration list for PBXProject "Assert" */ = { 505 | isa = XCConfigurationList; 506 | buildConfigurations = ( 507 | 1A98F9E417A4018400BF09FF /* Debug */, 508 | 1A98F9E517A4018400BF09FF /* Release */, 509 | ); 510 | defaultConfigurationIsVisible = 0; 511 | defaultConfigurationName = Release; 512 | }; 513 | 1A98F9E617A4018400BF09FF /* Build configuration list for PBXNativeTarget "example" */ = { 514 | isa = XCConfigurationList; 515 | buildConfigurations = ( 516 | 1A98F9E717A4018400BF09FF /* Debug */, 517 | 1A98F9E817A4018400BF09FF /* Release */, 518 | ); 519 | defaultConfigurationIsVisible = 0; 520 | defaultConfigurationName = Release; 521 | }; 522 | 1A98F9F317A408F000BF09FF /* Build configuration list for PBXNativeTarget "test" */ = { 523 | isa = XCConfigurationList; 524 | buildConfigurations = ( 525 | 1A98F9F417A408F000BF09FF /* Debug */, 526 | 1A98F9F517A408F000BF09FF /* Release */, 527 | ); 528 | defaultConfigurationIsVisible = 0; 529 | defaultConfigurationName = Release; 530 | }; 531 | /* End XCConfigurationList section */ 532 | }; 533 | rootObject = 1A98F9C117A4018400BF09FF /* Project object */; 534 | } 535 | -------------------------------------------------------------------------------- /_ios-xcode/Assert.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /_mac-xcode/.gitignore: -------------------------------------------------------------------------------- 1 | xcuserdata/ 2 | xcshareddata/ 3 | -------------------------------------------------------------------------------- /_mac-xcode/Assert.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 1A42F182182EBAB500F3880C /* ppk_assert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A42F17C182EBA3600F3880C /* ppk_assert.cpp */; }; 11 | 1A42F183182EBAB600F3880C /* ppk_assert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A42F17C182EBA3600F3880C /* ppk_assert.cpp */; }; 12 | 1A42F184182EBABC00F3880C /* main.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A42F17E182EBA4300F3880C /* main.cpp */; }; 13 | 1A42F185182EBABF00F3880C /* ppk_assert_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A42F181182EBA7900F3880C /* ppk_assert_test.cpp */; }; 14 | 1A42F186182EBAC300F3880C /* gtest-all.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A42F17F182EBA5000F3880C /* gtest-all.cc */; }; 15 | 1A7A0B5E18316C790099EA41 /* ppk_assert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A42F17C182EBA3600F3880C /* ppk_assert.cpp */; }; 16 | 1A7A0B5F18316C790099EA41 /* ppk_assert_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A42F181182EBA7900F3880C /* ppk_assert_test.cpp */; }; 17 | 1A7A0B6018316C790099EA41 /* gtest-all.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A42F17F182EBA5000F3880C /* gtest-all.cc */; }; 18 | 1A7A0B6918316D7E0099EA41 /* ppk_assert.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A42F17C182EBA3600F3880C /* ppk_assert.cpp */; }; 19 | 1A7A0B6A18316D7E0099EA41 /* ppk_assert_test.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1A42F181182EBA7900F3880C /* ppk_assert_test.cpp */; }; 20 | 1A7A0B6B18316D7E0099EA41 /* gtest-all.cc in Sources */ = {isa = PBXBuildFile; fileRef = 1A42F17F182EBA5000F3880C /* gtest-all.cc */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXCopyFilesBuildPhase section */ 24 | 1A7A0B6218316C790099EA41 /* CopyFiles */ = { 25 | isa = PBXCopyFilesBuildPhase; 26 | buildActionMask = 2147483647; 27 | dstPath = /usr/share/man/man1/; 28 | dstSubfolderSpec = 0; 29 | files = ( 30 | ); 31 | runOnlyForDeploymentPostprocessing = 1; 32 | }; 33 | 1A7A0B6D18316D7E0099EA41 /* CopyFiles */ = { 34 | isa = PBXCopyFilesBuildPhase; 35 | buildActionMask = 2147483647; 36 | dstPath = /usr/share/man/man1/; 37 | dstSubfolderSpec = 0; 38 | files = ( 39 | ); 40 | runOnlyForDeploymentPostprocessing = 1; 41 | }; 42 | 1A98F9FF17A4249200BF09FF /* CopyFiles */ = { 43 | isa = PBXCopyFilesBuildPhase; 44 | buildActionMask = 2147483647; 45 | dstPath = /usr/share/man/man1/; 46 | dstSubfolderSpec = 0; 47 | files = ( 48 | ); 49 | runOnlyForDeploymentPostprocessing = 1; 50 | }; 51 | 1A98FA1517A4262700BF09FF /* CopyFiles */ = { 52 | isa = PBXCopyFilesBuildPhase; 53 | buildActionMask = 2147483647; 54 | dstPath = /usr/share/man/man1/; 55 | dstSubfolderSpec = 0; 56 | files = ( 57 | ); 58 | runOnlyForDeploymentPostprocessing = 1; 59 | }; 60 | /* End PBXCopyFilesBuildPhase section */ 61 | 62 | /* Begin PBXFileReference section */ 63 | 1A42F17C182EBA3600F3880C /* ppk_assert.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ppk_assert.cpp; sourceTree = ""; }; 64 | 1A42F17D182EBA3600F3880C /* ppk_assert.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ppk_assert.h; sourceTree = ""; }; 65 | 1A42F17E182EBA4300F3880C /* main.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = ""; }; 66 | 1A42F17F182EBA5000F3880C /* gtest-all.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = "gtest-all.cc"; path = "gtest/gtest-all.cc"; sourceTree = ""; }; 67 | 1A42F180182EBA5000F3880C /* gtest.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = gtest.h; path = gtest/gtest.h; sourceTree = ""; }; 68 | 1A42F181182EBA7900F3880C /* ppk_assert_test.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ppk_assert_test.cpp; sourceTree = ""; }; 69 | 1A7A0B6618316C790099EA41 /* test copy */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "test copy"; sourceTree = BUILT_PRODUCTS_DIR; }; 70 | 1A7A0B7118316D7E0099EA41 /* test-no-stl copy */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = "test-no-stl copy"; sourceTree = BUILT_PRODUCTS_DIR; }; 71 | 1A98FA0117A4249200BF09FF /* example */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = example; sourceTree = BUILT_PRODUCTS_DIR; }; 72 | 1A98FA1917A4262700BF09FF /* test */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = test; sourceTree = BUILT_PRODUCTS_DIR; }; 73 | /* End PBXFileReference section */ 74 | 75 | /* Begin PBXFrameworksBuildPhase section */ 76 | 1A7A0B6118316C790099EA41 /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | ); 81 | runOnlyForDeploymentPostprocessing = 0; 82 | }; 83 | 1A7A0B6C18316D7E0099EA41 /* Frameworks */ = { 84 | isa = PBXFrameworksBuildPhase; 85 | buildActionMask = 2147483647; 86 | files = ( 87 | ); 88 | runOnlyForDeploymentPostprocessing = 0; 89 | }; 90 | 1A98F9FE17A4249200BF09FF /* Frameworks */ = { 91 | isa = PBXFrameworksBuildPhase; 92 | buildActionMask = 2147483647; 93 | files = ( 94 | ); 95 | runOnlyForDeploymentPostprocessing = 0; 96 | }; 97 | 1A98FA1417A4262700BF09FF /* Frameworks */ = { 98 | isa = PBXFrameworksBuildPhase; 99 | buildActionMask = 2147483647; 100 | files = ( 101 | ); 102 | runOnlyForDeploymentPostprocessing = 0; 103 | }; 104 | /* End PBXFrameworksBuildPhase section */ 105 | 106 | /* Begin PBXGroup section */ 107 | 1A42F178182EB9EF00F3880C /* src */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | 1A42F17C182EBA3600F3880C /* ppk_assert.cpp */, 111 | 1A42F17D182EBA3600F3880C /* ppk_assert.h */, 112 | ); 113 | name = src; 114 | path = ../src; 115 | sourceTree = ""; 116 | }; 117 | 1A42F179182EB9F500F3880C /* test */ = { 118 | isa = PBXGroup; 119 | children = ( 120 | 1A42F17B182EBA2B00F3880C /* gtest */, 121 | 1A42F181182EBA7900F3880C /* ppk_assert_test.cpp */, 122 | ); 123 | name = test; 124 | path = ../test; 125 | sourceTree = ""; 126 | }; 127 | 1A42F17A182EB9FE00F3880C /* example */ = { 128 | isa = PBXGroup; 129 | children = ( 130 | 1A42F17E182EBA4300F3880C /* main.cpp */, 131 | ); 132 | name = example; 133 | path = ../example; 134 | sourceTree = ""; 135 | }; 136 | 1A42F17B182EBA2B00F3880C /* gtest */ = { 137 | isa = PBXGroup; 138 | children = ( 139 | 1A42F17F182EBA5000F3880C /* gtest-all.cc */, 140 | 1A42F180182EBA5000F3880C /* gtest.h */, 141 | ); 142 | name = gtest; 143 | sourceTree = ""; 144 | }; 145 | 1A98F9F817A4249200BF09FF = { 146 | isa = PBXGroup; 147 | children = ( 148 | 1A42F178182EB9EF00F3880C /* src */, 149 | 1A42F17A182EB9FE00F3880C /* example */, 150 | 1A42F179182EB9F500F3880C /* test */, 151 | 1A98FA0217A4249200BF09FF /* Products */, 152 | ); 153 | sourceTree = ""; 154 | }; 155 | 1A98FA0217A4249200BF09FF /* Products */ = { 156 | isa = PBXGroup; 157 | children = ( 158 | 1A98FA0117A4249200BF09FF /* example */, 159 | 1A98FA1917A4262700BF09FF /* test */, 160 | 1A7A0B6618316C790099EA41 /* test copy */, 161 | 1A7A0B7118316D7E0099EA41 /* test-no-stl copy */, 162 | ); 163 | name = Products; 164 | sourceTree = ""; 165 | }; 166 | /* End PBXGroup section */ 167 | 168 | /* Begin PBXNativeTarget section */ 169 | 1A7A0B5C18316C790099EA41 /* test-no-stl */ = { 170 | isa = PBXNativeTarget; 171 | buildConfigurationList = 1A7A0B6318316C790099EA41 /* Build configuration list for PBXNativeTarget "test-no-stl" */; 172 | buildPhases = ( 173 | 1A7A0B5D18316C790099EA41 /* Sources */, 174 | 1A7A0B6118316C790099EA41 /* Frameworks */, 175 | 1A7A0B6218316C790099EA41 /* CopyFiles */, 176 | ); 177 | buildRules = ( 178 | ); 179 | dependencies = ( 180 | ); 181 | name = "test-no-stl"; 182 | productName = Assert; 183 | productReference = 1A7A0B6618316C790099EA41 /* test copy */; 184 | productType = "com.apple.product-type.tool"; 185 | }; 186 | 1A7A0B6718316D7E0099EA41 /* test-no-exceptions */ = { 187 | isa = PBXNativeTarget; 188 | buildConfigurationList = 1A7A0B6E18316D7E0099EA41 /* Build configuration list for PBXNativeTarget "test-no-exceptions" */; 189 | buildPhases = ( 190 | 1A7A0B6818316D7E0099EA41 /* Sources */, 191 | 1A7A0B6C18316D7E0099EA41 /* Frameworks */, 192 | 1A7A0B6D18316D7E0099EA41 /* CopyFiles */, 193 | ); 194 | buildRules = ( 195 | ); 196 | dependencies = ( 197 | ); 198 | name = "test-no-exceptions"; 199 | productName = Assert; 200 | productReference = 1A7A0B7118316D7E0099EA41 /* test-no-stl copy */; 201 | productType = "com.apple.product-type.tool"; 202 | }; 203 | 1A98FA0017A4249200BF09FF /* example */ = { 204 | isa = PBXNativeTarget; 205 | buildConfigurationList = 1A98FA0A17A4249200BF09FF /* Build configuration list for PBXNativeTarget "example" */; 206 | buildPhases = ( 207 | 1A98F9FD17A4249200BF09FF /* Sources */, 208 | 1A98F9FE17A4249200BF09FF /* Frameworks */, 209 | 1A98F9FF17A4249200BF09FF /* CopyFiles */, 210 | ); 211 | buildRules = ( 212 | ); 213 | dependencies = ( 214 | ); 215 | name = example; 216 | productName = Assert; 217 | productReference = 1A98FA0117A4249200BF09FF /* example */; 218 | productType = "com.apple.product-type.tool"; 219 | }; 220 | 1A98FA1117A4262700BF09FF /* test */ = { 221 | isa = PBXNativeTarget; 222 | buildConfigurationList = 1A98FA1617A4262700BF09FF /* Build configuration list for PBXNativeTarget "test" */; 223 | buildPhases = ( 224 | 1A98FA1217A4262700BF09FF /* Sources */, 225 | 1A98FA1417A4262700BF09FF /* Frameworks */, 226 | 1A98FA1517A4262700BF09FF /* CopyFiles */, 227 | ); 228 | buildRules = ( 229 | ); 230 | dependencies = ( 231 | ); 232 | name = test; 233 | productName = Assert; 234 | productReference = 1A98FA1917A4262700BF09FF /* test */; 235 | productType = "com.apple.product-type.tool"; 236 | }; 237 | /* End PBXNativeTarget section */ 238 | 239 | /* Begin PBXProject section */ 240 | 1A98F9F917A4249200BF09FF /* Project object */ = { 241 | isa = PBXProject; 242 | attributes = { 243 | LastUpgradeCheck = 0460; 244 | ORGANIZATIONNAME = "Gregory Pakosz"; 245 | }; 246 | buildConfigurationList = 1A98F9FC17A4249200BF09FF /* Build configuration list for PBXProject "Assert" */; 247 | compatibilityVersion = "Xcode 3.2"; 248 | developmentRegion = English; 249 | hasScannedForEncodings = 0; 250 | knownRegions = ( 251 | en, 252 | ); 253 | mainGroup = 1A98F9F817A4249200BF09FF; 254 | productRefGroup = 1A98FA0217A4249200BF09FF /* Products */; 255 | projectDirPath = ""; 256 | projectRoot = ""; 257 | targets = ( 258 | 1A98FA0017A4249200BF09FF /* example */, 259 | 1A98FA1117A4262700BF09FF /* test */, 260 | 1A7A0B5C18316C790099EA41 /* test-no-stl */, 261 | 1A7A0B6718316D7E0099EA41 /* test-no-exceptions */, 262 | ); 263 | }; 264 | /* End PBXProject section */ 265 | 266 | /* Begin PBXSourcesBuildPhase section */ 267 | 1A7A0B5D18316C790099EA41 /* Sources */ = { 268 | isa = PBXSourcesBuildPhase; 269 | buildActionMask = 2147483647; 270 | files = ( 271 | 1A7A0B5E18316C790099EA41 /* ppk_assert.cpp in Sources */, 272 | 1A7A0B5F18316C790099EA41 /* ppk_assert_test.cpp in Sources */, 273 | 1A7A0B6018316C790099EA41 /* gtest-all.cc in Sources */, 274 | ); 275 | runOnlyForDeploymentPostprocessing = 0; 276 | }; 277 | 1A7A0B6818316D7E0099EA41 /* Sources */ = { 278 | isa = PBXSourcesBuildPhase; 279 | buildActionMask = 2147483647; 280 | files = ( 281 | 1A7A0B6918316D7E0099EA41 /* ppk_assert.cpp in Sources */, 282 | 1A7A0B6A18316D7E0099EA41 /* ppk_assert_test.cpp in Sources */, 283 | 1A7A0B6B18316D7E0099EA41 /* gtest-all.cc in Sources */, 284 | ); 285 | runOnlyForDeploymentPostprocessing = 0; 286 | }; 287 | 1A98F9FD17A4249200BF09FF /* Sources */ = { 288 | isa = PBXSourcesBuildPhase; 289 | buildActionMask = 2147483647; 290 | files = ( 291 | 1A42F184182EBABC00F3880C /* main.cpp in Sources */, 292 | 1A42F182182EBAB500F3880C /* ppk_assert.cpp in Sources */, 293 | ); 294 | runOnlyForDeploymentPostprocessing = 0; 295 | }; 296 | 1A98FA1217A4262700BF09FF /* Sources */ = { 297 | isa = PBXSourcesBuildPhase; 298 | buildActionMask = 2147483647; 299 | files = ( 300 | 1A42F183182EBAB600F3880C /* ppk_assert.cpp in Sources */, 301 | 1A42F185182EBABF00F3880C /* ppk_assert_test.cpp in Sources */, 302 | 1A42F186182EBAC300F3880C /* gtest-all.cc in Sources */, 303 | ); 304 | runOnlyForDeploymentPostprocessing = 0; 305 | }; 306 | /* End PBXSourcesBuildPhase section */ 307 | 308 | /* Begin XCBuildConfiguration section */ 309 | 1A7A0B6418316C790099EA41 /* Debug */ = { 310 | isa = XCBuildConfiguration; 311 | buildSettings = { 312 | GCC_PREPROCESSOR_DEFINITIONS = PPK_ASSERT_DISABLE_STL; 313 | HEADER_SEARCH_PATHS = ( 314 | "$(inherited)", 315 | ../src, 316 | ../test, 317 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 318 | ); 319 | PRODUCT_NAME = "test copy"; 320 | }; 321 | name = Debug; 322 | }; 323 | 1A7A0B6518316C790099EA41 /* Release */ = { 324 | isa = XCBuildConfiguration; 325 | buildSettings = { 326 | GCC_PREPROCESSOR_DEFINITIONS = ( 327 | PPK_ASSERT_DISABLE_STL, 328 | "$(inherited)", 329 | ); 330 | HEADER_SEARCH_PATHS = ( 331 | "$(inherited)", 332 | ../src, 333 | ../test, 334 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 335 | ); 336 | PRODUCT_NAME = "test copy"; 337 | }; 338 | name = Release; 339 | }; 340 | 1A7A0B6F18316D7E0099EA41 /* Debug */ = { 341 | isa = XCBuildConfiguration; 342 | buildSettings = { 343 | GCC_PREPROCESSOR_DEFINITIONS = PPK_ASSERT_DISABLE_EXCEPTIONS; 344 | HEADER_SEARCH_PATHS = ( 345 | "$(inherited)", 346 | ../src, 347 | ../test, 348 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 349 | ); 350 | PRODUCT_NAME = "test-no-stl copy"; 351 | }; 352 | name = Debug; 353 | }; 354 | 1A7A0B7018316D7E0099EA41 /* Release */ = { 355 | isa = XCBuildConfiguration; 356 | buildSettings = { 357 | GCC_PREPROCESSOR_DEFINITIONS = ( 358 | PPK_ASSERT_DISABLE_EXCEPTIONS, 359 | "$(inherited)", 360 | ); 361 | HEADER_SEARCH_PATHS = ( 362 | "$(inherited)", 363 | ../src, 364 | ../test, 365 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 366 | ); 367 | PRODUCT_NAME = "test-no-stl copy"; 368 | }; 369 | name = Release; 370 | }; 371 | 1A98FA0817A4249200BF09FF /* Debug */ = { 372 | isa = XCBuildConfiguration; 373 | buildSettings = { 374 | ALWAYS_SEARCH_USER_PATHS = NO; 375 | ARCHS = "$(ARCHS_STANDARD_64_BIT)"; 376 | CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; 377 | CLANG_CXX_LIBRARY = "libc++"; 378 | CLANG_WARN_CONSTANT_CONVERSION = YES; 379 | CLANG_WARN_EMPTY_BODY = YES; 380 | CLANG_WARN_ENUM_CONVERSION = YES; 381 | CLANG_WARN_INT_CONVERSION = YES; 382 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 383 | COPY_PHASE_STRIP = NO; 384 | GCC_C_LANGUAGE_STANDARD = gnu99; 385 | GCC_DYNAMIC_NO_PIC = NO; 386 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 387 | GCC_OPTIMIZATION_LEVEL = 0; 388 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 389 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 390 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 391 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 392 | GCC_WARN_UNUSED_VARIABLE = YES; 393 | MACOSX_DEPLOYMENT_TARGET = 10.8; 394 | ONLY_ACTIVE_ARCH = YES; 395 | PRODUCT_NAME = "$(TARGET_NAME)"; 396 | SDKROOT = macosx; 397 | }; 398 | name = Debug; 399 | }; 400 | 1A98FA0917A4249200BF09FF /* Release */ = { 401 | isa = XCBuildConfiguration; 402 | buildSettings = { 403 | ALWAYS_SEARCH_USER_PATHS = NO; 404 | ARCHS = "$(ARCHS_STANDARD_64_BIT)"; 405 | CLANG_CXX_LANGUAGE_STANDARD = "c++0x"; 406 | CLANG_CXX_LIBRARY = "libc++"; 407 | CLANG_WARN_CONSTANT_CONVERSION = YES; 408 | CLANG_WARN_EMPTY_BODY = YES; 409 | CLANG_WARN_ENUM_CONVERSION = YES; 410 | CLANG_WARN_INT_CONVERSION = YES; 411 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 412 | COPY_PHASE_STRIP = YES; 413 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 414 | GCC_C_LANGUAGE_STANDARD = gnu99; 415 | GCC_ENABLE_OBJC_EXCEPTIONS = YES; 416 | GCC_OPTIMIZATION_LEVEL = 2; 417 | GCC_PREPROCESSOR_DEFINITIONS = NDEBUG; 418 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 419 | GCC_WARN_ABOUT_RETURN_TYPE = YES; 420 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 421 | GCC_WARN_UNUSED_VARIABLE = YES; 422 | MACOSX_DEPLOYMENT_TARGET = 10.8; 423 | PRODUCT_NAME = "$(TARGET_NAME)"; 424 | SDKROOT = macosx; 425 | }; 426 | name = Release; 427 | }; 428 | 1A98FA0B17A4249200BF09FF /* Debug */ = { 429 | isa = XCBuildConfiguration; 430 | buildSettings = { 431 | HEADER_SEARCH_PATHS = ( 432 | "$(inherited)", 433 | ../src, 434 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 435 | ); 436 | }; 437 | name = Debug; 438 | }; 439 | 1A98FA0C17A4249200BF09FF /* Release */ = { 440 | isa = XCBuildConfiguration; 441 | buildSettings = { 442 | HEADER_SEARCH_PATHS = ( 443 | "$(inherited)", 444 | ../src, 445 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 446 | ); 447 | }; 448 | name = Release; 449 | }; 450 | 1A98FA1717A4262700BF09FF /* Debug */ = { 451 | isa = XCBuildConfiguration; 452 | buildSettings = { 453 | HEADER_SEARCH_PATHS = ( 454 | "$(inherited)", 455 | ../src, 456 | ../test, 457 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 458 | ); 459 | }; 460 | name = Debug; 461 | }; 462 | 1A98FA1817A4262700BF09FF /* Release */ = { 463 | isa = XCBuildConfiguration; 464 | buildSettings = { 465 | HEADER_SEARCH_PATHS = ( 466 | "$(inherited)", 467 | ../src, 468 | ../test, 469 | /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, 470 | ); 471 | }; 472 | name = Release; 473 | }; 474 | /* End XCBuildConfiguration section */ 475 | 476 | /* Begin XCConfigurationList section */ 477 | 1A7A0B6318316C790099EA41 /* Build configuration list for PBXNativeTarget "test-no-stl" */ = { 478 | isa = XCConfigurationList; 479 | buildConfigurations = ( 480 | 1A7A0B6418316C790099EA41 /* Debug */, 481 | 1A7A0B6518316C790099EA41 /* Release */, 482 | ); 483 | defaultConfigurationIsVisible = 0; 484 | defaultConfigurationName = Release; 485 | }; 486 | 1A7A0B6E18316D7E0099EA41 /* Build configuration list for PBXNativeTarget "test-no-exceptions" */ = { 487 | isa = XCConfigurationList; 488 | buildConfigurations = ( 489 | 1A7A0B6F18316D7E0099EA41 /* Debug */, 490 | 1A7A0B7018316D7E0099EA41 /* Release */, 491 | ); 492 | defaultConfigurationIsVisible = 0; 493 | defaultConfigurationName = Release; 494 | }; 495 | 1A98F9FC17A4249200BF09FF /* Build configuration list for PBXProject "Assert" */ = { 496 | isa = XCConfigurationList; 497 | buildConfigurations = ( 498 | 1A98FA0817A4249200BF09FF /* Debug */, 499 | 1A98FA0917A4249200BF09FF /* Release */, 500 | ); 501 | defaultConfigurationIsVisible = 0; 502 | defaultConfigurationName = Release; 503 | }; 504 | 1A98FA0A17A4249200BF09FF /* Build configuration list for PBXNativeTarget "example" */ = { 505 | isa = XCConfigurationList; 506 | buildConfigurations = ( 507 | 1A98FA0B17A4249200BF09FF /* Debug */, 508 | 1A98FA0C17A4249200BF09FF /* Release */, 509 | ); 510 | defaultConfigurationIsVisible = 0; 511 | defaultConfigurationName = Release; 512 | }; 513 | 1A98FA1617A4262700BF09FF /* Build configuration list for PBXNativeTarget "test" */ = { 514 | isa = XCConfigurationList; 515 | buildConfigurations = ( 516 | 1A98FA1717A4262700BF09FF /* Debug */, 517 | 1A98FA1817A4262700BF09FF /* Release */, 518 | ); 519 | defaultConfigurationIsVisible = 0; 520 | defaultConfigurationName = Release; 521 | }; 522 | /* End XCConfigurationList section */ 523 | }; 524 | rootObject = 1A98F9F917A4249200BF09FF /* Project object */; 525 | } 526 | -------------------------------------------------------------------------------- /_mac-xcode/Assert.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /_win-vs14/.gitignore: -------------------------------------------------------------------------------- 1 | /build 2 | /ipch 3 | 4 | *.suo 5 | *.sdf 6 | *.opensdf 7 | *.user 8 | *.sln.docstates 9 | *.opendb 10 | *.VC.db 11 | -------------------------------------------------------------------------------- /_win-vs14/Assert.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Express 2012 for Windows Desktop 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "example", "example.vcxproj", "{7BC8C873-A2C7-43A1-BD8A-2F1731F3CB81}" 5 | EndProject 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test", "test.vcxproj", "{B961C6F4-3EB4-488C-B71F-E2D5B4D83BD4}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-no-stl", "test-no-stl.vcxproj", "{3AE23415-275A-41EE-ACCE-C669B6D49617}" 9 | EndProject 10 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "test-no-exceptions", "test-no-exceptions.vcxproj", "{9C7F4A41-3416-412A-A0BF-9D656C3E47EB}" 11 | EndProject 12 | Global 13 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 14 | Debug|Win32 = Debug|Win32 15 | Debug|x64 = Debug|x64 16 | Release|Win32 = Release|Win32 17 | Release|x64 = Release|x64 18 | EndGlobalSection 19 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 20 | {7BC8C873-A2C7-43A1-BD8A-2F1731F3CB81}.Debug|Win32.ActiveCfg = Debug|Win32 21 | {7BC8C873-A2C7-43A1-BD8A-2F1731F3CB81}.Debug|Win32.Build.0 = Debug|Win32 22 | {7BC8C873-A2C7-43A1-BD8A-2F1731F3CB81}.Debug|x64.ActiveCfg = Debug|x64 23 | {7BC8C873-A2C7-43A1-BD8A-2F1731F3CB81}.Debug|x64.Build.0 = Debug|x64 24 | {7BC8C873-A2C7-43A1-BD8A-2F1731F3CB81}.Release|Win32.ActiveCfg = Release|Win32 25 | {7BC8C873-A2C7-43A1-BD8A-2F1731F3CB81}.Release|Win32.Build.0 = Release|Win32 26 | {7BC8C873-A2C7-43A1-BD8A-2F1731F3CB81}.Release|x64.ActiveCfg = Release|x64 27 | {7BC8C873-A2C7-43A1-BD8A-2F1731F3CB81}.Release|x64.Build.0 = Release|x64 28 | {B961C6F4-3EB4-488C-B71F-E2D5B4D83BD4}.Debug|Win32.ActiveCfg = Debug|Win32 29 | {B961C6F4-3EB4-488C-B71F-E2D5B4D83BD4}.Debug|Win32.Build.0 = Debug|Win32 30 | {B961C6F4-3EB4-488C-B71F-E2D5B4D83BD4}.Debug|x64.ActiveCfg = Debug|x64 31 | {B961C6F4-3EB4-488C-B71F-E2D5B4D83BD4}.Debug|x64.Build.0 = Debug|x64 32 | {B961C6F4-3EB4-488C-B71F-E2D5B4D83BD4}.Release|Win32.ActiveCfg = Release|Win32 33 | {B961C6F4-3EB4-488C-B71F-E2D5B4D83BD4}.Release|Win32.Build.0 = Release|Win32 34 | {B961C6F4-3EB4-488C-B71F-E2D5B4D83BD4}.Release|x64.ActiveCfg = Release|x64 35 | {B961C6F4-3EB4-488C-B71F-E2D5B4D83BD4}.Release|x64.Build.0 = Release|x64 36 | {3AE23415-275A-41EE-ACCE-C669B6D49617}.Debug|Win32.ActiveCfg = Debug|Win32 37 | {3AE23415-275A-41EE-ACCE-C669B6D49617}.Debug|Win32.Build.0 = Debug|Win32 38 | {3AE23415-275A-41EE-ACCE-C669B6D49617}.Debug|x64.ActiveCfg = Debug|x64 39 | {3AE23415-275A-41EE-ACCE-C669B6D49617}.Debug|x64.Build.0 = Debug|x64 40 | {3AE23415-275A-41EE-ACCE-C669B6D49617}.Release|Win32.ActiveCfg = Release|Win32 41 | {3AE23415-275A-41EE-ACCE-C669B6D49617}.Release|Win32.Build.0 = Release|Win32 42 | {3AE23415-275A-41EE-ACCE-C669B6D49617}.Release|x64.ActiveCfg = Release|x64 43 | {3AE23415-275A-41EE-ACCE-C669B6D49617}.Release|x64.Build.0 = Release|x64 44 | {9C7F4A41-3416-412A-A0BF-9D656C3E47EB}.Debug|Win32.ActiveCfg = Debug|Win32 45 | {9C7F4A41-3416-412A-A0BF-9D656C3E47EB}.Debug|Win32.Build.0 = Debug|Win32 46 | {9C7F4A41-3416-412A-A0BF-9D656C3E47EB}.Debug|x64.ActiveCfg = Debug|x64 47 | {9C7F4A41-3416-412A-A0BF-9D656C3E47EB}.Debug|x64.Build.0 = Debug|x64 48 | {9C7F4A41-3416-412A-A0BF-9D656C3E47EB}.Release|Win32.ActiveCfg = Release|Win32 49 | {9C7F4A41-3416-412A-A0BF-9D656C3E47EB}.Release|Win32.Build.0 = Release|Win32 50 | {9C7F4A41-3416-412A-A0BF-9D656C3E47EB}.Release|x64.ActiveCfg = Release|x64 51 | {9C7F4A41-3416-412A-A0BF-9D656C3E47EB}.Release|x64.Build.0 = Release|x64 52 | EndGlobalSection 53 | GlobalSection(SolutionProperties) = preSolution 54 | HideSolutionNode = FALSE 55 | EndGlobalSection 56 | EndGlobal 57 | -------------------------------------------------------------------------------- /_win-vs14/Common.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | ..\bin\Windows$(PLATFORM_SUFFIX)-$(ARCH)$(CONF_SUFFIX) 5 | ..\lib\Windows$(PLATFORM_SUFFIX)-$(ARCH)-vs11$(CONF_SUFFIX) 6 | build\$(ProjectName)-win$(PLATFORM_SUFFIX)-$(ARCH)-vs11$(CONF_SUFFIX) 7 | 8 | 9 | $(BUILD_DIR)\ 10 | $(BIN_DIR)\ 11 | false 12 | 13 | 14 | 15 | _CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;_SCL_SECURE_NO_WARNINGS;%(PreprocessorDefinitions) 16 | true 17 | /w14545 /w34242 /w34254 /w34287 /w44263 /w44265 /w44296 /w44311 /w44355 /w44826 /wd4010 /wd4054 /wd4055 /wd4100 /wd4127 /wd4132 /wd4152 /wd4201 /wd4204 /wd4206 /wd4221 /wd4458 /wd4505 /wd4668 /wd4701 /wd4703 /wd4706 /wd4710 /wd4711 /wd4820 /we4002 /we4003 /we4013 /we4289 /we4546 /we4547 /we4548 /we4549 /we4555 /we4619 /we4905 /we4906 /we4928 %(AdditionalOptions) 18 | NotUsing 19 | true 20 | EnableAllWarnings 21 | 22 | 23 | true 24 | Console 25 | /time %(AdditionalOptions) 26 | 27 | 28 | 29 | 30 | $(BIN_DIR) 31 | 32 | 33 | $(LIB_DIR) 34 | 35 | 36 | $(BUILD_DIR) 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /_win-vs14/Debug.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | -Debug 5 | 6 | 7 | true 8 | 9 | 10 | 11 | Disabled 12 | Level3 13 | ProgramDatabase 14 | MultiThreadedDebug 15 | true 16 | OnlyExplicitInline 17 | 18 | 19 | 20 | 21 | $(CONF_SUFFIX) 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /_win-vs14/Release.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | false 8 | 9 | 10 | 11 | MaxSpeed 12 | AnySuitable 13 | true 14 | Speed 15 | true 16 | true 17 | true 18 | NDEBUG;%(PreprocessorDefinitions) 19 | true 20 | Level3 21 | ProgramDatabase 22 | MultiThreaded 23 | false 24 | /d2Zi+ %(AdditionalOptions) 25 | 26 | 27 | UseLinkTimeCodeGeneration 28 | true 29 | 30 | 31 | true 32 | 33 | 34 | 35 | 36 | $(CONF_SUFFIX) 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /_win-vs14/UnitTest.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | <_ProjectFileVersion>10.0.40219.1 5 | 6 | 7 | 8 | ..\src;..\test;%(AdditionalIncludeDirectories) 9 | _VARIADIC_MAX=10;%(PreprocessorDefinitions) 10 | /wd4350 /wd4514 /wd4571 /wd4577 /wd4623 /wd4625 /wd4626 /wd4640 /wd4668 /wd4986 /wd5026 /wd5027 /we4836 /we4946 %(AdditionalOptions) 11 | 12 | 13 | false 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /_win-vs14/example.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | {7BC8C873-A2C7-43A1-BD8A-2F1731F3CB81} 30 | example 31 | 32 | 33 | 34 | Application 35 | true 36 | v140 37 | 38 | 39 | Application 40 | true 41 | v140 42 | 43 | 44 | Application 45 | false 46 | v140 47 | true 48 | 49 | 50 | Application 51 | false 52 | v140 53 | true 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | ..\src;%(AdditionalIncludeDirectories) 92 | 93 | 94 | Windows 95 | 96 | 97 | 98 | 99 | 100 | ..\src;%(AdditionalIncludeDirectories) 101 | 102 | 103 | Windows 104 | 105 | 106 | 107 | 108 | 109 | ..\src;%(AdditionalIncludeDirectories) 110 | 111 | 112 | Windows 113 | 114 | 115 | 116 | 117 | 118 | ..\src;%(AdditionalIncludeDirectories) 119 | 120 | 121 | Windows 122 | 123 | 124 | 125 | 126 | 127 | 128 | -------------------------------------------------------------------------------- /_win-vs14/test-no-exceptions.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | {9C7F4A41-3416-412A-A0BF-9D656C3E47EB} 32 | test-no-exceptions 33 | 34 | 35 | 36 | Application 37 | true 38 | v140 39 | 40 | 41 | Application 42 | true 43 | v140 44 | 45 | 46 | Application 47 | false 48 | v140 49 | true 50 | 51 | 52 | Application 53 | false 54 | v140 55 | true 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | false 99 | /wd4530 %(AdditionalOptions) 100 | 101 | 102 | 103 | 104 | 105 | 106 | false 107 | /wd4530 %(AdditionalOptions) 108 | 109 | 110 | 111 | 112 | 113 | 114 | false 115 | /wd4530 %(AdditionalOptions) 116 | 117 | 118 | 119 | 120 | 121 | 122 | false 123 | /wd4530 %(AdditionalOptions) 124 | 125 | 126 | 127 | 128 | 129 | 130 | -------------------------------------------------------------------------------- /_win-vs14/test-no-stl.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | {3AE23415-275A-41EE-ACCE-C669B6D49617} 32 | test-no-stl 33 | 34 | 35 | 36 | Application 37 | true 38 | v140 39 | 40 | 41 | Application 42 | true 43 | v140 44 | 45 | 46 | Application 47 | false 48 | v140 49 | true 50 | 51 | 52 | Application 53 | false 54 | v140 55 | true 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | PPK_ASSERT_DISABLE_STL;%(PreprocessorDefinitions) 99 | 100 | 101 | 102 | 103 | 104 | 105 | PPK_ASSERT_DISABLE_STL;%(PreprocessorDefinitions) 106 | 107 | 108 | 109 | 110 | 111 | 112 | PPK_ASSERT_DISABLE_STL;%(PreprocessorDefinitions) 113 | 114 | 115 | 116 | 117 | 118 | 119 | PPK_ASSERT_DISABLE_STL;%(PreprocessorDefinitions) 120 | 121 | 122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /_win-vs14/test.vcxproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | Debug 6 | Win32 7 | 8 | 9 | Debug 10 | x64 11 | 12 | 13 | Release 14 | Win32 15 | 16 | 17 | Release 18 | x64 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | {B961C6F4-3EB4-488C-B71F-E2D5B4D83BD4} 32 | test 33 | 34 | 35 | 36 | Application 37 | true 38 | v140 39 | 40 | 41 | Application 42 | true 43 | v140 44 | 45 | 46 | Application 47 | false 48 | v140 49 | true 50 | 51 | 52 | Application 53 | false 54 | v140 55 | true 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | -------------------------------------------------------------------------------- /_win-vs14/x64.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | x64 5 | 6 | 7 | 8 | MachineX64 9 | 10 | 11 | 12 | 13 | $(ARCH) 14 | 15 | 16 | 17 | -------------------------------------------------------------------------------- /_win-vs14/x86.props: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | x86 5 | 6 | 7 | 8 | MachineX86 9 | 10 | 11 | StreamingSIMDExtensions2 12 | 13 | 14 | 15 | 16 | $(ARCH) 17 | 18 | 19 | -------------------------------------------------------------------------------- /example/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | // custom prefix 7 | #define ASSERT PPK_ASSERT 8 | #define ASSERT_WARNING PPK_ASSERT_WARNING 9 | #define ASSERT_DEBUG PPK_ASSERT_DEBUG 10 | #define ASSERT_ERROR PPK_ASSERT_ERROR 11 | #define ASSERT_FATAL PPK_ASSERT_FATAL 12 | #define ASSERT_CUSTOM PPK_ASSERT_CUSTOM 13 | #define ASSERT_USED PPK_ASSERT_USED 14 | 15 | void trigger_assert_debug_even(int i) 16 | { 17 | ASSERT_DEBUG((i % 2) == 0, "not an even number: %d", i); 18 | } 19 | 20 | void trigger_assert_debug_odd(int i) 21 | { 22 | ASSERT_DEBUG((i % 2) != 0, "not an odd number: %d", i); 23 | } 24 | 25 | void trigger_assert_error() 26 | { 27 | void* ptr = 0; 28 | ASSERT_ERROR(ptr != 0, "invalid ptr: must not be null"); 29 | } 30 | 31 | void trigger_assert_custom1() 32 | { 33 | void* ptr = 0; 34 | ASSERT_CUSTOM(100, ptr != 0, "invalid ptr: must not be null"); 35 | } 36 | 37 | ASSERT_USED(std::vector) trigger_assert_unused_return_value1() 38 | { 39 | return std::vector(10); 40 | } 41 | 42 | #undef PPK_ASSERT_ENABLED 43 | #define PPK_ASSERT_ENABLED 0 44 | #include 45 | 46 | void trigger_assert_custom2() 47 | { 48 | void* ptr = 0; 49 | ASSERT_CUSTOM(100, ptr != 0, "invalid ptr: must not be null"); 50 | } 51 | 52 | ASSERT_USED(int) trigger_assert_unused_return_value2() 53 | { 54 | return 0; 55 | } 56 | 57 | #undef PPK_ASSERT_ENABLED 58 | #define PPK_ASSERT_ENABLED 1 59 | #include 60 | 61 | #if defined(_WIN32) 62 | #define WIN32_LEAN_AND_MEAN 63 | #include 64 | int CALLBACK WinMain(_In_ HINSTANCE, _In_opt_ HINSTANCE, _In_ LPSTR, _In_ int) 65 | #else 66 | int main() 67 | #endif 68 | { 69 | ASSERT(true); 70 | ASSERT_WARNING(true); 71 | ASSERT_DEBUG(true); 72 | ASSERT_ERROR(true); 73 | ASSERT_FATAL(true); 74 | ASSERT_CUSTOM(0, true); 75 | 76 | for (int i = 0; i < 5; ++i) 77 | trigger_assert_debug_even(i); 78 | 79 | for (int i = 0; i < 5; ++i) 80 | trigger_assert_debug_odd(i); 81 | 82 | try 83 | { 84 | trigger_assert_error(); 85 | } 86 | catch(const ppk::assert::AssertionException& e) 87 | { 88 | std::cout << "AssertionException caught:" << std::endl; 89 | std::cout << " [file]: " << e.file() << std::endl; 90 | std::cout << " [line]: " << e.line() << std::endl; 91 | std::cout << " [function]: " << e.function() << std::endl; 92 | std::cout << " [expression]: " << e.expression() << std::endl; 93 | std::cout << " [what]: " << e.what() << std::endl; 94 | std::cout << std::endl; 95 | } 96 | 97 | trigger_assert_custom1(); 98 | 99 | trigger_assert_custom2(); 100 | 101 | { 102 | std::vector v = trigger_assert_unused_return_value1(); 103 | v.clear(); 104 | 105 | // trigger assert on scope exit 106 | trigger_assert_unused_return_value1(); 107 | } 108 | 109 | { 110 | trigger_assert_unused_return_value2(); 111 | } 112 | 113 | ASSERT_FATAL(false, "He's dead. He's dead, Jim"); 114 | 115 | std::cout << std::endl; 116 | std::cout << "if you see this message, this means you decided to ignore all assertions" << std::endl; 117 | 118 | return 0; 119 | } 120 | -------------------------------------------------------------------------------- /src/ppk_assert.cpp: -------------------------------------------------------------------------------- 1 | // see README.md for usage instructions. 2 | // (‑●‑●)> released under the WTFPL v2 license, by Gregory Pakosz (@gpakosz) 3 | 4 | #if defined(_WIN32) 5 | #define WIN32_LEAN_AND_MEAN 6 | #define _CRT_SECURE_NO_WARNINGS 7 | #include 8 | #endif 9 | 10 | #include 11 | 12 | #include // fprintf() and vsnprintf() 13 | #include 14 | #include // va_start() and va_end() 15 | #include // abort() 16 | 17 | #if defined(__APPLE__) 18 | #include 19 | #endif 20 | 21 | #if defined(__ANDROID__) || defined(ANDROID) 22 | #include 23 | #if !defined(PPK_ASSERT_LOG_TAG) 24 | #define PPK_ASSERT_LOG_TAG "PPK_ASSERT" 25 | #endif 26 | #endif 27 | 28 | //#define PPK_ASSERT_LOG_FILE "/tmp/assert.txt" 29 | //#define PPK_ASSERT_LOG_FILE_TRUNCATE 30 | 31 | // malloc and free are only used by AssertionException implemented in terms of 32 | // short string optimization. 33 | // However, no memory allocation happens if 34 | // PPK_ASSERT_EXCEPTION_MESSAGE_BUFFER_SIZE == PPK_ASSERT_MESSAGE_BUFFER_SIZE 35 | // which is the default. 36 | #if !defined(PPK_ASSERT_MALLOC) 37 | #define PPK_ASSERT_MALLOC(size) malloc(size) 38 | #endif 39 | 40 | #if !defined(PPK_ASSERT_FREE) 41 | #define PPK_ASSERT_FREE(p) free(p) 42 | #endif 43 | 44 | #if !defined(PPK_ASSERT_MESSAGE_BUFFER_SIZE) 45 | # define PPK_ASSERT_MESSAGE_BUFFER_SIZE PPK_ASSERT_EXCEPTION_MESSAGE_BUFFER_SIZE 46 | #endif 47 | 48 | #if !defined(PPK_ASSERT_ABORT) 49 | #define PPK_ASSERT_ABORT abort 50 | #endif 51 | 52 | namespace { 53 | 54 | namespace AssertLevel = ppk::assert::implementation::AssertLevel; 55 | namespace AssertAction = ppk::assert::implementation::AssertAction; 56 | 57 | typedef int (*printHandler)(FILE* out, int, const char* format, ...); 58 | 59 | #if defined(PPK_ASSERT_LOG_FILE) && defined(PPK_ASSERT_LOG_FILE_TRUNCATE) 60 | struct LogFileTruncate 61 | { 62 | LogFileTruncate() 63 | { 64 | if (FILE* f = fopen(PPK_ASSERT_LOG_FILE, "w")) 65 | fclose(f); 66 | } 67 | }; 68 | 69 | static LogFileTruncate truncate; 70 | #endif 71 | 72 | int print(FILE* out, int level, const char* format, ...) 73 | { 74 | va_list args; 75 | int count; 76 | 77 | va_start(args, format); 78 | count = vfprintf(out, format, args); 79 | fflush(out); 80 | va_end(args); 81 | 82 | #if defined(PPK_ASSERT_LOG_FILE) 83 | struct Local 84 | { 85 | static void log(const char* _format, va_list _args) 86 | { 87 | if (FILE* f = fopen(PPK_ASSERT_LOG_FILE, "a")) 88 | { 89 | vfprintf(f, _format, _args); 90 | fclose(f); 91 | } 92 | } 93 | }; 94 | 95 | va_start(args, format); 96 | Local::log(format, args); 97 | va_end(args); 98 | #endif 99 | 100 | #if defined(_WIN32) 101 | char buffer[PPK_ASSERT_MESSAGE_BUFFER_SIZE]; 102 | va_start(args, format); 103 | vsnprintf(buffer, PPK_ASSERT_MESSAGE_BUFFER_SIZE, format, args); 104 | ::OutputDebugStringA(buffer); 105 | va_end(args); 106 | #endif 107 | 108 | #if defined(__ANDROID__) || defined(ANDROID) 109 | int priority = ANDROID_LOG_VERBOSE; 110 | 111 | if (level >= AssertLevel::Debug) 112 | priority = ANDROID_LOG_DEBUG; 113 | else if (level >= AssertLevel::Warning) 114 | priority = ANDROID_LOG_WARN; 115 | else if (level >= AssertLevel::Error) 116 | priority = ANDROID_LOG_ERROR; 117 | else if (level >= AssertLevel::Fatal) 118 | priority = ANDROID_LOG_FATAL; 119 | 120 | va_start(args, format); 121 | __android_log_vprint(priority, PPK_ASSERT_LOG_TAG, format, args); 122 | va_start(args, format); 123 | #else 124 | PPK_ASSERT_UNUSED(level); 125 | #endif 126 | 127 | return count; 128 | } 129 | 130 | int formatLevel(int level, const char* expression, FILE* out, printHandler print) 131 | { 132 | const char* levelstr = 0; 133 | 134 | switch (level) 135 | { 136 | case AssertLevel::Debug: 137 | levelstr = "DEBUG"; 138 | break; 139 | case AssertLevel::Warning: 140 | levelstr = "WARNING"; 141 | break; 142 | case AssertLevel::Error: 143 | levelstr = "ERROR"; 144 | break; 145 | case AssertLevel::Fatal: 146 | levelstr = "FATAL"; 147 | break; 148 | 149 | default: 150 | break; 151 | } 152 | 153 | if (levelstr) 154 | return print(out, level, "Assertion '%s' failed (%s)\n", expression, levelstr); 155 | else 156 | return print(out, level, "Assertion '%s' failed (level = %d)\n", expression, level); 157 | } 158 | 159 | AssertAction::AssertAction PPK_ASSERT_CALL _defaultHandler( const char* file, 160 | int line, 161 | const char* function, 162 | const char* expression, 163 | int level, 164 | const char* message) 165 | { 166 | #if defined(_WIN32) 167 | if (::GetConsoleWindow() == NULL) 168 | { 169 | if (::AllocConsole()) 170 | { 171 | (void)freopen("CONIN$", "r", stdin); 172 | (void)freopen("CONOUT$", "w", stdout); 173 | (void)freopen("CONOUT$", "w", stderr); 174 | 175 | SetFocus(::GetConsoleWindow()); 176 | } 177 | } 178 | #endif 179 | 180 | formatLevel(level, expression, stderr, reinterpret_cast(print)); 181 | print(stderr, level, " in file %s, line %d\n function: %s\n", file, line, function); 182 | 183 | if (message) 184 | print(stderr, level, " with message: %s\n\n", message); 185 | 186 | if (level < AssertLevel::Debug) 187 | { 188 | return AssertAction::None; 189 | } 190 | else if (AssertLevel::Debug <= level && level < AssertLevel::Error) 191 | { 192 | #if (!TARGET_OS_IPHONE && !TARGET_IPHONE_SIMULATOR) && (!defined(__ANDROID__) && !defined(ANDROID)) || defined(PPK_ASSERT_DEFAULT_HANDLER_STDIN) 193 | for (;;) 194 | { 195 | #if defined(PPK_ASSERT_DISABLE_IGNORE_LINE) 196 | fprintf(stderr, "Press (I)gnore / Ignore (A)ll / (D)ebug / A(b)ort: "); 197 | #else 198 | fprintf(stderr, "Press (I)gnore / Ignore (F)orever / Ignore (A)ll / (D)ebug / A(b)ort: "); 199 | #endif 200 | fflush(stderr); 201 | 202 | char buffer[256]; 203 | if (!fgets(buffer, sizeof(buffer), stdin)) 204 | { 205 | clearerr(stdin); 206 | fprintf(stderr, "\n"); 207 | fflush(stderr); 208 | continue; 209 | } 210 | 211 | // we eventually skip the leading spaces but that's it 212 | char input[2] = {'b', 0}; 213 | if (sscanf(buffer, " %1[a-zA-Z] ", input) != 1) 214 | continue; 215 | 216 | switch (*input) 217 | { 218 | case 'b': 219 | case 'B': 220 | return AssertAction::Abort; 221 | 222 | case 'd': 223 | case 'D': 224 | return AssertAction::Break; 225 | 226 | case 'i': 227 | case 'I': 228 | return AssertAction::Ignore; 229 | 230 | # if !defined(PPK_ASSERT_DISABLE_IGNORE_LINE) 231 | case 'f': 232 | case 'F': 233 | return AssertAction::IgnoreLine; 234 | # endif 235 | 236 | case 'a': 237 | case 'A': 238 | return AssertAction::IgnoreAll; 239 | 240 | default: 241 | break; 242 | } 243 | } 244 | #else 245 | return AssertAction::Break; 246 | #endif 247 | } 248 | else if (AssertLevel::Error <= level && level < AssertLevel::Fatal) 249 | { 250 | return AssertAction::Throw; 251 | } 252 | 253 | return AssertAction::Abort; 254 | } 255 | 256 | void _throw(const char* file, 257 | int line, 258 | const char* function, 259 | const char* expression, 260 | const char* message) 261 | { 262 | using ppk::assert::implementation::throwException; 263 | throwException(ppk::assert::AssertionException(file, line, function, expression, message)); 264 | } 265 | } 266 | 267 | namespace ppk { 268 | namespace assert { 269 | 270 | AssertionException::AssertionException(const char* file, 271 | int line, 272 | const char* function, 273 | const char* expression, 274 | const char* message) 275 | : _file(file), _line(line), _function(function), _expression(expression), _heap(PPK_ASSERT_NULLPTR) 276 | { 277 | if (!message) 278 | { 279 | memset(_stack, 0, sizeof(char) * size); 280 | return; 281 | } 282 | 283 | size_t length = strlen(message); 284 | 285 | if (length < size) // message is short enough for the stack buffer 286 | { 287 | memcpy(_stack, message, sizeof(char) * length); 288 | memset(_stack + length, 0, sizeof(char) * (size - length)); // pad with 0 289 | } 290 | else // allocate storage on the heap 291 | { 292 | _heap = static_cast(PPK_ASSERT_MALLOC(sizeof(char) * (length + 1))); 293 | 294 | if (!_heap) // allocation failed 295 | { 296 | memcpy(_stack, message, sizeof(char) * (size - 1)); // stack fallback, truncate :/ 297 | _stack[size - 1] = 0; 298 | } 299 | else 300 | { 301 | memcpy(_heap, message, sizeof(char) * length); // copy the message 302 | _heap[length] = 0; 303 | _stack[size - 1] = 1; // mark the stack 304 | } 305 | } 306 | } 307 | 308 | AssertionException::AssertionException(const AssertionException& rhs) 309 | : _file(rhs._file), _line(rhs._line), _function(rhs._function), _expression(rhs._expression) 310 | { 311 | const char* message = rhs.what(); 312 | size_t length = strlen(message); 313 | 314 | if (length < size) // message is short enough for the stack buffer 315 | { 316 | memcpy(_stack, message, sizeof(char) * size); // pad with 0 317 | } 318 | else // allocate storage on the heap 319 | { 320 | _heap = static_cast(PPK_ASSERT_MALLOC(sizeof(char) * (length + 1))); 321 | 322 | if (!_heap) // allocation failed 323 | { 324 | memcpy(_stack, message, sizeof(char) * (size - 1)); // stack fallback, truncate :/ 325 | _stack[size - 1] = 0; 326 | } 327 | else 328 | { 329 | memcpy(_heap, message, sizeof(char) * length); // copy the message 330 | _heap[length] = 0; 331 | _stack[size - 1] = 1; // mark the stack 332 | } 333 | } 334 | } 335 | 336 | AssertionException::~AssertionException() PPK_ASSERT_EXCEPTION_NO_THROW 337 | { 338 | if (_stack[size - 1]) 339 | PPK_ASSERT_FREE(_heap); 340 | 341 | _heap = PPK_ASSERT_NULLPTR; // in case the exception object is destroyed twice 342 | _stack[size - 1] = 0; 343 | } 344 | 345 | AssertionException& AssertionException::operator = (const AssertionException& rhs) 346 | { 347 | if (&rhs == this) 348 | return *this; 349 | 350 | const char* message = rhs.what(); 351 | size_t length = strlen(message); 352 | 353 | if (length < size) // message is short enough for the stack buffer 354 | { 355 | if (_stack[size - 1]) 356 | PPK_ASSERT_FREE(_heap); 357 | 358 | memcpy(_stack, message, sizeof(char) * size); 359 | } 360 | else // allocate storage on the heap 361 | { 362 | if (_stack[size - 1]) 363 | { 364 | size_t _length = strlen(_heap); 365 | 366 | if (length <= _length) 367 | { 368 | memcpy(_heap, message, sizeof(char) * _length); // copy the message, pad with 0 369 | return *this; 370 | } 371 | else 372 | { 373 | PPK_ASSERT_FREE(_heap); 374 | } 375 | } 376 | 377 | _heap = static_cast(PPK_ASSERT_MALLOC(sizeof(char) * (length + 1))); 378 | 379 | if (!_heap) // allocation failed 380 | { 381 | memcpy(_stack, message, sizeof(char) * (size - 1)); // stack fallback, truncate :/ 382 | _stack[size - 1] = 0; 383 | } 384 | else 385 | { 386 | memcpy(_heap, message, sizeof(char) * length); // copy the message 387 | _heap[length] = 0; 388 | _stack[size - 1] = 1; // mark the stack 389 | } 390 | } 391 | 392 | _file = rhs._file; 393 | _line = rhs._line; 394 | _function = rhs._function; 395 | _expression = rhs._expression; 396 | 397 | return *this; 398 | } 399 | 400 | const char* AssertionException::what() const PPK_ASSERT_EXCEPTION_NO_THROW 401 | { 402 | return _stack[size - 1] ? _heap : _stack; 403 | } 404 | 405 | namespace implementation { 406 | 407 | namespace { 408 | bool _ignoreAll = false; 409 | } 410 | 411 | void PPK_ASSERT_CALL ignoreAllAsserts(bool value) 412 | { 413 | _ignoreAll = value; 414 | } 415 | 416 | bool PPK_ASSERT_CALL ignoreAllAsserts() 417 | { 418 | return _ignoreAll; 419 | } 420 | 421 | namespace { 422 | AssertHandler _handler = _defaultHandler; 423 | } 424 | 425 | AssertHandler PPK_ASSERT_CALL setAssertHandler(AssertHandler handler) 426 | { 427 | AssertHandler previous = _handler; 428 | 429 | _handler = handler ? handler : _defaultHandler; 430 | 431 | return previous; 432 | } 433 | 434 | AssertAction::AssertAction PPK_ASSERT_CALL handleAssert(const char* file, 435 | int line, 436 | const char* function, 437 | const char* expression, 438 | int level, 439 | bool* ignoreLine, 440 | const char* message, ...) 441 | { 442 | char message_[PPK_ASSERT_MESSAGE_BUFFER_SIZE] = {0}; 443 | const char* file_; 444 | 445 | if (message) 446 | { 447 | va_list args; 448 | va_start(args, message); 449 | vsnprintf(message_, PPK_ASSERT_MESSAGE_BUFFER_SIZE, message, args); 450 | va_end(args); 451 | 452 | message = message_; 453 | } 454 | 455 | #if defined(_WIN32) 456 | file_ = strrchr(file, '\\'); 457 | #else 458 | file_ = strrchr(file, '/'); 459 | #endif // #if defined(_WIN32) 460 | 461 | file = file_ ? file_ + 1 : file; 462 | AssertAction::AssertAction action = _handler(file, line, function, expression, level, message); 463 | 464 | switch (action) 465 | { 466 | case AssertAction::Abort: 467 | PPK_ASSERT_ABORT(); 468 | 469 | #if !defined(PPK_ASSERT_DISABLE_IGNORE_LINE) 470 | case AssertAction::IgnoreLine: 471 | *ignoreLine = true; 472 | break; 473 | #else 474 | PPK_ASSERT_UNUSED(ignoreLine); 475 | #endif 476 | 477 | case AssertAction::IgnoreAll: 478 | ignoreAllAsserts(true); 479 | break; 480 | 481 | case AssertAction::Throw: 482 | _throw(file, line, function, expression, message); 483 | break; 484 | 485 | case AssertAction::Ignore: 486 | case AssertAction::Break: 487 | case AssertAction::None: 488 | default: 489 | return action; 490 | } 491 | 492 | return AssertAction::None; 493 | } 494 | 495 | } // namespace implementation 496 | } // namespace assert 497 | } // namespace ppk 498 | -------------------------------------------------------------------------------- /src/ppk_assert.h: -------------------------------------------------------------------------------- 1 | // see README.md for usage instructions. 2 | // (‑●‑●)> released under the WTFPL v2 license, by Gregory Pakosz (@gpakosz) 3 | 4 | // -- usage -------------------------------------------------------------------- 5 | /* 6 | 7 | run-time assertions: 8 | 9 | PPK_ASSERT(expression); 10 | PPK_ASSERT(expression, message, ...); 11 | 12 | PPK_ASSERT_WARNING(expression); 13 | PPK_ASSERT_WARNING(expression, message, ...); 14 | 15 | PPK_ASSERT_DEBUG(expression); 16 | PPK_ASSERT_DEBUG(expression, message, ...); 17 | 18 | PPK_ASSERT_ERROR(expression); 19 | PPK_ASSERT_ERROR(expression, message); 20 | 21 | PPK_ASSERT_FATAL(expression); 22 | PPK_ASSERT_FATAL(expression, message, ...); 23 | 24 | PPK_ASSERT_CUSTOM(level, expression); 25 | PPK_ASSERT_CUSTOM(level, expression, message, ...); 26 | 27 | PPK_ASSERT_USED(type) 28 | PPK_ASSERT_USED_WARNING(type) 29 | PPK_ASSERT_USED_DEBUG(type) 30 | PPK_ASSERT_USED_ERROR(type) 31 | PPK_ASSERT_USED_FATAL(type) 32 | PPK_ASSERT_USED_CUSTOM(level, type) 33 | 34 | PPK_ASSERT_USED(bool) foo() 35 | { 36 | return true; 37 | } 38 | 39 | compile-time assertions: 40 | 41 | PPK_STATIC_ASSERT(expression) 42 | PPK_STATIC_ASSERT(expression, message) 43 | 44 | */ 45 | 46 | #if !defined(PPK_ASSERT_ENABLED) 47 | #if !defined(NDEBUG) // if we are in debug mode 48 | #define PPK_ASSERT_ENABLED 1 // enable them 49 | #endif 50 | #endif 51 | 52 | #if !defined(PPK_ASSERT_DEFAULT_LEVEL) 53 | #define PPK_ASSERT_DEFAULT_LEVEL Debug 54 | #endif 55 | 56 | // -- implementation ----------------------------------------------------------- 57 | 58 | #if (defined(__GNUC__) && ((__GNUC__ * 1000 + __GNUC_MINOR__ * 100) >= 4600)) || defined(__clang__) 59 | #pragma GCC diagnostic push 60 | #pragma GCC diagnostic ignored "-Wvariadic-macros" 61 | #endif 62 | 63 | #if defined(__clang__) 64 | #pragma GCC diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" 65 | #endif 66 | 67 | #if !defined(PPK_ASSERT_H) 68 | #define PPK_ASSERT_H 69 | 70 | #define PPK_ASSERT(...) PPK_ASSERT_(ppk::assert::implementation::AssertLevel::PPK_ASSERT_DEFAULT_LEVEL, __VA_ARGS__) 71 | #define PPK_ASSERT_WARNING(...) PPK_ASSERT_(ppk::assert::implementation::AssertLevel::Warning, __VA_ARGS__) 72 | #define PPK_ASSERT_DEBUG(...) PPK_ASSERT_(ppk::assert::implementation::AssertLevel::Debug, __VA_ARGS__) 73 | #define PPK_ASSERT_ERROR(...) PPK_ASSERT_(ppk::assert::implementation::AssertLevel::Error, __VA_ARGS__) 74 | #define PPK_ASSERT_FATAL(...) PPK_ASSERT_(ppk::assert::implementation::AssertLevel::Fatal, __VA_ARGS__) 75 | #define PPK_ASSERT_CUSTOM(level, ...) PPK_ASSERT_(level, __VA_ARGS__) 76 | 77 | #define PPK_ASSERT_USED(...) PPK_ASSERT_USED_(__VA_ARGS__) 78 | #define PPK_ASSERT_USED_WARNING(...) PPK_ASSERT_USED_(ppk::assert::implementation::AssertLevel::Warning, __VA_ARGS__) 79 | #define PPK_ASSERT_USED_DEBUG(...) PPK_ASSERT_USED_(ppk::assert::implementation::AssertLevel::Debug, __VA_ARGS__) 80 | #define PPK_ASSERT_USED_ERROR(...) PPK_ASSERT_USED_(ppk::assert::implementation::AssertLevel::Error, __VA_ARGS__) 81 | #define PPK_ASSERT_USED_FATAL(...) PPK_ASSERT_USED_(ppk::assert::implementation::AssertLevel::Fatal, __VA_ARGS__) 82 | #define PPK_ASSERT_USED_CUSTOM(level, ...) PPK_ASSERT_USED_(level, __VA_ARGS__) 83 | 84 | 85 | #define PPK_ASSERT_JOIN(lhs, rhs) PPK_ASSERT_JOIN_(lhs, rhs) 86 | #define PPK_ASSERT_JOIN_(lhs, rhs) PPK_ASSERT_JOIN__(lhs, rhs) 87 | #define PPK_ASSERT_JOIN__(lhs, rhs) lhs##rhs 88 | 89 | #define PPK_ASSERT_FILE __FILE__ 90 | #define PPK_ASSERT_LINE __LINE__ 91 | #if defined(__GNUC__) || defined(__clang__) 92 | #define PPK_ASSERT_FUNCTION __PRETTY_FUNCTION__ 93 | #elif defined(_MSC_VER) 94 | #define PPK_ASSERT_FUNCTION __FUNCSIG__ 95 | #elif defined(__SUNPRO_CC) 96 | #define PPK_ASSERT_FUNCTION __func__ 97 | #else 98 | #define PPK_ASSERT_FUNCTION __FUNCTION__ 99 | #endif 100 | 101 | #if defined(_MSC_VER) 102 | #define PPK_ASSERT_ALWAYS_INLINE __forceinline 103 | #elif defined(__GNUC__) || defined(__clang__) 104 | #define PPK_ASSERT_ALWAYS_INLINE inline __attribute__((always_inline)) 105 | #else 106 | #define PPK_ASSERT_ALWAYS_INLINE inline 107 | #endif 108 | 109 | #define PPK_ASSERT_NO_MACRO 110 | 111 | #define PPK_ASSERT_APPLY_VA_ARGS(M, ...) PPK_ASSERT_APPLY_VA_ARGS_(M, (__VA_ARGS__)) 112 | #define PPK_ASSERT_APPLY_VA_ARGS_(M, args) M args 113 | 114 | #define PPK_ASSERT_NARG(...) PPK_ASSERT_APPLY_VA_ARGS(PPK_ASSERT_NARG_, PPK_ASSERT_NO_MACRO,##__VA_ARGS__,\ 115 | 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 18, 17, 16,\ 116 | 15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0, PPK_ASSERT_NO_MACRO) 117 | #define PPK_ASSERT_NARG_( _0, _1, _2, _3, _4, _5, _6, _7, _8,\ 118 | _9, _10, _11, _12, _13, _14, _15, _16,\ 119 | _17, _18, _19, _20, _21, _22, _23, _24,\ 120 | _25, _26, _27, _28, _29, _30, _31, _32, _33, ...) _33 121 | 122 | #define PPK_ASSERT_HAS_ONE_ARG(...) PPK_ASSERT_APPLY_VA_ARGS(PPK_ASSERT_NARG_, PPK_ASSERT_NO_MACRO,##__VA_ARGS__,\ 123 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,\ 124 | 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, PPK_ASSERT_NO_MACRO) 125 | 126 | #if defined(__GNUC__) || defined(__clang__) 127 | #define PPK_ASSERT_LIKELY(arg) __builtin_expect(!!(arg), !0) 128 | #define PPK_ASSERT_UNLIKELY(arg) __builtin_expect(!!(arg), 0) 129 | #else 130 | #define PPK_ASSERT_LIKELY(arg) (arg) 131 | #define PPK_ASSERT_UNLIKELY(arg) (arg) 132 | #endif 133 | 134 | #define PPK_ASSERT_UNUSED(expression) (void)(true ? (void)0 : ((void)(expression))) 135 | 136 | #if !defined(PPK_ASSERT_DEBUG_BREAK) 137 | #if defined(_WIN32) 138 | extern void __cdecl __debugbreak(void); 139 | #define PPK_ASSERT_DEBUG_BREAK() __debugbreak() 140 | #else 141 | #if defined(__APPLE__) 142 | #include 143 | #endif 144 | #if defined(__clang__) && !TARGET_OS_IPHONE || TARGET_IPHONE_SIMULATOR 145 | #define PPK_ASSERT_DEBUG_BREAK() __builtin_debugtrap() 146 | #elif defined(linux) || defined(__linux) || defined(__linux__) || defined(__APPLE__) 147 | #include 148 | #define PPK_ASSERT_DEBUG_BREAK() raise(SIGTRAP) 149 | #elif defined(__GNUC__) 150 | #define PPK_ASSERT_DEBUG_BREAK() __builtin_trap() 151 | #else 152 | #define PPK_ASSERT_DEBUG_BREAK() ((void)0) 153 | #endif 154 | #endif 155 | #endif 156 | 157 | #if (defined (__cplusplus) && (__cplusplus > 199711L)) || (defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 150020706)) 158 | #define PPK_ASSERT_CXX11 159 | #endif 160 | 161 | #if defined(PPK_ASSERT_CXX11) 162 | #define PPK_ASSERT_NULLPTR nullptr 163 | #else 164 | #define PPK_ASSERT_NULLPTR 0 165 | #endif 166 | 167 | #define PPK_ASSERT_(level, ...) PPK_ASSERT_JOIN(PPK_ASSERT_, PPK_ASSERT_HAS_ONE_ARG(__VA_ARGS__))(level, __VA_ARGS__) 168 | #define PPK_ASSERT_0(level, ...) PPK_ASSERT_APPLY_VA_ARGS(PPK_ASSERT_2, level, __VA_ARGS__) 169 | #define PPK_ASSERT_1(level, expression) PPK_ASSERT_2(level, expression, PPK_ASSERT_NULLPTR) 170 | 171 | #if defined(_MSC_FULL_VER) && (_MSC_FULL_VER >= 140050215) 172 | 173 | #if defined(PPK_ASSERT_DISABLE_IGNORE_LINE) 174 | 175 | #define PPK_ASSERT_3(level, expression, ...)\ 176 | __pragma(warning(push))\ 177 | __pragma(warning(disable: 4127))\ 178 | do\ 179 | {\ 180 | if (PPK_ASSERT_LIKELY(expression) || ppk::assert::implementation::ignoreAllAsserts());\ 181 | else\ 182 | {\ 183 | if (ppk::assert::implementation::handleAssert(PPK_ASSERT_FILE, PPK_ASSERT_LINE, PPK_ASSERT_FUNCTION, #expression, level, PPK_ASSERT_NULLPTR, __VA_ARGS__) == ppk::assert::implementation::AssertAction::Break)\ 184 | PPK_ASSERT_DEBUG_BREAK();\ 185 | }\ 186 | }\ 187 | while (false)\ 188 | __pragma(warning(pop)) 189 | 190 | #else 191 | 192 | #define PPK_ASSERT_3(level, expression, ...)\ 193 | __pragma(warning(push))\ 194 | __pragma(warning(disable: 4127))\ 195 | do\ 196 | {\ 197 | static bool _ignore = false;\ 198 | if (PPK_ASSERT_LIKELY(expression) || _ignore || ppk::assert::implementation::ignoreAllAsserts());\ 199 | else\ 200 | {\ 201 | if (ppk::assert::implementation::handleAssert(PPK_ASSERT_FILE, PPK_ASSERT_LINE, PPK_ASSERT_FUNCTION, #expression, level, &_ignore, __VA_ARGS__) == ppk::assert::implementation::AssertAction::Break)\ 202 | PPK_ASSERT_DEBUG_BREAK();\ 203 | }\ 204 | }\ 205 | while (false)\ 206 | __pragma(warning(pop)) 207 | 208 | #endif 209 | 210 | #else 211 | 212 | #if (defined(__GNUC__) && ((__GNUC__ * 1000 + __GNUC_MINOR__ * 100) >= 4600)) || defined(__clang__) 213 | #define _pragma(x) _Pragma(#x) 214 | #define _PPK_ASSERT_WFORMAT_AS_ERROR_BEGIN\ 215 | _pragma(GCC diagnostic push)\ 216 | _pragma(GCC diagnostic error "-Wformat") 217 | #define _PPK_ASSERT_WFORMAT_AS_ERROR_END\ 218 | _pragma(GCC diagnostic pop) 219 | #else 220 | #define _PPK_ASSERT_WFORMAT_AS_ERROR_BEGIN 221 | #define _PPK_ASSERT_WFORMAT_AS_ERROR_END 222 | #endif 223 | 224 | #if defined(PPK_ASSERT_DISABLE_IGNORE_LINE) 225 | 226 | #define PPK_ASSERT_3(level, expression, ...)\ 227 | do\ 228 | {\ 229 | if (PPK_ASSERT_LIKELY(expression) || ppk::assert::implementation::ignoreAllAsserts());\ 230 | else\ 231 | {\ 232 | _PPK_ASSERT_WFORMAT_AS_ERROR_BEGIN\ 233 | if (ppk::assert::implementation::handleAssert(PPK_ASSERT_FILE, PPK_ASSERT_LINE, PPK_ASSERT_FUNCTION, #expression, level, PPK_ASSERT_NULLPTR, __VA_ARGS__) == ppk::assert::implementation::AssertAction::Break)\ 234 | PPK_ASSERT_DEBUG_BREAK();\ 235 | _PPK_ASSERT_WFORMAT_AS_ERROR_END\ 236 | }\ 237 | }\ 238 | while (false) 239 | 240 | #else 241 | 242 | #define PPK_ASSERT_3(level, expression, ...)\ 243 | do\ 244 | {\ 245 | static bool _ignore = false;\ 246 | if (PPK_ASSERT_LIKELY(expression) || _ignore || ppk::assert::implementation::ignoreAllAsserts());\ 247 | else\ 248 | {\ 249 | _PPK_ASSERT_WFORMAT_AS_ERROR_BEGIN\ 250 | if (ppk::assert::implementation::handleAssert(PPK_ASSERT_FILE, PPK_ASSERT_LINE, PPK_ASSERT_FUNCTION, #expression, level, &_ignore, __VA_ARGS__) == ppk::assert::implementation::AssertAction::Break)\ 251 | PPK_ASSERT_DEBUG_BREAK();\ 252 | _PPK_ASSERT_WFORMAT_AS_ERROR_END\ 253 | }\ 254 | }\ 255 | while (false) 256 | 257 | #endif 258 | 259 | #endif 260 | 261 | #define PPK_ASSERT_USED_(...) PPK_ASSERT_USED_0(PPK_ASSERT_NARG(__VA_ARGS__), __VA_ARGS__) 262 | #define PPK_ASSERT_USED_0(N, ...) PPK_ASSERT_JOIN(PPK_ASSERT_USED_, N)(__VA_ARGS__) 263 | 264 | #define PPK_STATIC_ASSERT(...) PPK_ASSERT_APPLY_VA_ARGS(PPK_ASSERT_JOIN(PPK_STATIC_ASSERT_, PPK_ASSERT_HAS_ONE_ARG(__VA_ARGS__)), __VA_ARGS__) 265 | #if defined(PPK_ASSERT_CXX11) 266 | #define PPK_STATIC_ASSERT_0(expression, message) static_assert(expression, message) 267 | #else 268 | #define PPK_STATIC_ASSERT_0(expression, message)\ 269 | struct PPK_ASSERT_JOIN(_ppk_static_assertion_at_line_, PPK_ASSERT_LINE)\ 270 | {\ 271 | ppk::assert::implementation::StaticAssertion((expression))> PPK_ASSERT_JOIN(STATIC_ASSERTION_FAILED_AT_LINE_, PPK_ASSERT_LINE);\ 272 | };\ 273 | typedef ppk::assert::implementation::StaticAssertionTest PPK_ASSERT_JOIN(_ppk_static_assertion_test_at_line_, PPK_ASSERT_LINE) 274 | // note that we wrap the non existing type inside a struct to avoid warning 275 | // messages about unused variables when static assertions are used at function 276 | // scope 277 | // the use of sizeof makes sure the assertion error is not ignored by SFINAE 278 | #endif 279 | #define PPK_STATIC_ASSERT_1(expression) PPK_STATIC_ASSERT_0(expression, #expression) 280 | 281 | #if !defined (PPK_ASSERT_CXX11) 282 | namespace ppk { 283 | namespace assert { 284 | namespace implementation { 285 | 286 | template 287 | struct StaticAssertion; 288 | 289 | template <> 290 | struct StaticAssertion 291 | { 292 | }; // StaticAssertion 293 | 294 | template 295 | struct StaticAssertionTest 296 | { 297 | }; // StaticAssertionTest 298 | 299 | } // namespace implementation 300 | } // namespace assert 301 | } // namespace ppk 302 | #endif 303 | 304 | #if !defined(PPK_ASSERT_DISABLE_STL) 305 | #if defined(_MSC_VER) 306 | #pragma warning(push) 307 | #pragma warning(disable: 4548) 308 | #pragma warning(disable: 4710) 309 | #endif 310 | #include 311 | #if defined(_MSC_VER) 312 | #pragma warning(pop) 313 | #endif 314 | #endif 315 | 316 | #if !defined(PPK_ASSERT_EXCEPTION_MESSAGE_BUFFER_SIZE) 317 | #define PPK_ASSERT_EXCEPTION_MESSAGE_BUFFER_SIZE 1024 318 | #endif 319 | 320 | #if defined(PPK_ASSERT_CXX11) && !defined(_MSC_VER) 321 | #define PPK_ASSERT_EXCEPTION_NO_THROW noexcept(true) 322 | #else 323 | #define PPK_ASSERT_EXCEPTION_NO_THROW throw() 324 | #endif 325 | 326 | #if defined(PPK_ASSERT_CXX11) 327 | #include 328 | #endif 329 | 330 | namespace ppk { 331 | namespace assert { 332 | 333 | #if !defined(PPK_ASSERT_DISABLE_STL) 334 | class AssertionException: public std::exception 335 | #else 336 | class AssertionException 337 | #endif 338 | { 339 | public: 340 | explicit AssertionException(const char* file, 341 | int line, 342 | const char* function, 343 | const char* expression, 344 | const char* message); 345 | 346 | AssertionException(const AssertionException& rhs); 347 | 348 | virtual ~AssertionException() PPK_ASSERT_EXCEPTION_NO_THROW; 349 | 350 | AssertionException& operator = (const AssertionException& rhs); 351 | 352 | virtual const char* what() const PPK_ASSERT_EXCEPTION_NO_THROW; 353 | 354 | const char* file() const; 355 | int line() const; 356 | const char* function() const; 357 | const char* expression() const; 358 | 359 | private: 360 | const char* _file; 361 | int _line; 362 | const char* _function; 363 | const char* _expression; 364 | 365 | enum 366 | { 367 | request = PPK_ASSERT_EXCEPTION_MESSAGE_BUFFER_SIZE, 368 | size = request > sizeof(char*) ? request : sizeof(char*) + 1 369 | }; 370 | 371 | union 372 | { 373 | char _stack[size]; 374 | char* _heap; 375 | }; 376 | 377 | PPK_STATIC_ASSERT(size > sizeof(char*), "invalid_size"); 378 | }; // AssertionException 379 | 380 | PPK_ASSERT_ALWAYS_INLINE const char* AssertionException::file() const 381 | { 382 | return _file; 383 | } 384 | 385 | PPK_ASSERT_ALWAYS_INLINE int AssertionException::line() const 386 | { 387 | return _line; 388 | } 389 | 390 | PPK_ASSERT_ALWAYS_INLINE const char* AssertionException::function() const 391 | { 392 | return _function; 393 | } 394 | 395 | PPK_ASSERT_ALWAYS_INLINE const char* AssertionException::expression() const 396 | { 397 | return _expression; 398 | } 399 | 400 | namespace implementation { 401 | 402 | #if defined(_MSC_VER) && !defined(_CPPUNWIND) 403 | #if !defined(PPK_ASSERT_DISABLE_EXCEPTIONS) 404 | #define PPK_ASSERT_DISABLE_EXCEPTIONS 405 | #endif 406 | #endif 407 | 408 | #if !defined(PPK_ASSERT_DISABLE_EXCEPTIONS) 409 | 410 | template 411 | inline void throwException(const E& e) 412 | { 413 | throw e; 414 | } 415 | 416 | #else 417 | 418 | // user defined, the behavior is undefined if the function returns 419 | void throwException(const ppk::assert::AssertionException& e); 420 | 421 | #endif 422 | 423 | namespace AssertLevel { 424 | 425 | enum AssertLevel 426 | { 427 | Warning = 32, 428 | Debug = 64, 429 | Error = 128, 430 | Fatal = 256 431 | 432 | }; // AssertLevel 433 | 434 | } // AssertLevel 435 | 436 | namespace AssertAction { 437 | 438 | enum AssertAction 439 | { 440 | None, 441 | Abort, 442 | Break, 443 | Ignore, 444 | #if !defined(PPK_ASSERT_DISABLE_IGNORE_LINE) 445 | IgnoreLine, 446 | #endif 447 | IgnoreAll, 448 | Throw 449 | 450 | }; // AssertAction 451 | 452 | } // AssertAction 453 | 454 | #if !defined(PPK_ASSERT_CALL) 455 | #define PPK_ASSERT_CALL 456 | #endif 457 | 458 | typedef AssertAction::AssertAction (PPK_ASSERT_CALL *AssertHandler)(const char* file, 459 | int line, 460 | const char* function, 461 | const char* expression, 462 | int level, 463 | const char* message); 464 | 465 | 466 | #if defined(__GNUC__) || defined(__clang__) 467 | #define PPK_ASSERT_HANDLE_ASSERT_FORMAT __attribute__((format (printf, 7, 8))) 468 | #else 469 | #define PPK_ASSERT_HANDLE_ASSERT_FORMAT 470 | #endif 471 | 472 | #if !defined(PPK_ASSERT_FUNCSPEC) 473 | #define PPK_ASSERT_FUNCSPEC 474 | #endif 475 | 476 | PPK_ASSERT_FUNCSPEC 477 | AssertAction::AssertAction PPK_ASSERT_CALL handleAssert(const char* file, 478 | int line, 479 | const char* function, 480 | const char* expression, 481 | int level, 482 | bool* ignoreLine, 483 | const char* message, ...) PPK_ASSERT_HANDLE_ASSERT_FORMAT; 484 | 485 | PPK_ASSERT_FUNCSPEC 486 | AssertHandler PPK_ASSERT_CALL setAssertHandler(AssertHandler handler); 487 | 488 | PPK_ASSERT_FUNCSPEC 489 | void PPK_ASSERT_CALL ignoreAllAsserts(bool value); 490 | 491 | PPK_ASSERT_FUNCSPEC 492 | bool PPK_ASSERT_CALL ignoreAllAsserts(); 493 | 494 | #if defined(PPK_ASSERT_CXX11) 495 | 496 | template 497 | class AssertUsedWrapper 498 | { 499 | public: 500 | AssertUsedWrapper(T&& t); 501 | ~AssertUsedWrapper() PPK_ASSERT_EXCEPTION_NO_THROW; 502 | 503 | operator T(); 504 | 505 | private: 506 | const AssertUsedWrapper& operator = (const AssertUsedWrapper&); // not implemented on purpose (and only VS2013 supports deleted functions) 507 | 508 | T t; 509 | mutable bool used; 510 | 511 | }; // AssertUsedWrapper 512 | 513 | template 514 | inline AssertUsedWrapper::AssertUsedWrapper(T&& _t) 515 | : t(std::forward(_t)), used(false) 516 | {} 517 | 518 | template 519 | inline AssertUsedWrapper::operator T() 520 | { 521 | used = true; 522 | return std::move(t); 523 | } 524 | 525 | template 526 | inline AssertUsedWrapper::~AssertUsedWrapper() PPK_ASSERT_EXCEPTION_NO_THROW 527 | { 528 | PPK_ASSERT_3(level, used, "unused value"); 529 | } 530 | 531 | #else 532 | 533 | template 534 | class AssertUsedWrapper 535 | { 536 | public: 537 | AssertUsedWrapper(const T& t); 538 | AssertUsedWrapper(const AssertUsedWrapper& rhs); 539 | ~AssertUsedWrapper() PPK_ASSERT_EXCEPTION_NO_THROW; 540 | 541 | operator T() const; 542 | 543 | private: 544 | const AssertUsedWrapper& operator = (const AssertUsedWrapper&); // not implemented on purpose 545 | 546 | T t; 547 | mutable bool used; 548 | 549 | }; // AssertUsedWrapper 550 | 551 | template 552 | PPK_ASSERT_ALWAYS_INLINE AssertUsedWrapper::AssertUsedWrapper(const T& _t) 553 | : t(_t), used(false) 554 | {} 555 | 556 | template 557 | PPK_ASSERT_ALWAYS_INLINE AssertUsedWrapper::AssertUsedWrapper(const AssertUsedWrapper& rhs) 558 | : t(rhs.t), used(rhs.used) 559 | {} 560 | 561 | // /!\ GCC is not so happy if we inline that destructor 562 | template 563 | AssertUsedWrapper::~AssertUsedWrapper() PPK_ASSERT_EXCEPTION_NO_THROW 564 | { 565 | PPK_ASSERT_3(level, used, "unused value"); 566 | } 567 | 568 | template 569 | PPK_ASSERT_ALWAYS_INLINE AssertUsedWrapper::operator T() const 570 | { 571 | used = true; 572 | return t; 573 | } 574 | 575 | #endif 576 | 577 | } // namespace implementation 578 | 579 | } // namespace assert 580 | } // namespace ppk 581 | 582 | #endif 583 | 584 | #undef PPK_ASSERT_2 585 | #undef PPK_ASSERT_USED_1 586 | #undef PPK_ASSERT_USED_2 587 | 588 | #if defined(_MSC_VER) && defined(_PREFAST_) 589 | 590 | #define PPK_ASSERT_2(level, expression, ...) __analysis_assume(!!(expression)) 591 | #define PPK_ASSERT_USED_1(type) type 592 | #define PPK_ASSERT_USED_2(level, type) type 593 | 594 | #elif defined(__clang__) && defined(__clang_analyzer__) 595 | 596 | void its_going_to_be_ok(bool expression) __attribute__((analyzer_noreturn)); 597 | #define PPK_ASSERT_2(level, expression, ...) its_going_to_be_ok(!!(expression)) 598 | #define PPK_ASSERT_USED_1(type) type 599 | #define PPK_ASSERT_USED_2(level, type) type 600 | 601 | #else 602 | 603 | #if PPK_ASSERT_ENABLED 604 | 605 | #define PPK_ASSERT_2(level, expression, ...) PPK_ASSERT_3(level, expression, __VA_ARGS__) 606 | #define PPK_ASSERT_USED_1(type) ppk::assert::implementation::AssertUsedWrapper 607 | #define PPK_ASSERT_USED_2(level, type) ppk::assert::implementation::AssertUsedWrapper 608 | 609 | #else 610 | 611 | #define PPK_ASSERT_2(level, expression, ...) PPK_ASSERT_UNUSED(expression) 612 | #define PPK_ASSERT_USED_1(type) type 613 | #define PPK_ASSERT_USED_2(level, type) type 614 | 615 | #endif 616 | 617 | #endif 618 | 619 | #if (defined(__GNUC__) && ((__GNUC__ * 1000 + __GNUC_MINOR__ * 100) >= 4600)) || defined(__clang__) 620 | #pragma GCC diagnostic pop 621 | #endif 622 | -------------------------------------------------------------------------------- /test/ppk_assert_test.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #define PPK_ASSERT_ENABLED 1 4 | #include 5 | 6 | #include 7 | #include 8 | 9 | 10 | using namespace ppk::assert; 11 | 12 | namespace { 13 | 14 | namespace implementation = ppk::assert::implementation; 15 | namespace AssertLevel = implementation::AssertLevel; 16 | namespace AssertAction = implementation::AssertAction; 17 | 18 | const char* _file; 19 | int _line; 20 | const char* _function; 21 | const char* _expression; 22 | int _level; 23 | char* _message; 24 | 25 | AssertAction::AssertAction _action = AssertAction::None; 26 | 27 | AssertAction::AssertAction _testHandler(const char* file, 28 | int line, 29 | const char* function, 30 | const char* expression, 31 | int level, 32 | const char* message) 33 | { 34 | _file = file; 35 | _line = line; 36 | _function = function; 37 | _expression = expression; 38 | _level = level; 39 | 40 | if (_message) 41 | free(_message); 42 | 43 | if (message) 44 | _message = strdup(message); 45 | 46 | if (level == AssertLevel::Error) 47 | return AssertAction::Throw; 48 | 49 | return _action; 50 | } 51 | } 52 | 53 | #if defined(PPK_ASSERT_DISABLE_EXCEPTIONS) 54 | namespace ppk { 55 | namespace assert { 56 | namespace implementation { 57 | 58 | void throwException(const ppk::assert::AssertionException& e) 59 | { 60 | _file = e.file(); 61 | _line = e.line(); 62 | _function = e.function(); 63 | _expression = e.expression(); 64 | _level = AssertLevel::Error; 65 | } 66 | 67 | } // namespace implementation 68 | } // namespace assert 69 | } // namespace ppk 70 | #endif 71 | 72 | namespace { 73 | 74 | class AssertTest : public ::testing::Test 75 | { 76 | protected: 77 | explicit AssertTest() 78 | { 79 | implementation::setAssertHandler(_testHandler); 80 | _action = AssertAction::None; 81 | 82 | _message = 0; 83 | } 84 | 85 | ~AssertTest() 86 | { 87 | implementation::setAssertHandler(PPK_ASSERT_NULLPTR); 88 | 89 | if (_message) 90 | free(_message); 91 | 92 | _message = 0; 93 | } 94 | 95 | }; 96 | 97 | TEST_F(AssertTest, ASSERT_WARNING) 98 | { 99 | PPK_ASSERT_WARNING(true); 100 | PPK_ASSERT_WARNING(true, "always true, never fails"); 101 | 102 | PPK_ASSERT_WARNING(false); 103 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 104 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 105 | EXPECT_EQ(AssertLevel::Warning, _level); 106 | EXPECT_STREQ(static_cast(PPK_ASSERT_NULLPTR), _message); 107 | 108 | PPK_ASSERT_WARNING(false, "always false, always fails"); 109 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 110 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 111 | EXPECT_EQ(AssertLevel::Warning, _level); 112 | EXPECT_STREQ("always false, always fails", _message); 113 | 114 | const char* s = "foo"; 115 | int i = 123; 116 | float f = 123.456f; 117 | PPK_ASSERT_WARNING(false, "always false, always fails -- s: %s, i: %d, f: %3.3f", s, i, f); 118 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 119 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 120 | EXPECT_EQ(AssertLevel::Warning, _level); 121 | EXPECT_STREQ("always false, always fails -- s: foo, i: 123, f: 123.456", _message); 122 | } 123 | 124 | TEST_F(AssertTest, ASSERT) 125 | { 126 | PPK_ASSERT(true); 127 | PPK_ASSERT(true, "always true, never fails"); 128 | 129 | PPK_ASSERT(false); 130 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 131 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 132 | EXPECT_EQ(AssertLevel::Debug, _level); 133 | EXPECT_STREQ(static_cast(PPK_ASSERT_NULLPTR), _message); 134 | 135 | PPK_ASSERT(false, "always false, always fails"); 136 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 137 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 138 | EXPECT_EQ(AssertLevel::Debug, _level); 139 | EXPECT_STREQ("always false, always fails", _message); 140 | 141 | const char* s = "foo"; 142 | int i = 123; 143 | float f = 123.456f; 144 | PPK_ASSERT_DEBUG(false, "always false, always fails -- s: %s, i: %d, f: %3.3f", s, i, f); 145 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 146 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 147 | EXPECT_EQ(AssertLevel::Debug, _level); 148 | EXPECT_STREQ("always false, always fails -- s: foo, i: 123, f: 123.456", _message); 149 | } 150 | 151 | TEST_F(AssertTest, ASSERT_DEBUG) 152 | { 153 | PPK_ASSERT_DEBUG(true); 154 | PPK_ASSERT_DEBUG(true, "always true, never fails"); 155 | 156 | PPK_ASSERT_DEBUG(false); 157 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 158 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 159 | EXPECT_EQ(AssertLevel::Debug, _level); 160 | EXPECT_STREQ(static_cast(PPK_ASSERT_NULLPTR), _message); 161 | 162 | PPK_ASSERT_DEBUG(false, "always false, always fails"); 163 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 164 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 165 | EXPECT_EQ(AssertLevel::Debug, _level); 166 | EXPECT_STREQ("always false, always fails", _message); 167 | 168 | const char* s = "foo"; 169 | int i = 123; 170 | float f = 123.456f; 171 | PPK_ASSERT_DEBUG(false, "always false, always fails -- s: %s, i: %d, f: %3.3f", s, i, f); 172 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 173 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 174 | EXPECT_EQ(AssertLevel::Debug, _level); 175 | EXPECT_STREQ("always false, always fails -- s: foo, i: 123, f: 123.456", _message); 176 | } 177 | 178 | TEST_F(AssertTest, ASSERT_ERROR) 179 | { 180 | PPK_ASSERT_ERROR(true); 181 | PPK_ASSERT_ERROR(true, "always true, never fails"); 182 | 183 | #if defined(PPK_ASSERT_DISABLE_EXCEPTIONS) 184 | PPK_ASSERT_ERROR(false); 185 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 186 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 187 | EXPECT_EQ(AssertLevel::Error, _level); 188 | EXPECT_STREQ(static_cast(PPK_ASSERT_NULLPTR), _message); 189 | #else 190 | EXPECT_THROW(PPK_ASSERT_ERROR(false), AssertionException); 191 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 192 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 193 | EXPECT_EQ(AssertLevel::Error, _level); 194 | EXPECT_STREQ(static_cast(PPK_ASSERT_NULLPTR), _message); 195 | #endif 196 | 197 | #if defined(PPK_ASSERT_DISABLE_EXCEPTIONS) 198 | PPK_ASSERT_ERROR(false, "always false, always fails"); 199 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 200 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 201 | EXPECT_EQ(AssertLevel::Error, _level); 202 | EXPECT_STREQ("always false, always fails", _message); 203 | #else 204 | EXPECT_THROW(PPK_ASSERT_ERROR(false, "always false, always fails"), AssertionException); 205 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 206 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 207 | EXPECT_EQ(AssertLevel::Error, _level); 208 | EXPECT_STREQ("always false, always fails", _message); 209 | #endif 210 | 211 | const char* s = "foo"; 212 | int i = 123; 213 | float f = 123.456f; 214 | #if defined(PPK_ASSERT_DISABLE_EXCEPTIONS) 215 | PPK_ASSERT_ERROR(false, "always false, always fails -- s: %s, i: %d, f: %3.3f", s, i, f); 216 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 217 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 218 | EXPECT_EQ(AssertLevel::Error, _level); 219 | EXPECT_STREQ("always false, always fails -- s: foo, i: 123, f: 123.456", _message); 220 | #else 221 | EXPECT_THROW(PPK_ASSERT_ERROR(false, "always false, always fails -- s: %s, i: %d, f: %3.3f", s, i, f), AssertionException); 222 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 223 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 224 | EXPECT_EQ(AssertLevel::Error, _level); 225 | EXPECT_STREQ("always false, always fails -- s: foo, i: 123, f: 123.456", _message); 226 | #endif 227 | } 228 | 229 | TEST_F(AssertTest, ASSERT_FATAL) 230 | { 231 | PPK_ASSERT_FATAL(true); 232 | PPK_ASSERT_FATAL(true, "always true, never fails"); 233 | 234 | PPK_ASSERT_FATAL(false); 235 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 236 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 237 | EXPECT_EQ(AssertLevel::Fatal, _level); 238 | EXPECT_STREQ(static_cast(PPK_ASSERT_NULLPTR), _message); 239 | 240 | PPK_ASSERT_FATAL(false, "always false, always fails"); 241 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 242 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 243 | EXPECT_EQ(AssertLevel::Fatal, _level); 244 | EXPECT_STREQ("always false, always fails", _message); 245 | 246 | const char* s = "foo"; 247 | int i = 123; 248 | float f = 123.456f; 249 | PPK_ASSERT_FATAL(false, "always false, always fails -- s: %s, i: %d, f: %3.3f", s, i, f); 250 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 251 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 252 | EXPECT_EQ(AssertLevel::Fatal, _level); 253 | EXPECT_STREQ("always false, always fails -- s: foo, i: 123, f: 123.456", _message); 254 | 255 | implementation::setAssertHandler(PPK_ASSERT_NULLPTR); 256 | 257 | // 3rd parameter of EXPECT_DEATH is a regex 258 | EXPECT_DEATH_IF_SUPPORTED(PPK_ASSERT_FATAL(false), ""); 259 | EXPECT_DEATH_IF_SUPPORTED(PPK_ASSERT_FATAL(false, "always false, always fails"), "always false, always fails"); 260 | } 261 | 262 | TEST_F(AssertTest, ASSERT_CustomLevel) 263 | { 264 | PPK_ASSERT_CUSTOM(1337, true); 265 | PPK_ASSERT_CUSTOM(1337, true, "always true, never fails"); 266 | 267 | PPK_ASSERT_CUSTOM(1337, false); 268 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 269 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 270 | EXPECT_EQ(1337, _level); 271 | EXPECT_STREQ(static_cast(PPK_ASSERT_NULLPTR), _message); 272 | 273 | PPK_ASSERT_CUSTOM(1337, false, "always false, always fails"); 274 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 275 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 276 | EXPECT_EQ(1337, _level); 277 | EXPECT_STREQ("always false, always fails", _message); 278 | 279 | const char* s = "foo"; 280 | int i = 123; 281 | float f = 123.456f; 282 | PPK_ASSERT_CUSTOM(1337, false, "always false, always fails -- s: %s, i: %d, f: %3.3f", s, i, f); 283 | EXPECT_STREQ("ppk_assert_test.cpp", _file); 284 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 285 | EXPECT_EQ(1337, _level); 286 | EXPECT_STREQ("always false, always fails -- s: foo, i: 123, f: 123.456", _message); 287 | } 288 | 289 | TEST_F(AssertTest, ignoreLine) 290 | { 291 | struct Local 292 | { 293 | static void f() 294 | { 295 | PPK_ASSERT(false); 296 | } 297 | }; 298 | 299 | _action = AssertAction::IgnoreLine; 300 | 301 | Local::f(); 302 | EXPECT_EQ(PPK_ASSERT_LINE - 7, _line); 303 | 304 | PPK_ASSERT(false); 305 | Local::f(); // should be ignored the second time 306 | EXPECT_EQ(PPK_ASSERT_LINE - 2, _line); 307 | } 308 | 309 | TEST_F(AssertTest, ignoreAll) 310 | { 311 | struct Local 312 | { 313 | static void f() 314 | { 315 | PPK_ASSERT(false); 316 | } 317 | }; 318 | 319 | _action = AssertAction::IgnoreAll; 320 | 321 | PPK_ASSERT(false); 322 | EXPECT_EQ(PPK_ASSERT_LINE - 1, _line); 323 | 324 | PPK_ASSERT(false); 325 | EXPECT_EQ(PPK_ASSERT_LINE - 4, _line); 326 | 327 | Local::f(); 328 | EXPECT_EQ(PPK_ASSERT_LINE - 7, _line); 329 | 330 | implementation::ignoreAllAsserts(false); 331 | #if defined(PPK_ASSERT_DISABLE_EXCEPTIONS) 332 | PPK_ASSERT_ERROR(false); 333 | #else 334 | EXPECT_THROW(PPK_ASSERT_ERROR(false), AssertionException); 335 | #endif 336 | } 337 | 338 | PPK_ASSERT_USED(bool) testBoolUsed() 339 | { 340 | return true; 341 | } 342 | 343 | PPK_ASSERT_USED_FATAL(bool) testBoolUsedFatal() 344 | { 345 | return true; 346 | } 347 | 348 | struct Struct 349 | { 350 | Struct() 351 | : count(0) 352 | {} 353 | 354 | Struct(const Struct& rhs) 355 | : count(rhs.count + 1) 356 | {} 357 | 358 | int count; 359 | }; 360 | 361 | PPK_ASSERT_USED(Struct) testStructUsed() 362 | { 363 | return Struct(); 364 | } 365 | 366 | PPK_ASSERT_USED_FATAL(Struct) testStructUsedFatal() 367 | { 368 | return Struct(); 369 | } 370 | 371 | TEST_F(AssertTest, ASSERT_USED) 372 | { 373 | { 374 | bool b = testBoolUsed(); 375 | EXPECT_TRUE(b); 376 | } 377 | 378 | { 379 | testBoolUsed(); 380 | } 381 | EXPECT_EQ(_level, AssertLevel::Debug); 382 | EXPECT_STREQ(_message, "unused value"); 383 | 384 | { 385 | bool b = testBoolUsedFatal(); 386 | EXPECT_TRUE(b); 387 | } 388 | 389 | { 390 | testBoolUsedFatal(); 391 | } 392 | EXPECT_EQ(_level, AssertLevel::Fatal); 393 | EXPECT_STREQ(_message, "unused value"); 394 | 395 | #if defined(_MSC_VER) 396 | # pragma warning(push) 397 | # pragma warning(disable: 4928) // illegal copy-initialization; more than one 398 | // user-defined conversion has been implicitly 399 | // applied 400 | #endif 401 | { 402 | Struct s = testStructUsed(); 403 | EXPECT_LE(2, s.count); 404 | } 405 | 406 | { 407 | testStructUsed(); 408 | } 409 | EXPECT_EQ(_level, AssertLevel::Debug); 410 | EXPECT_STREQ(_message, "unused value"); 411 | 412 | { 413 | Struct s = testStructUsedFatal(); 414 | EXPECT_LE(2, s.count); 415 | } 416 | 417 | { 418 | testStructUsedFatal(); 419 | } 420 | EXPECT_EQ(_level, AssertLevel::Fatal); 421 | EXPECT_STREQ(_message, "unused value"); 422 | 423 | #if defined(_MSC_VER) 424 | # pragma warning(pop) 425 | #endif 426 | } 427 | } 428 | 429 | #if defined(_WIN32) 430 | #include 431 | #endif 432 | 433 | GTEST_API_ int main(int argc, char **argv) 434 | { 435 | testing::InitGoogleTest(&argc, argv); 436 | 437 | #if defined(_WIN32) 438 | _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); 439 | _CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE); 440 | _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE); 441 | _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); 442 | _CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR); 443 | _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR); 444 | #endif 445 | 446 | return RUN_ALL_TESTS(); 447 | } 448 | --------------------------------------------------------------------------------