From 48b3d82ffe1ed19db9ba3cf7e6536ecf92e27391 Mon Sep 17 00:00:00 2001 From: Szczepan Zalega Date: Fri, 22 Dec 2017 16:53:56 +0100 Subject: Squashed 'unittest/Catch/' content from commit ae5ee2cf git-subtree-dir: unittest/Catch git-subtree-split: ae5ee2cf63d6d67bd1369b512d2a7b60b571c907 --- projects/SelfTest/ClassTests.cpp | 57 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) create mode 100644 projects/SelfTest/ClassTests.cpp (limited to 'projects/SelfTest/ClassTests.cpp') diff --git a/projects/SelfTest/ClassTests.cpp b/projects/SelfTest/ClassTests.cpp new file mode 100644 index 0000000..a470784 --- /dev/null +++ b/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.1