├── .gitignore
├── BowlingGame
├── BowlingGame.vcxproj
├── BowlingGame.vcxproj.filters
├── Game.cpp
├── Game.h
├── ReadMe.txt
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── BowlingTests.Catch
├── BowlingTests.Catch.cpp
├── BowlingTests.Catch.vcxproj
├── BowlingTests.Catch.vcxproj.filters
├── ReadMe.txt
├── catch.hpp
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── BowlingTests.GTest
├── BowlingTests.GTest.vcxproj
├── BowlingTests.GTest.vcxproj.filters
├── ReadMe.txt
├── SimpleGameTests.cpp
├── SpareTests.cpp
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── BowlingTests.MSTest
├── BowlingTests.MSTest.vcxproj
├── BowlingTests.MSTest.vcxproj.filters
├── SimpleGameTests.cpp
├── SpareTests.cpp
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── BowlingTests.Mettle
├── BowlingTests.Mettle.cpp
├── BowlingTests.Mettle.vcxproj
├── BowlingTests.Mettle.vcxproj.filters
├── ReadMe.txt
├── mettle
│ ├── basic_suite.hpp
│ ├── detail
│ │ ├── forward_if.hpp
│ │ ├── string_algorithm.hpp
│ │ └── tuple_algorithm.hpp
│ ├── driver
│ │ ├── cmd_line.hpp
│ │ ├── detail
│ │ │ ├── bencode.hpp
│ │ │ ├── export.hpp
│ │ │ └── optional.hpp
│ │ ├── exit_code.hpp
│ │ ├── filters.hpp
│ │ ├── filters_core.hpp
│ │ ├── header_driver.hpp
│ │ ├── lib_driver.hpp
│ │ ├── object_factory.hpp
│ │ ├── posix
│ │ │ ├── scoped_pipe.hpp
│ │ │ ├── scoped_signal.hpp
│ │ │ └── subprocess.hpp
│ │ ├── run_tests.hpp
│ │ ├── subprocess_test_runner.hpp
│ │ ├── test_name.hpp
│ │ └── windows
│ │ │ ├── scoped_handle.hpp
│ │ │ ├── scoped_pipe.hpp
│ │ │ └── subprocess.hpp
│ ├── glue.hpp
│ ├── header_only.hpp
│ ├── matchers.hpp
│ ├── matchers
│ │ ├── any_capture.hpp
│ │ ├── arithmetic.hpp
│ │ ├── collection.hpp
│ │ ├── combinatoric.hpp
│ │ ├── core.hpp
│ │ ├── death.hpp
│ │ ├── detail
│ │ │ ├── source_location.hpp
│ │ │ └── source_location_shim.hpp
│ │ ├── exception.hpp
│ │ ├── expect.hpp
│ │ ├── regex.hpp
│ │ ├── relational.hpp
│ │ └── result.hpp
│ ├── output.hpp
│ ├── output
│ │ ├── string.hpp
│ │ ├── to_printable.hpp
│ │ ├── traits.hpp
│ │ └── type_name.hpp
│ ├── suite.hpp
│ ├── suite
│ │ ├── attributes.hpp
│ │ ├── compiled_suite.hpp
│ │ ├── detail
│ │ │ ├── all_suites.hpp
│ │ │ ├── built_in_attrs.hpp
│ │ │ └── test_caller.hpp
│ │ ├── factory.hpp
│ │ ├── global_suite.hpp
│ │ └── make_suite.hpp
│ └── test_uid.hpp
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── CppUnitTestingMockComparison.sln
├── CppUnitTestingMockComparison
├── CppUnitTestingMockComparison.cpp
├── CppUnitTestingMockComparison.vcxproj
├── CppUnitTestingMockComparison.vcxproj.filters
├── ReadMe.txt
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── DistibutedCalculator.FakeIt
├── DistibutedCalculator.FakeIt.cpp
├── DistibutedCalculator.FakeIt.vcxproj
├── DistibutedCalculator.FakeIt.vcxproj.filters
├── ReadMe.txt
├── catch.hpp
├── fakeit.hpp
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── DistributedCalculator.HippoMocks
├── DistributedCalculator.HippoMocks.vcxproj
├── DistributedCalculator.HippoMocks.vcxproj.filters
├── DistributedCalculatorTests.cpp
├── hippomocks.h
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── DistributedCalculator
├── Calculator.cpp
├── Calculator.h
├── DataAccess.h
├── DistributedCalculator.vcxproj
├── DistributedCalculator.vcxproj.filters
├── ReadMe.txt
├── RestApiClient.cpp
├── RestApiClient.h
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── DistributedCalculatorTests.GMock
├── DistributedCalculatorTests.GMock.cpp
├── DistributedCalculatorTests.GMock.vcxproj
├── DistributedCalculatorTests.GMock.vcxproj.filters
├── FakeDataAccess.h
├── FakeRestApiClient.h
├── ReadMe.txt
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── DistributedCalculatorTests.Trompeloeil
├── DistributedCalculatorTests.Trompeloeil.cpp
├── DistributedCalculatorTests.Trompeloeil.vcxproj
├── DistributedCalculatorTests.Trompeloeil.vcxproj.filters
├── FakeDataAccess.h
├── FakeRestApiClient.h
├── ReadMe.txt
├── catch.hpp
├── stdafx.cpp
├── stdafx.h
├── targetver.h
└── trompeloeil.hpp
├── LICENSE
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 | ##
4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
5 |
6 | # User-specific files
7 | *.suo
8 | *.user
9 | *.userosscache
10 | *.sln.docstates
11 |
12 | # User-specific files (MonoDevelop/Xamarin Studio)
13 | *.userprefs
14 |
15 | # Build results
16 | [Dd]ebug/
17 | [Dd]ebugPublic/
18 | [Rr]elease/
19 | [Rr]eleases/
20 | x64/
21 | x86/
22 | bld/
23 | [Bb]in/
24 | [Oo]bj/
25 | [Ll]og/
26 |
27 | # Visual Studio 2015 cache/options directory
28 | .vs/
29 | # Uncomment if you have tasks that create the project's static files in wwwroot
30 | #wwwroot/
31 |
32 | # MSTest test Results
33 | [Tt]est[Rr]esult*/
34 | [Bb]uild[Ll]og.*
35 |
36 | # NUNIT
37 | *.VisualState.xml
38 | TestResult.xml
39 |
40 | # Build Results of an ATL Project
41 | [Dd]ebugPS/
42 | [Rr]eleasePS/
43 | dlldata.c
44 |
45 | # .NET Core
46 | project.lock.json
47 | project.fragment.lock.json
48 | artifacts/
49 | **/Properties/launchSettings.json
50 |
51 | *_i.c
52 | *_p.c
53 | *_i.h
54 | *.ilk
55 | *.meta
56 | *.obj
57 | *.pch
58 | *.pdb
59 | *.pgc
60 | *.pgd
61 | *.rsp
62 | *.sbr
63 | *.tlb
64 | *.tli
65 | *.tlh
66 | *.tmp
67 | *.tmp_proj
68 | *.log
69 | *.vspscc
70 | *.vssscc
71 | .builds
72 | *.pidb
73 | *.svclog
74 | *.scc
75 |
76 | # Chutzpah Test files
77 | _Chutzpah*
78 |
79 | # Visual C++ cache files
80 | ipch/
81 | *.aps
82 | *.ncb
83 | *.opendb
84 | *.opensdf
85 | *.sdf
86 | *.cachefile
87 | *.VC.db
88 | *.VC.VC.opendb
89 |
90 | # Visual Studio profiler
91 | *.psess
92 | *.vsp
93 | *.vspx
94 | *.sap
95 |
96 | # TFS 2012 Local Workspace
97 | $tf/
98 |
99 | # Guidance Automation Toolkit
100 | *.gpState
101 |
102 | # ReSharper is a .NET coding add-in
103 | _ReSharper*/
104 | *.[Rr]e[Ss]harper
105 | *.DotSettings.user
106 |
107 | # JustCode is a .NET coding add-in
108 | .JustCode
109 |
110 | # TeamCity is a build add-in
111 | _TeamCity*
112 |
113 | # DotCover is a Code Coverage Tool
114 | *.dotCover
115 |
116 | # Visual Studio code coverage results
117 | *.coverage
118 | *.coveragexml
119 |
120 | # NCrunch
121 | _NCrunch_*
122 | .*crunch*.local.xml
123 | nCrunchTemp_*
124 |
125 | # MightyMoose
126 | *.mm.*
127 | AutoTest.Net/
128 |
129 | # Web workbench (sass)
130 | .sass-cache/
131 |
132 | # Installshield output folder
133 | [Ee]xpress/
134 |
135 | # DocProject is a documentation generator add-in
136 | DocProject/buildhelp/
137 | DocProject/Help/*.HxT
138 | DocProject/Help/*.HxC
139 | DocProject/Help/*.hhc
140 | DocProject/Help/*.hhk
141 | DocProject/Help/*.hhp
142 | DocProject/Help/Html2
143 | DocProject/Help/html
144 |
145 | # Click-Once directory
146 | publish/
147 |
148 | # Publish Web Output
149 | *.[Pp]ublish.xml
150 | *.azurePubxml
151 | # TODO: Comment the next line if you want to checkin your web deploy settings
152 | # but database connection strings (with potential passwords) will be unencrypted
153 | *.pubxml
154 | *.publishproj
155 |
156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to
157 | # checkin your Azure Web App publish settings, but sensitive information contained
158 | # in these scripts will be unencrypted
159 | PublishScripts/
160 |
161 | # NuGet Packages
162 | *.nupkg
163 | # The packages folder can be ignored because of Package Restore
164 | **/packages/*
165 | # except build/, which is used as an MSBuild target.
166 | !**/packages/build/
167 | # Uncomment if necessary however generally it will be regenerated when needed
168 | #!**/packages/repositories.config
169 | # NuGet v3's project.json files produces more ignorable files
170 | *.nuget.props
171 | *.nuget.targets
172 |
173 | # Microsoft Azure Build Output
174 | csx/
175 | *.build.csdef
176 |
177 | # Microsoft Azure Emulator
178 | ecf/
179 | rcf/
180 |
181 | # Windows Store app package directories and files
182 | AppPackages/
183 | BundleArtifacts/
184 | Package.StoreAssociation.xml
185 | _pkginfo.txt
186 |
187 | # Visual Studio cache files
188 | # files ending in .cache can be ignored
189 | *.[Cc]ache
190 | # but keep track of directories ending in .cache
191 | !*.[Cc]ache/
192 |
193 | # Others
194 | ClientBin/
195 | ~$*
196 | *~
197 | *.dbmdl
198 | *.dbproj.schemaview
199 | *.jfm
200 | *.pfx
201 | *.publishsettings
202 | orleans.codegen.cs
203 |
204 | # Since there are multiple workflows, uncomment next line to ignore bower_components
205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
206 | #bower_components/
207 |
208 | # RIA/Silverlight projects
209 | Generated_Code/
210 |
211 | # Backup & report files from converting an old project file
212 | # to a newer Visual Studio version. Backup files are not needed,
213 | # because we have git ;-)
214 | _UpgradeReport_Files/
215 | Backup*/
216 | UpgradeLog*.XML
217 | UpgradeLog*.htm
218 |
219 | # SQL Server files
220 | *.mdf
221 | *.ldf
222 | *.ndf
223 |
224 | # Business Intelligence projects
225 | *.rdl.data
226 | *.bim.layout
227 | *.bim_*.settings
228 |
229 | # Microsoft Fakes
230 | FakesAssemblies/
231 |
232 | # GhostDoc plugin setting file
233 | *.GhostDoc.xml
234 |
235 | # Node.js Tools for Visual Studio
236 | .ntvs_analysis.dat
237 | node_modules/
238 |
239 | # Typescript v1 declaration files
240 | typings/
241 |
242 | # Visual Studio 6 build log
243 | *.plg
244 |
245 | # Visual Studio 6 workspace options file
246 | *.opt
247 |
248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.)
249 | *.vbw
250 |
251 | # Visual Studio LightSwitch build output
252 | **/*.HTMLClient/GeneratedArtifacts
253 | **/*.DesktopClient/GeneratedArtifacts
254 | **/*.DesktopClient/ModelManifest.xml
255 | **/*.Server/GeneratedArtifacts
256 | **/*.Server/ModelManifest.xml
257 | _Pvt_Extensions
258 |
259 | # Paket dependency manager
260 | .paket/paket.exe
261 | paket-files/
262 |
263 | # FAKE - F# Make
264 | .fake/
265 |
266 | # JetBrains Rider
267 | .idea/
268 | *.sln.iml
269 |
270 | # CodeRush
271 | .cr/
272 |
273 | # Python Tools for Visual Studio (PTVS)
274 | __pycache__/
275 | *.pyc
276 |
277 | # Cake - Uncomment if you are using it
278 | # tools/**
279 | # !tools/packages.config
280 |
281 | # Telerik's JustMock configuration file
282 | *.jmconfig
283 |
284 | # BizTalk build output
285 | *.btp.cs
286 | *.btm.cs
287 | *.odx.cs
288 | *.xsd.cs
289 |
--------------------------------------------------------------------------------
/BowlingGame/BowlingGame.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 15.0
23 | {6D3969ED-98F4-4C00-88E5-12A24A5409DA}
24 | Win32Proj
25 | BowlingGame
26 | 10.0.15063.0
27 |
28 |
29 |
30 | StaticLibrary
31 | true
32 | v141
33 | Unicode
34 |
35 |
36 | StaticLibrary
37 | false
38 | v141
39 | true
40 | Unicode
41 |
42 |
43 | StaticLibrary
44 | true
45 | v141
46 | Unicode
47 |
48 |
49 | StaticLibrary
50 | false
51 | v141
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 | Use
77 | Level3
78 | Disabled
79 | WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)
80 |
81 |
82 | Windows
83 |
84 |
85 |
86 |
87 | Use
88 | Level3
89 | Disabled
90 | _DEBUG;_LIB;%(PreprocessorDefinitions)
91 |
92 |
93 | Windows
94 |
95 |
96 |
97 |
98 | Level3
99 | Use
100 | MaxSpeed
101 | true
102 | true
103 | WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)
104 |
105 |
106 | Windows
107 | true
108 | true
109 |
110 |
111 |
112 |
113 | Level3
114 | Use
115 | MaxSpeed
116 | true
117 | true
118 | NDEBUG;_LIB;%(PreprocessorDefinitions)
119 |
120 |
121 | Windows
122 | true
123 | true
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 | Create
138 | Create
139 | Create
140 | Create
141 |
142 |
143 |
144 |
145 |
146 |
--------------------------------------------------------------------------------
/BowlingGame/BowlingGame.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Header Files
23 |
24 |
25 | Header Files
26 |
27 |
28 | Header Files
29 |
30 |
31 |
32 |
33 | Source Files
34 |
35 |
36 | Source Files
37 |
38 |
39 |
--------------------------------------------------------------------------------
/BowlingGame/Game.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "Game.h"
3 | #include
4 |
5 | Game::Game() : _round(0)
6 | {
7 | std::memset(_rolls, 0, sizeof(_rolls));
8 | }
9 |
10 |
11 | Game::~Game()
12 | {
13 | }
14 |
15 | int Game::Score() const {
16 | int total = 0;
17 | for (int i = 0; i < 21; ++i) {
18 | if (_rolls[i] == 10)
19 | {
20 | if (_round > i + 2)
21 | {
22 | total += 10 + _rolls[i + 2] + _rolls[i + 3];
23 | }
24 | }
25 | else if (_rolls[i] + _rolls[i + 1] == 10) {
26 | total += 10 + _rolls[i + 2];
27 | i++;
28 | }
29 | else
30 | {
31 | total += _rolls[i];
32 | }
33 | }
34 |
35 | return total;
36 | }
37 |
38 | void Game::Roll(int pins)
39 | {
40 | _rolls[_round++] = pins;
41 |
42 | if (pins == 10)
43 | {
44 | _round++;
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/BowlingGame/Game.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | class Game
3 | {
4 | int _rolls[21];
5 | int _round;
6 | public:
7 | Game();
8 | ~Game();
9 |
10 | int Score() const;
11 | void Roll(int);
12 | };
13 |
14 |
--------------------------------------------------------------------------------
/BowlingGame/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | STATIC LIBRARY : BowlingGame Project Overview
3 | ========================================================================
4 |
5 | AppWizard has created this BowlingGame library project for you.
6 |
7 | This file contains a summary of what you will find in each of the files that
8 | make up your BowlingGame application.
9 |
10 |
11 | BowlingGame.vcxproj
12 | This is the main project file for VC++ projects generated using an Application Wizard.
13 | It contains information about the version of Visual C++ that generated the file, and
14 | information about the platforms, configurations, and project features selected with the
15 | Application Wizard.
16 |
17 | BowlingGame.vcxproj.filters
18 | This is the filters file for VC++ projects generated using an Application Wizard.
19 | It contains information about the association between the files in your project
20 | and the filters. This association is used in the IDE to show grouping of files with
21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the
22 | "Source Files" filter).
23 |
24 |
25 | /////////////////////////////////////////////////////////////////////////////
26 |
27 | StdAfx.h, StdAfx.cpp
28 | These files are used to build a precompiled header (PCH) file
29 | named BowlingGame.pch and a precompiled types file named StdAfx.obj.
30 |
31 | /////////////////////////////////////////////////////////////////////////////
32 | Other notes:
33 |
34 | AppWizard uses "TODO:" comments to indicate parts of the source code you
35 | should add to or customize.
36 |
37 | /////////////////////////////////////////////////////////////////////////////
38 |
--------------------------------------------------------------------------------
/BowlingGame/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // BowlingGame.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/BowlingGame/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 | #include "targetver.h"
9 |
10 | #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
11 |
12 |
13 |
14 | // TODO: reference additional headers your program requires here
15 |
--------------------------------------------------------------------------------
/BowlingGame/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------
/BowlingTests.Catch/BowlingTests.Catch.cpp:
--------------------------------------------------------------------------------
1 | // BowlingTests.Catch.cpp : Defines the entry point for the console application.
2 | //
3 |
4 | #include "stdafx.h"
5 | #define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
6 | #include "catch.hpp"
7 | #include "../BowlingGame/Game.h"
8 |
9 | void RollSeveral(Game& game, int rolls, int pins) {
10 | for (int i = 0; i < rolls; i++) {
11 | game.Roll(pins);
12 | }
13 | }
14 |
15 | TEST_CASE("Simple Bowling score -- without score or strike", "[BowlingKata]")
16 | {
17 | Game game;
18 |
19 | SECTION("All rolls are gutter balls --> score == 0") {
20 | RollSeveral(game, 20, 0);
21 |
22 | REQUIRE(game.Score() == 0);
23 | }
24 |
25 | SECTION("All rolls are 1 --> score == 20") {
26 | RollSeveral(game, 20, 1);
27 |
28 | REQUIRE(game.Score() == 20);
29 | }
30 |
31 | SECTION("All rolls are 2 --> score == 40", "[Run me]") {
32 | RollSeveral(game, 20, 2);
33 |
34 | REQUIRE(game.Score() == 40);
35 | }
36 | }
37 |
38 | TEST_CASE("Using spare")
39 | {
40 | Game game;
41 |
42 | SECTION("Spare in the first round --> value equals secod round first roll + 10")
43 | {
44 | game.Roll(7);
45 | game.Roll(3);
46 | game.Roll(4);
47 | RollSeveral(game, 17, 0);
48 |
49 | REQUIRE(game.Score() == 18);
50 | }
51 | }
52 |
53 | SCENARIO("First roll is strike")
54 | {
55 | GIVEN("Bowled strike on first turn")
56 | {
57 | Game game;
58 | game.Roll(10);
59 |
60 | WHEN("All rest rolls are gutter balls")
61 | {
62 | RollSeveral(game, 18, 0);
63 | THEN("Total score is 10")
64 | {
65 | REQUIRE(game.Score() == 10);
66 | }
67 | }
68 |
69 | WHEN("Next two rolls are not spare or strike")
70 | {
71 | game.Roll(3);
72 | game.Roll(4);
73 | RollSeveral(game, 16, 0);
74 |
75 | THEN("Total score is 10 plus twice the sum of these rolls")
76 | {
77 | REQUIRE(game.Score() == 24);
78 | }
79 | }
80 |
81 | WHEN("Next roll is spare then all gutter balls")
82 | {
83 | game.Roll(3);
84 | game.Roll(7);
85 | RollSeveral(game, 16, 0);
86 |
87 | THEN("Total score is 30")
88 | {
89 | REQUIRE(game.Score() == 30);
90 | }
91 | }
92 |
93 | WHEN("Next roll is spare then roll five")
94 | {
95 | game.Roll(3);
96 | game.Roll(7);
97 | game.Roll(5);
98 | RollSeveral(game, 15, 0);
99 |
100 | THEN("Total score is 40")
101 | {
102 | REQUIRE(game.Score() == 40);
103 | }
104 | }
105 |
106 | WHEN("Next two rolls are strike then gutter balls")
107 | {
108 | game.Roll(10);
109 | game.Roll(10);
110 | RollSeveral(game, 16, 0);
111 |
112 | THEN("Total score is 60")
113 | {
114 | REQUIRE(game.Score() == 60);
115 | }
116 | }
117 | }
118 | }
--------------------------------------------------------------------------------
/BowlingTests.Catch/BowlingTests.Catch.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Header Files
23 |
24 |
25 | Header Files
26 |
27 |
28 | Header Files
29 |
30 |
31 |
32 |
33 | Source Files
34 |
35 |
36 | Source Files
37 |
38 |
39 |
--------------------------------------------------------------------------------
/BowlingTests.Catch/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | CONSOLE APPLICATION : BowlingTests.Catch Project Overview
3 | ========================================================================
4 |
5 | AppWizard has created this BowlingTests.Catch application for you.
6 |
7 | This file contains a summary of what you will find in each of the files that
8 | make up your BowlingTests.Catch application.
9 |
10 |
11 | BowlingTests.Catch.vcxproj
12 | This is the main project file for VC++ projects generated using an Application Wizard.
13 | It contains information about the version of Visual C++ that generated the file, and
14 | information about the platforms, configurations, and project features selected with the
15 | Application Wizard.
16 |
17 | BowlingTests.Catch.vcxproj.filters
18 | This is the filters file for VC++ projects generated using an Application Wizard.
19 | It contains information about the association between the files in your project
20 | and the filters. This association is used in the IDE to show grouping of files with
21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the
22 | "Source Files" filter).
23 |
24 | BowlingTests.Catch.cpp
25 | This is the main application source file.
26 |
27 | /////////////////////////////////////////////////////////////////////////////
28 | Other standard files:
29 |
30 | StdAfx.h, StdAfx.cpp
31 | These files are used to build a precompiled header (PCH) file
32 | named BowlingTests.Catch.pch and a precompiled types file named StdAfx.obj.
33 |
34 | /////////////////////////////////////////////////////////////////////////////
35 | Other notes:
36 |
37 | AppWizard uses "TODO:" comments to indicate parts of the source code you
38 | should add to or customize.
39 |
40 | /////////////////////////////////////////////////////////////////////////////
41 |
--------------------------------------------------------------------------------
/BowlingTests.Catch/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // BowlingTests.Catch.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/BowlingTests.Catch/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 | #include "targetver.h"
9 |
10 | #include
11 | #include
12 |
13 |
14 |
15 | // TODO: reference additional headers your program requires here
16 |
--------------------------------------------------------------------------------
/BowlingTests.Catch/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------
/BowlingTests.GTest/BowlingTests.GTest.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Header Files
23 |
24 |
25 | Header Files
26 |
27 |
28 |
29 |
30 | Source Files
31 |
32 |
33 | Source Files
34 |
35 |
36 | Source Files
37 |
38 |
39 |
--------------------------------------------------------------------------------
/BowlingTests.GTest/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | CONSOLE APPLICATION : BowlingTests.GTest Project Overview
3 | ========================================================================
4 |
5 | AppWizard has created this BowlingTests.GTest application for you.
6 |
7 | This file contains a summary of what you will find in each of the files that
8 | make up your BowlingTests.GTest application.
9 |
10 |
11 | BowlingTests.GTest.vcxproj
12 | This is the main project file for VC++ projects generated using an Application Wizard.
13 | It contains information about the version of Visual C++ that generated the file, and
14 | information about the platforms, configurations, and project features selected with the
15 | Application Wizard.
16 |
17 | BowlingTests.GTest.vcxproj.filters
18 | This is the filters file for VC++ projects generated using an Application Wizard.
19 | It contains information about the association between the files in your project
20 | and the filters. This association is used in the IDE to show grouping of files with
21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the
22 | "Source Files" filter).
23 |
24 | BowlingTests.GTest.cpp
25 | This is the main application source file.
26 |
27 | /////////////////////////////////////////////////////////////////////////////
28 | Other standard files:
29 |
30 | StdAfx.h, StdAfx.cpp
31 | These files are used to build a precompiled header (PCH) file
32 | named BowlingTests.GTest.pch and a precompiled types file named StdAfx.obj.
33 |
34 | /////////////////////////////////////////////////////////////////////////////
35 | Other notes:
36 |
37 | AppWizard uses "TODO:" comments to indicate parts of the source code you
38 | should add to or customize.
39 |
40 | /////////////////////////////////////////////////////////////////////////////
41 |
--------------------------------------------------------------------------------
/BowlingTests.GTest/SimpleGameTests.cpp:
--------------------------------------------------------------------------------
1 | // BowlingTests.GTest.cpp : Defines the entry point for the console application.
2 | //
3 |
4 | #include "stdafx.h"
5 | #include "gtest/gtest.h"
6 | #include "../BowlingGame/Game.h"
7 |
8 | using namespace testing;
9 |
10 |
11 | void RollSeveral(Game& game, int rolls, int pins) {
12 | for (int i = 0; i < rolls; i++) {
13 | game.Roll(pins);
14 | }
15 | }
16 |
17 | TEST(SimpleGameTests, AllRollsAreGutterBalls_ScoreIsZero)
18 | {
19 | Game game;
20 |
21 | RollSeveral(game, 20, 0);
22 |
23 | ASSERT_EQ(0, game.Score());
24 | }
25 |
26 | TEST(SimpleGameTests, AllRollsAreOne_ScoreIs20)
27 | {
28 | Game game;
29 |
30 | RollSeveral(game, 20, 1);
31 |
32 | ASSERT_EQ(20, game.Score());
33 | }
34 |
35 | TEST(SimpleGameTests, AllRollsAreTwo_ScoreIs40)
36 | {
37 | Game game;
38 |
39 | RollSeveral(game, 20, 2);
40 |
41 | ASSERT_EQ(40, game.Score());
42 | }
43 |
44 |
45 | int main(int argc, char** argv)
46 | {
47 | InitGoogleTest(&argc, argv);
48 |
49 | return RUN_ALL_TESTS();
50 | }
51 |
52 |
--------------------------------------------------------------------------------
/BowlingTests.GTest/SpareTests.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "gtest/gtest.h"
3 | #include "../BowlingGame/Game.h"
4 |
5 | using namespace testing;
6 |
7 | class SpareTests : public Test
8 | {
9 | protected:
10 | Game game;
11 |
12 |
13 | void SetUp() override
14 | {
15 | game.Roll(7);
16 | game.Roll(3);
17 | }
18 | };
19 |
20 | TEST_F(SpareTests, SecondRoundZero_ScoreIsTen)
21 | {
22 | game.Roll(0);
23 | game.Roll(0);
24 |
25 | ASSERT_EQ(11, game.Score());
26 | }
27 |
28 | TEST_F(SpareTests, RollSomeValueInSecondRound_ScoreEqualValuePlusTenPlusRound)
29 | {
30 | game.Roll(4);
31 | game.Roll(2);
32 |
33 | ASSERT_EQ(20, game.Score());
34 | }
--------------------------------------------------------------------------------
/BowlingTests.GTest/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // BowlingTests.GTest.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/BowlingTests.GTest/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 | #include "targetver.h"
9 |
10 | #include
11 | #include
12 |
13 |
14 |
15 | // TODO: reference additional headers your program requires here
16 |
--------------------------------------------------------------------------------
/BowlingTests.GTest/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------
/BowlingTests.MSTest/BowlingTests.MSTest.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 | Header Files
20 |
21 |
22 | Header Files
23 |
24 |
25 |
26 |
27 | Source Files
28 |
29 |
30 | Source Files
31 |
32 |
33 | Source Files
34 |
35 |
36 |
--------------------------------------------------------------------------------
/BowlingTests.MSTest/SimpleGameTests.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "CppUnitTest.h"
3 | #include "../BowlingGame/Game.h"
4 |
5 | using namespace Microsoft::VisualStudio::CppUnitTestFramework;
6 |
7 | namespace BowlingTestsMSTest
8 | {
9 | void RollSeveral(Game& game, int rolls, int pins) {
10 | for (int i = 0; i < rolls; i++) {
11 | game.Roll(pins);
12 | }
13 | }
14 |
15 | TEST_CLASS(SimpleGameTests)
16 | {
17 | Game game;
18 | public:
19 |
20 | TEST_METHOD(AllRollsAreGutterBalls_ScoreIsZero)
21 | {
22 | RollSeveral(game, 20, 0);
23 |
24 | Assert::AreEqual(0, game.Score());
25 | }
26 |
27 | TEST_METHOD(AllRollsAreOne_ScoreIs20)
28 | {
29 | RollSeveral(game, 20, 1);
30 |
31 | Assert::AreEqual(20, game.Score());
32 | }
33 |
34 | TEST_METHOD(AllRollsAreTwo_ScoreIs40)
35 | {
36 | RollSeveral(game, 20, 2);
37 |
38 | Assert::AreEqual(40, game.Score());
39 | }
40 | };
41 | }
--------------------------------------------------------------------------------
/BowlingTests.MSTest/SpareTests.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "CppUnitTest.h"
3 | #include "../BowlingGame/Game.h"
4 |
5 | using namespace Microsoft::VisualStudio::CppUnitTestFramework;
6 |
7 | namespace BowlingTestsMSTest
8 | {
9 | TEST_CLASS(SpareTests)
10 | {
11 | Game game;
12 | public:
13 |
14 | TEST_METHOD_INITIALIZE(RollSpareInFirstRound)
15 | {
16 | game.Roll(7);
17 | game.Roll(3);
18 | }
19 |
20 | TEST_METHOD(SecondRoundZero_ScoreIsZero)
21 | {
22 | game.Roll(0);
23 | game.Roll(0);
24 |
25 | Assert::AreEqual(10, game.Score());
26 | }
27 |
28 | TEST_METHOD(RollSomeValueInSecondRound_ScoreEqualValuePlusTenPlusRound)
29 | {
30 | game.Roll(4);
31 | game.Roll(2);
32 |
33 | Assert::AreEqual(20, game.Score());
34 | }
35 | };
36 | }
--------------------------------------------------------------------------------
/BowlingTests.MSTest/stdafx.cpp:
--------------------------------------------------------------------------------
1 | // stdafx.cpp : source file that includes just the standard includes
2 | // BowlingTests.MSTest.pch will be the pre-compiled header
3 | // stdafx.obj will contain the pre-compiled type information
4 |
5 | #include "stdafx.h"
6 |
7 | // TODO: reference any additional headers you need in STDAFX.H
8 | // and not in this file
9 |
--------------------------------------------------------------------------------
/BowlingTests.MSTest/stdafx.h:
--------------------------------------------------------------------------------
1 | // stdafx.h : include file for standard system include files,
2 | // or project specific include files that are used frequently, but
3 | // are changed infrequently
4 | //
5 |
6 | #pragma once
7 |
8 | #include "targetver.h"
9 |
10 | // Headers for CppUnitTest
11 | #include "CppUnitTest.h"
12 |
13 | // TODO: reference additional headers your program requires here
14 |
--------------------------------------------------------------------------------
/BowlingTests.MSTest/targetver.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | // Including SDKDDKVer.h defines the highest available Windows platform.
4 |
5 | // If you wish to build your application for a previous Windows platform, include WinSDKVer.h and
6 | // set the _WIN32_WINNT macro to the platform you wish to support before including SDKDDKVer.h.
7 |
8 | #include
9 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/BowlingTests.Mettle.cpp:
--------------------------------------------------------------------------------
1 | // BowlingTests.Mettle.cpp : Defines the entry point for the console application.
2 | //
3 |
4 | #include "stdafx.h"
5 | #include "mettle/header_only.hpp"
6 | #include "../BowlingGame/Game.h"
7 |
8 | using namespace mettle;
9 |
10 | void RollSeveral(Game& game, int rolls, int pins) {
11 | for (int i = 0; i < rolls; i++) {
12 | game.Roll(pins);
13 | }
14 | }
15 |
16 | suite<> first("simple tests", [](auto &_) {
17 | _.test("When all rolles are gutterballs --> score is 0", []() {
18 | Game game;
19 |
20 | RollSeveral(game, 20, 0);
21 |
22 | expect(game.Score(), equal_to(0));
23 | });
24 |
25 | _.test("When all rolles are one --> score is 20", []() {
26 | Game game;
27 |
28 | RollSeveral(game, 20, 1);
29 |
30 | expect(game.Score(), equal_to(20));
31 | });
32 |
33 | _.test("When all rolles are two --> score is 40", []() {
34 | Game game;
35 |
36 | RollSeveral(game, 20, 2);
37 |
38 | expect(game.Score(), equal_to(40));
39 | });
40 | });
41 |
42 | struct SpareTests {
43 | Game game;
44 | };
45 |
46 | suite fix("fixture suite", [](auto &_) {
47 |
48 | _.setup([](SpareTests &f) {
49 | f.game.Roll(7);
50 | f.game.Roll(3);
51 | });
52 |
53 | _.test("next round is zero --> score is 10", [](SpareTests &f) {
54 | f.game.Roll(0);
55 | f.game.Roll(0);
56 |
57 | expect(f.game.Score(), equal_to(10));
58 | });
59 |
60 | _.test("Spare in the first round --> value equals secod round first roll + 10", [](SpareTests &f) {
61 | f.game.Roll(4);
62 | f.game.Roll(0);
63 |
64 | expect(f.game.Score(), equal_to(18));
65 | });
66 | });
--------------------------------------------------------------------------------
/BowlingTests.Mettle/BowlingTests.Mettle.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Release
10 | Win32
11 |
12 |
13 | Debug
14 | x64
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | 15.0
23 | {257C2B29-8CB7-4E17-B236-F9C8C3ACADAD}
24 | Win32Proj
25 | BowlingTestsMettle
26 | 10.0.15063.0
27 |
28 |
29 |
30 | Application
31 | true
32 | v141
33 | Unicode
34 |
35 |
36 | Application
37 | false
38 | v141
39 | true
40 | Unicode
41 |
42 |
43 | Application
44 | true
45 | v141
46 | Unicode
47 |
48 |
49 | Application
50 | false
51 | v141
52 | true
53 | Unicode
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 | true
75 |
76 |
77 | true
78 |
79 |
80 | false
81 |
82 |
83 | false
84 |
85 |
86 |
87 | Use
88 | Level3
89 | Disabled
90 | WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)
91 |
92 |
93 | Console
94 | $(OutputPath)
95 | bowlinggame.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
96 |
97 |
98 |
99 |
100 | Use
101 | Level3
102 | Disabled
103 | _DEBUG;_CONSOLE;%(PreprocessorDefinitions)
104 |
105 |
106 | Console
107 |
108 |
109 |
110 |
111 | Level3
112 | Use
113 | MaxSpeed
114 | true
115 | true
116 | WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
117 |
118 |
119 | Console
120 | true
121 | true
122 | $(OutputPath)
123 | bowlinggame.lib;kernel32.lib;user32.lib;gdi32.lib;winspool.lib;comdlg32.lib;advapi32.lib;shell32.lib;ole32.lib;oleaut32.lib;uuid.lib;odbc32.lib;odbccp32.lib;%(AdditionalDependencies)
124 |
125 |
126 |
127 |
128 | Level3
129 | Use
130 | MaxSpeed
131 | true
132 | true
133 | NDEBUG;_CONSOLE;%(PreprocessorDefinitions)
134 |
135 |
136 | Console
137 | true
138 | true
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 | Create
152 | Create
153 | Create
154 | Create
155 |
156 |
157 |
158 |
159 |
160 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/BowlingTests.Mettle.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | Header Files
23 |
24 |
25 | Header Files
26 |
27 |
28 |
29 |
30 | Source Files
31 |
32 |
33 | Source Files
34 |
35 |
36 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | CONSOLE APPLICATION : BowlingTests.Mettle Project Overview
3 | ========================================================================
4 |
5 | AppWizard has created this BowlingTests.Mettle application for you.
6 |
7 | This file contains a summary of what you will find in each of the files that
8 | make up your BowlingTests.Mettle application.
9 |
10 |
11 | BowlingTests.Mettle.vcxproj
12 | This is the main project file for VC++ projects generated using an Application Wizard.
13 | It contains information about the version of Visual C++ that generated the file, and
14 | information about the platforms, configurations, and project features selected with the
15 | Application Wizard.
16 |
17 | BowlingTests.Mettle.vcxproj.filters
18 | This is the filters file for VC++ projects generated using an Application Wizard.
19 | It contains information about the association between the files in your project
20 | and the filters. This association is used in the IDE to show grouping of files with
21 | similar extensions under a specific node (for e.g. ".cpp" files are associated with the
22 | "Source Files" filter).
23 |
24 | BowlingTests.Mettle.cpp
25 | This is the main application source file.
26 |
27 | /////////////////////////////////////////////////////////////////////////////
28 | Other standard files:
29 |
30 | StdAfx.h, StdAfx.cpp
31 | These files are used to build a precompiled header (PCH) file
32 | named BowlingTests.Mettle.pch and a precompiled types file named StdAfx.obj.
33 |
34 | /////////////////////////////////////////////////////////////////////////////
35 | Other notes:
36 |
37 | AppWizard uses "TODO:" comments to indicate parts of the source code you
38 | should add to or customize.
39 |
40 | /////////////////////////////////////////////////////////////////////////////
41 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/mettle/basic_suite.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INC_METTLE_BASIC_SUITE_HPP
2 | #define INC_METTLE_BASIC_SUITE_HPP
3 |
4 | #include "suite/attributes.hpp"
5 | #include "suite/compiled_suite.hpp"
6 | #include "suite/make_suite.hpp"
7 | #include "suite/global_suite.hpp"
8 |
9 | #endif
10 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/mettle/detail/forward_if.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INC_METTLE_DETAIL_MOVE_IF_HPP
2 | #define INC_METTLE_DETAIL_MOVE_IF_HPP
3 |
4 | #include
5 |
6 | namespace mettle {
7 |
8 | namespace detail {
9 | template
10 | struct ref_if {
11 | using type = typename std::conditional<
12 | std::is_lvalue_reference::value,
13 | typename std::remove_reference::type &,
14 | typename std::remove_reference::type &&
15 | >::type;
16 | };
17 |
18 | template
19 | inline decltype(auto)
20 | forward_if(Element &&value) {
21 | return static_cast::type>(value);
22 | }
23 | }
24 |
25 | } // namespace mettle
26 |
27 | #endif
28 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/mettle/detail/string_algorithm.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INC_METTLE_DETAIL_STRING_ALGORITHM_HPP
2 | #define INC_METTLE_DETAIL_STRING_ALGORITHM_HPP
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 |
9 | namespace mettle {
10 |
11 | namespace detail {
12 |
13 | struct identity {
14 | template
15 | constexpr decltype(auto) operator ()(T &&t) const {
16 | return std::forward(t);
17 | }
18 | };
19 |
20 | template
21 | std::string stringify(const T &t) {
22 | std::ostringstream ss;
23 | ss << t;
24 | return ss.str();
25 | }
26 |
27 | template
28 | const std::string & stringify(const std::string &s) {
29 | return s;
30 | }
31 |
32 | class ostream_list_append {
33 | public:
34 | ostream_list_append(std::ostream &os, std::string delim = ", ")
35 | : os_(os), delim_(std::move(delim)) {}
36 |
37 | template
38 | void operator ()(T &&t) {
39 | if(first_)
40 | first_ = false;
41 | else
42 | os_ << delim_;
43 | os_ << std::forward(t);
44 | }
45 | private:
46 | std::ostream &os_;
47 | const std::string delim_;
48 | bool first_ = true;
49 | };
50 |
51 | template
52 | class string_joiner {
53 | public:
54 | string_joiner(Iter begin, Iter end, const Func &func,
55 | const std::string &delim)
56 | : begin_(begin), end_(end), func_(func), delim_(delim) {}
57 | string_joiner(const string_joiner &) = delete;
58 |
59 | friend std::ostream &
60 | operator <<(std::ostream &os, const string_joiner &t) {
61 | ostream_list_append append(os, t.delim_);
62 | for(auto i = t.begin_; i != t.end_; ++i)
63 | append(t.func_(*i));
64 | return os;
65 | }
66 | private:
67 | const Iter begin_, end_;
68 | const Func &func_;
69 | const std::string &delim_;
70 | };
71 |
72 | template
73 | inline const string_joiner
74 | iter_joined(Iter begin, Iter end, const Func &func = identity{},
75 | const std::string &delim = ", ") {
76 | return {begin, end, func, delim};
77 | }
78 |
79 | template
80 | inline auto joined(const T &t, const Func &func = identity{},
81 | const std::string &delim = ", ") ->
82 | const string_joiner {
83 | return {std::begin(t), std::end(t), func, delim};
84 | }
85 |
86 | template
87 | inline auto joined(std::initializer_list t, const Func &func = identity{},
88 | const std::string &delim = ", ") ->
89 | const string_joiner {
90 | return {std::begin(t), std::end(t), func, delim};
91 | }
92 |
93 | }
94 |
95 | } // namespace mettle
96 |
97 | #endif
98 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/mettle/detail/tuple_algorithm.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INC_METTLE_DETAIL_TUPLE_ALGORITHM_HPP
2 | #define INC_METTLE_DETAIL_TUPLE_ALGORITHM_HPP
3 |
4 | #include
5 | #include
6 | #include
7 |
8 | namespace mettle {
9 |
10 | namespace detail {
11 |
12 | template
13 | struct do_until {
14 | template
15 | do_until(Func &&f) {
16 | if(!f(std::integral_constant{}))
17 | do_until(std::forward(f));
18 | }
19 | };
20 |
21 | template
22 | struct do_until {
23 | template
24 | do_until(Func &&) {}
25 | };
26 |
27 | template
28 | void tuple_for_until(Tuple &&tuple, Func &&f) {
29 | using T = typename std::remove_reference::type;
30 | do_until<0, std::tuple_size::value>([&](auto i) {
31 | return f(std::get(tuple));
32 | });
33 | }
34 |
35 | template
36 | class tuple_joiner {
37 | public:
38 | tuple_joiner(const Tuple &tuple, const Func &func, const std::string &delim)
39 | : tuple_(tuple), func_(func), delim_(delim) {}
40 |
41 | friend std::ostream & operator <<(std::ostream &os, const tuple_joiner &t) {
42 | std::size_t i = 0;
43 | tuple_for_until(t.tuple_, [&os, &i, &t](const auto &item) {
44 | if(i++ != 0)
45 | os << t.delim_;
46 | os << t.func_(item);
47 | return false;
48 | });
49 | return os;
50 | }
51 | private:
52 | const Tuple &tuple_;
53 | const Func &func_;
54 | const std::string &delim_;
55 | };
56 |
57 | template
58 | inline tuple_joiner
59 | tuple_joined(const Tuple &tuple, const Func &func,
60 | const std::string &delim = ", ") {
61 | return {tuple, func, delim};
62 | }
63 | }
64 |
65 | } // namespace mettle
66 |
67 | #endif
68 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/mettle/driver/cmd_line.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INC_METTLE_DRIVER_CMD_LINE_HPP
2 | #define INC_METTLE_DRIVER_CMD_LINE_HPP
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | #include
11 | #include
12 | #include
13 |
14 | #include "filters.hpp"
15 | #include "object_factory.hpp"
16 | #include "detail/export.hpp"
17 | #include "detail/optional.hpp"
18 | #include "log/core.hpp"
19 | #include "log/indent.hpp"
20 |
21 | #ifdef _WIN32
22 | # include
23 | #endif
24 |
25 | namespace mettle {
26 |
27 | struct generic_options {
28 | bool show_help = false;
29 | };
30 |
31 | METTLE_PUBLIC boost::program_options::options_description
32 | make_generic_options(generic_options &opts);
33 |
34 | struct driver_options {
35 | METTLE_OPTIONAL_NS::optional timeout;
36 | filter_set filters;
37 | };
38 |
39 | METTLE_PUBLIC boost::program_options::options_description
40 | make_driver_options(driver_options &opts);
41 |
42 | enum class color_option {
43 | never,
44 | automatic,
45 | always
46 | };
47 |
48 | METTLE_PUBLIC bool
49 | color_enabled(color_option opt, int fd = 1 /* STDOUT_FILENO */);
50 |
51 | struct output_options {
52 | std::string output = "brief";
53 | color_option color = color_option::automatic;
54 | std::size_t runs = 1;
55 | bool show_terminal = false;
56 | bool show_time = false;
57 | };
58 |
59 | using logger_factory = object_factory<
60 | std::unique_ptr(indenting_ostream &, const output_options &)
61 | >;
62 | METTLE_PUBLIC logger_factory make_logger_factory();
63 |
64 | METTLE_PUBLIC boost::program_options::options_description
65 | make_output_options(output_options &opts, const logger_factory &factory);
66 |
67 | METTLE_PUBLIC boost::program_options::option_description *
68 | has_option(const boost::program_options::options_description &options,
69 | const boost::program_options::variables_map &args);
70 |
71 | template
72 | std::vector> filter_options(
73 | const boost::program_options::basic_parsed_options &parsed,
74 | const boost::program_options::options_description &desc
75 | ) {
76 | std::vector> filtered;
77 | for(auto &&option : parsed.options) {
78 | if(desc.find_nothrow(option.string_key, false)) {
79 | auto &&tokens = option.original_tokens;
80 | filtered.insert(filtered.end(), tokens.begin(), tokens.end());
81 | }
82 | }
83 | return filtered;
84 | }
85 |
86 | METTLE_PUBLIC attr_filter parse_attr(const std::string &value);
87 |
88 | METTLE_PUBLIC void
89 | validate(boost::any &v, const std::vector &values,
90 | color_option*, int);
91 |
92 | METTLE_PUBLIC void
93 | validate(boost::any &v, const std::vector &values,
94 | attr_filter_set*, int);
95 |
96 | METTLE_PUBLIC void
97 | validate(boost::any &v, const std::vector &values,
98 | name_filter_set*, int);
99 |
100 | } // namespace mettle
101 |
102 | // Put these in the boost namespace so that ADL picks them up (via the
103 | // boost::any parameter).
104 | namespace boost {
105 |
106 | METTLE_PUBLIC void
107 | validate(boost::any &v, const std::vector &values,
108 | std::chrono::milliseconds*, int);
109 |
110 | #ifdef _WIN32
111 | METTLE_PUBLIC void
112 | validate(boost::any &v, const std::vector &values, HANDLE*, int);
113 | #endif
114 |
115 | template
116 | void validate(boost::any &v, const std::vector &values,
117 | METTLE_OPTIONAL_NS::optional*, int) {
118 | using namespace boost::program_options;
119 | using optional_t = METTLE_OPTIONAL_NS::optional;
120 |
121 | if(v.empty())
122 | v = optional_t();
123 | auto *val = boost::any_cast(&v);
124 | assert(val);
125 |
126 | boost::any a;
127 | validate(a, values, static_cast(nullptr), 0);
128 | *val = boost::any_cast(a);
129 | }
130 |
131 | } // namespace boost
132 |
133 | #endif
134 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/mettle/driver/detail/bencode.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INC_METTLE_DRIVER_DETAIL_BENCODE_HPP
2 | #define INC_METTLE_DRIVER_DETAIL_BENCODE_HPP
3 |
4 | #ifdef METTLE_USE_STDLIB_EXTS
5 | # define BENCODE_USE_STDLIB_EXTS
6 | #endif
7 |
8 | #ifdef METTLE_NO_STDLIB_EXTS
9 | # define BENCODE_NO_STDLIB_EXTS
10 | #endif
11 |
12 | #include
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/mettle/driver/detail/export.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INC_METTLE_DRIVER_DETAIL_EXPORT_HPP
2 | #define INC_METTLE_DRIVER_DETAIL_EXPORT_HPP
3 |
4 | #if defined(_WIN32) && !defined(METTLE_STATIC)
5 | # ifdef LIBMETTLE_EXPORTS
6 | # define METTLE_PUBLIC __declspec(dllexport)
7 | # else
8 | # define METTLE_PUBLIC __declspec(dllimport)
9 | # endif
10 | #else
11 | # define METTLE_PUBLIC
12 | #endif
13 |
14 | #endif
15 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/mettle/driver/detail/optional.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INC_METTLE_DRIVER_DETAIL_OPTIONAL_HPP
2 | #define INC_METTLE_DRIVER_DETAIL_OPTIONAL_HPP
3 |
4 | // Get _LIBCPP_VERSION to detect libc++.
5 | #include
6 |
7 | // Try to use N4480's optional class, or fall back to Boost's.
8 | #if defined(METTLE_USE_STDLIB_EXTS)
9 | # include
10 | # define METTLE_OPTIONAL_NS std::experimental
11 | #elif !defined(METTLE_NO_STDLIB_EXTS) && defined(__has_include)
12 | // XXX: clang doesn't support SFINAE in variadic templates, which libstdc++'s
13 | // `optional` relies on. See .
14 | # if !(defined(__clang__) && !defined(_LIBCPP_VERSION) && \
15 | defined(__GLIBCXX__)) && __has_include()
16 | # include
17 | # define METTLE_OPTIONAL_NS std::experimental
18 | # else
19 | # include
20 | # include
21 | # define METTLE_OPTIONAL_NS boost
22 | # endif
23 | #else
24 | # include
25 | # include
26 | # define METTLE_OPTIONAL_NS boost
27 | #endif
28 |
29 | #endif
30 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/mettle/driver/exit_code.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INC_METTLE_DRIVER_EXIT_CODE_HPP
2 | #define INC_METTLE_DRIVER_EXIT_CODE_HPP
3 |
4 | namespace mettle {
5 |
6 | namespace exit_code {
7 | // Exit codes >= 64 are designed to match sysexits.h values.
8 | constexpr const int success = 0;
9 | constexpr const int failure = 1;
10 | constexpr const int timeout = 32;
11 | constexpr const int bad_args = 64;
12 | constexpr const int no_inputs = 66;
13 | constexpr const int unknown_error = 70;
14 | constexpr const int fatal = 71;
15 | }
16 |
17 | } // namespace mettle
18 |
19 | #endif
20 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/mettle/driver/filters.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INC_METTLE_DRIVER_FILTERS_HPP
2 | #define INC_METTLE_DRIVER_FILTERS_HPP
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 |
10 | #include "filters_core.hpp"
11 | #include "detail/export.hpp"
12 |
13 | namespace mettle {
14 |
15 | class name_filter_set {
16 | public:
17 | using value_type = std::regex;
18 | using container_type = std::vector;
19 | using iterator = container_type::const_iterator;
20 |
21 | name_filter_set() = default;
22 | name_filter_set(std::initializer_list i) : filters_(i) {}
23 |
24 | METTLE_PUBLIC filter_result
25 | operator ()(const test_name &name, const attributes &) const;
26 |
27 | void insert(const value_type &item) {
28 | filters_.push_back(item);
29 | }
30 |
31 | void insert(value_type &&item) {
32 | filters_.push_back(std::move(item));
33 | }
34 |
35 | bool empty() const {
36 | return filters_.empty();
37 | }
38 |
39 | std::size_t size() const {
40 | return filters_.size();
41 | }
42 |
43 | iterator begin() const {
44 | return filters_.begin();
45 | }
46 |
47 | iterator end() const {
48 | return filters_.end();
49 | }
50 | private:
51 | container_type filters_;
52 | };
53 |
54 | struct attr_filter_item {
55 | std::string attribute;
56 | std::function func;
57 | };
58 |
59 | inline attr_filter_item
60 | has_attr(std::string name) {
61 | return {std::move(name), [](const attr_instance *attr) -> bool {
62 | return attr != nullptr;
63 | }};
64 | }
65 |
66 | inline attr_filter_item
67 | has_attr(std::string name, std::string value) {
68 | auto f = [value = std::move(value)](const attr_instance *attr) -> bool {
69 | return attr && attr->value.count(value);
70 | };
71 | return {std::move(name), std::move(f)};
72 | }
73 |
74 | inline attr_filter_item
75 | operator !(attr_filter_item filter) {
76 | auto f = [func = std::move(filter.func)](const attr_instance *attr) -> bool {
77 | return !func(attr);
78 | };
79 | return {std::move(filter.attribute), std::move(f)};
80 | }
81 |
82 | class attr_filter {
83 | public:
84 | using value_type = attr_filter_item;
85 | using container_type = std::vector;
86 | using iterator = container_type::const_iterator;
87 |
88 | attr_filter() = default;
89 | attr_filter(std::initializer_list i) : filters_(i) {}
90 |
91 | METTLE_PUBLIC filter_result
92 | operator ()(const test_name &, const attributes &attrs) const;
93 |
94 | void insert(const value_type &item) {
95 | filters_.push_back(item);
96 | }
97 |
98 | void insert(value_type &&item) {
99 | filters_.push_back(std::move(item));
100 | }
101 |
102 | bool empty() const {
103 | return filters_.empty();
104 | }
105 |
106 | std::size_t size() const {
107 | return filters_.size();
108 | }
109 |
110 | iterator begin() const {
111 | return filters_.begin();
112 | }
113 |
114 | iterator end() const {
115 | return filters_.end();
116 | }
117 | private:
118 | container_type filters_;
119 | };
120 |
121 | class attr_filter_set {
122 | public:
123 | using value_type = attr_filter;
124 | using container_type = std::vector;
125 | using iterator = container_type::const_iterator;
126 |
127 | attr_filter_set() = default;
128 | attr_filter_set(std::initializer_list i) : filters_(i) {}
129 |
130 | METTLE_PUBLIC filter_result
131 | operator ()(const test_name &, const attributes &attrs) const;
132 |
133 | void insert(const value_type &item) {
134 | filters_.push_back(item);
135 | }
136 |
137 | void insert(value_type &&item) {
138 | filters_.push_back(std::move(item));
139 | }
140 |
141 | bool empty() const {
142 | return filters_.empty();
143 | }
144 |
145 | std::size_t size() const {
146 | return filters_.size();
147 | }
148 |
149 | iterator begin() const {
150 | return filters_.begin();
151 | }
152 |
153 | iterator end() const {
154 | return filters_.end();
155 | }
156 | private:
157 | container_type filters_;
158 | };
159 |
160 | struct filter_set {
161 | name_filter_set by_name;
162 | attr_filter_set by_attr;
163 |
164 | filter_result
165 | operator ()(const test_name &name, const attributes &attrs) const {
166 | auto first = by_name(name, attrs);
167 | if(first.action == test_action::hide)
168 | return first;
169 |
170 | auto second = by_attr(name, attrs);
171 | if(second.action == test_action::indeterminate)
172 | return first;
173 | return second;
174 | }
175 | };
176 |
177 | } // namespace mettle
178 |
179 | #endif
180 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/mettle/driver/filters_core.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INC_METTLE_DRIVER_FILTERS_CORE_HPP
2 | #define INC_METTLE_DRIVER_FILTERS_CORE_HPP
3 |
4 | #include "../suite/attributes.hpp"
5 | #include "../detail/string_algorithm.hpp"
6 | #include "test_name.hpp"
7 |
8 | namespace mettle {
9 |
10 | struct filter_result {
11 | filter_result() = default;
12 | filter_result(test_action action, std::string message = "")
13 | : action(action), message(std::move(message)) {}
14 |
15 | test_action action;
16 | std::string message;
17 | };
18 |
19 | struct default_filter {
20 | filter_result operator ()(const test_name &, const attributes &) const {
21 | return test_action::indeterminate;
22 | }
23 | };
24 |
25 | inline filter_result filter_by_attr(const attributes &attrs) {
26 | using namespace detail;
27 | for(const auto &attr : attrs) {
28 | if(attr.attribute.action() == test_action::skip)
29 | return {test_action::skip, stringify(joined(attr.value))};
30 | }
31 | return test_action::run;
32 | }
33 |
34 | } // namespace mettle
35 |
36 | #endif
37 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/mettle/driver/header_driver.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INC_METTLE_DRIVER_HEADER_DRIVER_HPP
2 | #define INC_METTLE_DRIVER_HEADER_DRIVER_HPP
3 |
4 | #include
5 |
6 | #define METTLE_STATIC
7 |
8 | #include "run_tests.hpp"
9 | #include "log/indent.hpp"
10 | #include "log/simple_summary.hpp"
11 | #include "../suite/detail/all_suites.hpp"
12 | #include "../suite/detail/built_in_attrs.hpp"
13 |
14 | int main() {
15 | using namespace mettle;
16 |
17 | indenting_ostream out(std::cout);
18 |
19 | log::simple_summary logger(out);
20 | run_tests(detail::all_suites(), logger, inline_test_runner);
21 | logger.summarize();
22 | return !logger.good();
23 | }
24 |
25 | #endif
26 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/mettle/driver/lib_driver.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INC_METTLE_DRIVER_LIB_DRIVER_HPP
2 | #define INC_METTLE_DRIVER_LIB_DRIVER_HPP
3 |
4 | #include "detail/export.hpp"
5 | #include "../suite/detail/all_suites.hpp"
6 | #include "../suite/detail/built_in_attrs.hpp"
7 |
8 | namespace mettle {
9 |
10 | namespace detail {
11 | METTLE_PUBLIC int
12 | drive_tests(int argc, const char *argv[], const suites_list &suites);
13 | }
14 |
15 | } // namespace mettle
16 |
17 | int main(int argc, const char *argv[]) {
18 | return mettle::detail::drive_tests(argc, argv, mettle::detail::all_suites());
19 | }
20 |
21 | #endif
22 |
--------------------------------------------------------------------------------
/BowlingTests.Mettle/mettle/driver/object_factory.hpp:
--------------------------------------------------------------------------------
1 | #ifndef INC_METTLE_DRIVER_OBJECT_FACTORY_HPP
2 | #define INC_METTLE_DRIVER_OBJECT_FACTORY_HPP
3 |
4 | #include
5 | #include