-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtask_list_tests.hum
More file actions
80 lines (60 loc) · 1.45 KB
/
Copy pathtask_list_tests.hum
File metadata and controls
80 lines (60 loc) · 1.45 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
module examples.task_list_tests
test add_item rejects empty title {
why:
empty tasks should never be saved
uses:
fake tasks
covers:
add_item fails when title is empty
TaskError.empty_title
does:
expect add_item("") fails with TaskError.empty_title
}
test add_item saves nonempty title(title: Text) property {
why:
any meaningful title should become a saved active task
uses:
fake tasks
needs:
title is not empty
title is not only spaces
covers:
add_item ensures new item is saved
add_item ensures new item is not done
cost:
time: O(1)
space: O(1)
check: warn
does:
let result = add_item(title)
expect result is ok
expect tasks contains item with title
expect saved item is not done
}
test fuzz task titles(title_bytes: Bytes) fuzz {
why:
user text may contain unusual bytes or whitespace
uses:
fake tasks
covers:
add_item watch for title may be only spaces
avoids:
panic on invalid text input
does:
let title = decode text title_bytes or ""
call add_item(title)
expect no panic
}
test empty title with spaces is rejected regression {
why:
prevent blank-looking tasks from being saved again
uses:
fake tasks
regression:
found when title " " was accepted as nonempty
covers:
add_item watch for title may be only spaces
TaskError.empty_title
does:
expect add_item(" ") fails with TaskError.empty_title
}