Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 1 | /* |
| 2 | * TrickyTests.cpp |
| 3 | * Catch - Test |
| 4 | * |
| 5 | * Created by Phil on 09/11/2010. |
| 6 | * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. |
| 7 | * |
| 8 | * Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 9 | * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 10 | * |
| 11 | */ |
| 12 | |
Phil Nash | 7e8cfa7 | 2010-11-12 08:12:01 +0000 | [diff] [blame^] | 13 | #include "../catch.hpp" |
Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 14 | |
| 15 | namespace Catch |
| 16 | { |
| 17 | template<> |
| 18 | std::string toString<std::pair<int, int> >( const std::pair<int, int>& value ) |
| 19 | { |
| 20 | std::ostringstream oss; |
| 21 | oss << "std::pair( " << value.first << ", " << value.second << " )"; |
| 22 | return oss.str(); |
| 23 | |
| 24 | } |
| 25 | } |
| 26 | |
Phil Nash | 3d0fed7 | 2010-11-10 19:18:46 +0000 | [diff] [blame] | 27 | TEST_CASE( "succeeding/Tricky/std::pair", "Parsing a std::pair" ) |
Phil Nash | d802600 | 2010-11-09 23:24:00 +0000 | [diff] [blame] | 28 | { |
| 29 | std::pair<int, int> aNicePair( 1, 2 ); |
| 30 | |
| 31 | // !TBD: would be nice if this could compile without the extra parentheses |
| 32 | EXPECT( (std::pair<int, int>( 1, 2 )) == aNicePair ); |
| 33 | |
Phil Nash | 3d0fed7 | 2010-11-10 19:18:46 +0000 | [diff] [blame] | 34 | } |
| 35 | |
| 36 | TEST_CASE( "succeeding/Tricky/complex lhs", "Where the LHS is not a simple value" ) |
| 37 | { |
| 38 | int a = 1; |
| 39 | int b = 2; |
| 40 | |
Phil Nash | 48a7022 | 2010-11-11 07:21:57 +0000 | [diff] [blame] | 41 | // This only captures part of the expression, but issues a warning about the rest |
Phil Nash | c435f4c | 2010-11-11 07:22:46 +0000 | [diff] [blame] | 42 | EXPECT( a == 2 || b == 2 ); |
Phil Nash | 92f2d32 | 2010-11-11 20:37:46 +0000 | [diff] [blame] | 43 | } |