-
Notifications
You must be signed in to change notification settings - Fork 0
/
cell_test.gleam
70 lines (61 loc) · 1.52 KB
/
cell_test.gleam
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
61
62
63
64
65
66
67
68
69
70
//// test/cell_test.gleam
////
//// Module: cell_test
////
//// Test module for cell.
////
//// API:
//// - main() -> Nil
//// - new_test() -> Nil
//// - is_alive_test() -> Nil
//// - is_dead_test() -> Nil
//// - toggle_test() -> Nil
//// - get_location_test() -> Nil
//// Internal:
//// * None
// External imports:
import gleeunit as gle
import gleeunit/should as sho
// Local imports:
import cell as cel
import location as loc
// Public:
/// Setup for testing.
pub fn main() -> Nil {
gle.main()
}
/// Test the cell constructor.
pub fn new_test() -> Nil {
cel.new(loc.new(16, -14), False)
|> sho.equal(cel.Dead(#(16, -14)))
cel.new(loc.new(19, -4), True)
|> sho.equal(cel.Alive(#(19, -4)))
}
/// Test the is_alive function.
pub fn is_alive_test() -> Nil {
cel.is_alive(cel.new(loc.new(33, -14), True))
|> sho.equal(True)
cel.is_alive(cel.new(loc.new(47, 0), False))
|> sho.equal(False)
}
/// Test the is_dead function.
pub fn is_dead_test() -> Nil {
cel.is_dead(cel.new(loc.new(10, -10), False))
|> sho.equal(True)
cel.is_dead(cel.new(loc.new(11, 6), True))
|> sho.equal(False)
}
/// Test the toggle function.
pub fn toggle_test() -> Nil {
cel.is_alive(cel.toggle(cel.new(loc.new(10, -10), False)))
|> sho.equal(True)
cel.is_dead(cel.toggle(cel.new(loc.new(11, 6), True)))
|> sho.equal(True)
}
/// Test the get_location function.
pub fn get_location_test() -> Nil {
cel.get_location(cel.new(loc.new(8, 0), True))
|> sho.equal(#(8, 0))
cel.get_location(cel.new(loc.new(0, 0), False))
|> sho.equal(#(0, 0))
}