Skip to content

olegsych/simply.assert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

simply::assert

A small C++ library for asserting in unit tests. It was born out of frustration with the CppUnitTest framework used by the Visual Studio Native Unit Test projects and meant to replace its rudimentary Assert class with a TDD-focused, rich, modern assertion APIs comparable to Xunit.Assert's.

use

Add the simply.assert NuGet package to your Visual C++ Native Unit Test project using the Package Manager Console or using the Package Manager Dialog.

Install-Package simply.assert

Include the simply/assert.h header to your C++ file and use the simply namespace.

#include <simply/assert.h>
using namespace simply;

Use assert functions.

// fail (with overloads for std::string and std::wstring)
assert::fail("foo");

// bool
assert::is_true(true);
assert::is_false(false);

// equality
assert::is_equal(42, 42);
assert::is_not_equal(0, 42);

// exceptions
unique_ptr<exception> e = assert::throws<exception>([] { throw exception("foo"}; );

// null (with overloads for typed and void pointers)
assert::is_null(nullptr);
assert::is_not_null(reinterpret_cast<void*>(0x42));

// string (with overloads for string, wstring, char* and wchar_t*)
size_t position = assert::find("bar", "foo bar baz");
assert::is_equal("foo", "foo");
assert::is_not_equal("foo", "bar");

// type traits
assert::is_abstract<foo>();
assert::is_base_of<foo, bar>();
assert::is_concrete<foo>();
assert::is_convertible<from, to>(bool expected = true);
assert::is_copy_assignable<foo>();
assert::is_copy_constructible<foo>();
assert::is_destructible();
assert::is_same<foo, foo>();

build

Build status

From Visual Studio 2017:

  • Open simply.assert.sln
  • Select Build Solution from the Build menu
  • To switch build between x86 and x64 platforms, select Configuration Manager from the Build menu and change the Active Solution Configuration

From Developer Command Prompt for VS2017:

msbuild simply.assert.sln /p:Platform=x86
msbuild simply.assert.sln /p:Platform=x64

test

From Visual Studio 2015:

  • Select Run / All Tests from the Test menu
  • To switch test execution between x86 and x64 platform, select Test Settings from the Test menu and change the Default Processor Architecture.

From Developer Command Prompt for VS2017:

vstest.console bin\debug\Win32\test.dll /Platform:x86
vstest.console bin\debug\x64\test.dll /Platform:x64 /inIsolation

About

A small C++ library for asserting in unit tests.

Resources

License

Stars

Watchers

Forks

Packages

No packages published