-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.rs
48 lines (36 loc) · 809 Bytes
/
example.rs
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
// An example of using the framework
// licensed: public domain or cc0
use tester::*;
mod tester;
fn foo(a: float, b: float) -> float {
a + b
}
describe!("test", {
test!("foo", {
should!("add two numbers", {
let a = 5.0;
let b = 5.0;
must!(foo(a, b) eq 10.0);
})
should!("add a positive and negative number", {
let a = 5.0;
let b = -5.0;
must!(foo(a, b) eq 0.0);
})
should!("add a negative and positive number", {
let a = -5.0;
let b = 5.0;
must!(foo(a, b) eq 0.0);
})
should!("add two negative numbers", {
let a = -5.0;
let b = -5.0;
must!(foo(a, b) eq -10.0);
})
should!("add two fractions", {
let a = 1.25;
let b = 3.13;
must!(foo(a, b) near 4.38);
})
})
})