Quellcode durchsuchen

Trompeloeil added (#21).

main
offa vor 7 Jahren
Ursprung
Commit
70b6441ef7
5 geänderte Dateien mit 3833 neuen und 6 gelöschten Zeilen
  1. +4
    -1
      test/CMakeLists.txt
  2. +21
    -5
      test/ScopeGuardTest.cpp
  3. +27
    -0
      test/TestMain.cpp
  4. +23
    -0
      test/trompeloeil/LICENSE_1_0.txt
  5. +3758
    -0
      test/trompeloeil/trompeloeil.hpp

+ 4
- 1
test/CMakeLists.txt Datei anzeigen

@@ -2,9 +2,12 @@
add_library(Catch INTERFACE)
target_include_directories(Catch INTERFACE "catch")

add_library(Trompeloeil INTERFACE)
target_include_directories(Trompeloeil INTERFACE "trompeloeil")


add_library(TestMain TestMain.cpp)
target_link_libraries(TestMain Catch)
target_link_libraries(TestMain Catch Trompeloeil)


function(add_test_suite name)

+ 21
- 5
test/ScopeGuardTest.cpp Datei anzeigen

@@ -20,17 +20,33 @@

#include "scope_guard.h"
#include <catch.hpp>
#include <trompeloeil.hpp>

TEST_CASE("deleter called on destruction", "[ScopeGuard]")
using namespace trompeloeil;

struct CallMock
{
std::size_t calls{0};
MAKE_MOCK0(deleter, void());
};

namespace
{
CallMock m;

void deleter()
{
auto guard = sr::scope_guard([&calls] { ++calls; });
static_cast<void>(guard);
m.deleter();
}
}

REQUIRE(calls == 1);

TEST_CASE("deleter called on destruction", "[ScopeGuard]")
{
{
REQUIRE_CALL(m, deleter());
auto guard = sr::scope_guard(deleter);
static_cast<void>(guard);
}
}

TEST_CASE("deleter is not called if released", "[ScopeGuard]")

+ 27
- 0
test/TestMain.cpp Datei anzeigen

@@ -20,3 +20,30 @@

#define CATCH_CONFIG_MAIN
#include <catch.hpp>
#include <trompeloeil.hpp>


namespace trompeloeil
{
template <>
void reporter<specialized>::send(
severity s,
const char* file,
unsigned long line,
const char* msg)
{
std::ostringstream os;
if (line) os << file << ':' << line << '\n';
os << msg;
auto failure = os.str();
if (s == severity::fatal)
{
FAIL(failure);
}
else
{
CAPTURE(failure);
CHECK(failure.empty());
}
}
}

+ 23
- 0
test/trompeloeil/LICENSE_1_0.txt Datei anzeigen

@@ -0,0 +1,23 @@
Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.

+ 3758
- 0
test/trompeloeil/trompeloeil.hpp
Datei-Diff unterdrückt, da er zu groß ist
Datei anzeigen


Laden…
Abbrechen
Speichern