Repository navigation
Expand file tree
/
Copy pathexample1.cpp
More file actions
60 lines (49 loc) · 1.72 KB
/
Copy pathexample1.cpp
File metadata and controls
60 lines (49 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2013 by Martin Moene
//
// hamlest example. hamlest is based on the C++ hamcrest variant by Jon Reid,
// see http://code.google.com/p/hamcrest/source/browse/trunk/hamcrest-c++?r=446
// Note: Hamcrest is being ported to GitHub https://github.com/hamcrest
//
// 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 "hamlest.hpp"
#include <set>
using namespace lest::hamlest;
std::set<int> s{ 1, 2, 3, };
std::set<int> t{ 2, 1, 0, };
std::string hello() { return "hello C++11 world"; }
const lest::test specification[] =
{
CASE("sets of int compare equal")
{
EXPECT( s == s );
EXPECT( s == t );
},
CASE("sets of int match equal")
{
EXPECT_THAT( s, equal_to( s ) );
EXPECT_THAT( s, equal_to( t ) );
},
CASE("string contains substring")
{
EXPECT_THAT( hello(), starts_with( "hello" ) );
EXPECT_THAT( hello(), ends_with( "world" ) );
EXPECT_THAT( hello(), contains( "C++11" ) );
EXPECT_THAT( hello(), contains( "C++14" ) );
},
CASE("string matches at least one string")
{
EXPECT_THAT( "hello", any_of( { "hello", "C++", "world" } ) );
EXPECT_THAT( "hello", any_of( { "foo" , "C++", "bar" } ) );
},
CASE("string satisfies all constraints")
{
EXPECT_THAT( hello(), all_of( starts_with("hello"), contains("C++11"), ends_with("world") ) );
EXPECT_THAT( hello(), all_of( starts_with("hello"), contains("C++14"), ends_with("world") ) );
},
};
int main()
{
return lest::run( specification );
}
// g++ -Wall -Wextra -Weffc++ -std=c++11 -o example1.exe example1.cpp && example1.exe