Wire Sysio
Wire Sysion 1.0.0
Toggle main menu visibility
Main Page
Related Pages
Topics
Namespaces
Namespace List
Namespace Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
y
Enumerations
a
b
c
d
e
f
g
h
i
k
l
m
o
p
r
s
t
u
v
Enumerator
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
z
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
:
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Typedefs
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
y
Enumerations
_
a
b
c
e
f
i
k
l
m
o
p
r
s
t
u
v
w
y
Enumerator
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Properties
Related Symbols
:
a
b
c
d
e
f
g
h
i
l
m
n
o
p
q
r
s
t
u
v
z
Files
File List
File Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
r
s
t
u
v
w
x
y
z
Typedefs
_
a
b
c
d
e
f
g
h
i
j
l
m
o
p
r
s
t
u
v
w
x
y
z
Enumerations
a
c
e
f
h
l
n
o
p
r
s
t
u
w
x
y
Enumerator
_
a
b
c
d
e
f
i
k
l
m
n
o
p
r
s
t
u
x
y
Macros
_
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Modules
Pages
Loading...
Searching...
No Matches
010-TestCase.cpp
Go to the documentation of this file.
1
// 010-TestCase.cpp
2
3
// Let Catch provide main():
4
#define CATCH_CONFIG_MAIN
5
6
#include <
catch2/catch.hpp
>
7
8
int
Factorial
(
int
number ) {
9
return
number <= 1 ? number :
Factorial
( number - 1 ) * number;
// fail
10
// return number <= 1 ? 1 : Factorial( number - 1 ) * number; // pass
11
}
8
int
Factorial
(
int
number ) {
…
}
12
13
TEST_CASE
(
"Factorial of 0 is 1 (fail)"
,
"[single-file]"
) {
14
REQUIRE
(
Factorial
(0) == 1 );
15
}
13
TEST_CASE
(
"Factorial of 0 is 1 (fail)"
,
"[single-file]"
) {
…
}
16
17
TEST_CASE
(
"Factorials of 1 and higher are computed (pass)"
,
"[single-file]"
) {
18
REQUIRE
(
Factorial
(1) == 1 );
19
REQUIRE
(
Factorial
(2) == 2 );
20
REQUIRE
(
Factorial
(3) == 6 );
21
REQUIRE
(
Factorial
(10) == 3628800 );
22
}
17
TEST_CASE
(
"Factorials of 1 and higher are computed (pass)"
,
"[single-file]"
) {
…
}
23
24
// Compile & run:
25
// - g++ -std=c++11 -Wall -I$(CATCH_SINGLE_INCLUDE) -o 010-TestCase 010-TestCase.cpp && 010-TestCase --success
26
// - cl -EHsc -I%CATCH_SINGLE_INCLUDE% 010-TestCase.cpp && 010-TestCase --success
27
28
// Expected compact output (all assertions):
29
//
30
// prompt> 010-TestCase --reporter compact --success
31
// 010-TestCase.cpp:14: failed: Factorial(0) == 1 for: 0 == 1
32
// 010-TestCase.cpp:18: passed: Factorial(1) == 1 for: 1 == 1
33
// 010-TestCase.cpp:19: passed: Factorial(2) == 2 for: 2 == 2
34
// 010-TestCase.cpp:20: passed: Factorial(3) == 6 for: 6 == 6
35
// 010-TestCase.cpp:21: passed: Factorial(10) == 3628800 for: 3628800 (0x375f00) == 3628800 (0x375f00)
36
// Failed 1 test case, failed 1 assertion.
Factorial
int Factorial(int number)
Definition
010-TestCase.cpp:8
TEST_CASE
#define TEST_CASE(...)
Definition
catch.hpp:222
REQUIRE
#define REQUIRE(...)
Definition
catch.hpp:185
catch.hpp
libraries
sys-vm
external
Catch2
examples
010-TestCase.cpp
Generated by
1.12.0