From be98f6b83acf489daefe604e238e4657940b1e64 Mon Sep 17 00:00:00 2001 From: Miodrag Milanovic Date: Sat, 12 Nov 2016 10:20:42 +0100 Subject: Added Catch testing library (nw) --- 3rdparty/catch/projects/SelfTest/ClassTests.cpp | 57 +++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 3rdparty/catch/projects/SelfTest/ClassTests.cpp (limited to '3rdparty/catch/projects/SelfTest/ClassTests.cpp') diff --git a/3rdparty/catch/projects/SelfTest/ClassTests.cpp b/3rdparty/catch/projects/SelfTest/ClassTests.cpp new file mode 100644 index 00000000000..a4707849bb9 --- /dev/null +++ b/3rdparty/catch/projects/SelfTest/ClassTests.cpp @@ -0,0 +1,57 @@ +/* + * Created by Phil on 09/11/2010. + * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. + * + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include "catch.hpp" + +namespace +{ + class TestClass + { + std::string s; + + public: + TestClass() + : s( "hello" ) + {} + + void succeedingCase() + { + REQUIRE( s == "hello" ); + } + void failingCase() + { + REQUIRE( s == "world" ); + } + }; +} + + +METHOD_AS_TEST_CASE( TestClass::succeedingCase, "A METHOD_AS_TEST_CASE based test run that succeeds", "[class]" ) +METHOD_AS_TEST_CASE( TestClass::failingCase, "A METHOD_AS_TEST_CASE based test run that fails", "[.][class][failing]" ) + + +struct Fixture +{ + Fixture() : m_a( 1 ) {} + + int m_a; +}; + +TEST_CASE_METHOD( Fixture, "A TEST_CASE_METHOD based test run that succeeds", "[class]" ) +{ + REQUIRE( m_a == 1 ); +} + +// We should be able to write our tests within a different namespace +namespace Inner +{ + TEST_CASE_METHOD( Fixture, "A TEST_CASE_METHOD based test run that fails", "[.][class][failing]" ) + { + REQUIRE( m_a == 2 ); + } +} -- cgit v1.2.3-70-g09d2