-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
run_test.v
143 lines (125 loc) · 4.58 KB
/
run_test.v
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
module main
fn test_empty_roster() {
roster := create_new_roster()
assert get_all_students(roster) == []
}
fn test_roster_one_person() {
mut roster := create_new_roster()
roster = add_student(roster, 'Aimee', 1)
assert get_all_students(roster) == ['Aimee']
}
fn test_roster_three_people() {
mut roster := create_new_roster()
roster = add_student(roster, 'Blair', 2)
roster = add_student(roster, 'James', 2)
roster = add_student(roster, 'Paul', 2)
assert get_all_students(roster) == ['Blair', 'James', 'Paul']
}
fn test_roster_duplicate_in_same_grade() {
mut roster := create_new_roster()
roster = add_student(roster, 'Blair', 2)
roster = add_student(roster, 'James', 2)
roster = add_student(roster, 'James', 2)
roster = add_student(roster, 'Paul', 2)
assert get_all_students(roster) == ['Blair', 'James', 'Paul']
}
fn test_cant_have_one_person_in_two_grades() {
mut roster := create_new_roster()
roster = add_student(roster, 'Aimee', 1)
roster = add_student(roster, 'Aimee', 2)
assert get_students_in_grade(roster, 2) == []
}
fn test_just_one_person_duplicated() {
mut roster := create_new_roster()
roster = add_student(roster, 'Aimee', 2)
roster = add_student(roster, 'Aimee', 2)
assert get_all_students(roster) == ['Aimee']
}
fn test_students_added_to_multiple_grades() {
mut roster := create_new_roster()
roster = add_student(roster, 'Chelsea', 3)
roster = add_student(roster, 'Logan', 7)
assert get_all_students(roster) == ['Chelsea', 'Logan']
}
fn test_adding_same_student_multiple_grades() {
mut roster := create_new_roster()
roster = add_student(roster, 'Blair', 2)
roster = add_student(roster, 'James', 2)
roster = add_student(roster, 'James', 3)
roster = add_student(roster, 'Paul', 3)
assert get_all_students(roster) == ['Blair', 'James', 'Paul']
}
fn test_just_one_person_multiple_grades() {
mut roster := create_new_roster()
roster = add_student(roster, 'Aimee', 2)
roster = add_student(roster, 'Aimee', 1)
assert get_all_students(roster) == ['Aimee']
}
fn test_students_sorted_by_grade() {
mut roster := create_new_roster()
roster = add_student(roster, 'Jim', 3)
roster = add_student(roster, 'Peter', 2)
roster = add_student(roster, 'Anna', 1)
assert get_all_students(roster) == ['Anna', 'Peter', 'Jim']
}
fn test_students_sorted_by_name() {
mut roster := create_new_roster()
roster = add_student(roster, 'Peter', 2)
roster = add_student(roster, 'Zoe', 2)
roster = add_student(roster, 'Alex', 2)
assert get_all_students(roster) == ['Alex', 'Peter', 'Zoe']
}
fn test_students_sorted_by_grade_then_name() {
mut roster := create_new_roster()
roster = add_student(roster, 'Peter', 2)
roster = add_student(roster, 'Anna', 1)
roster = add_student(roster, 'Barb', 1)
roster = add_student(roster, 'Zoe', 2)
roster = add_student(roster, 'Alex', 2)
roster = add_student(roster, 'Jim', 3)
roster = add_student(roster, 'Charlie', 1)
assert get_all_students(roster) == ['Anna', 'Barb', 'Charlie', 'Alex', 'Peter', 'Zoe', 'Jim']
}
fn test_grade_empty_if_no_students_overall() {
mut roster := create_new_roster()
assert get_students_in_grade(roster, 1) == []
}
fn test_grade_empty_if_no_students_in_that_grade() {
mut roster := create_new_roster()
roster = add_student(roster, 'Peter', 2)
roster = add_student(roster, 'Zoe', 2)
roster = add_student(roster, 'Alex', 2)
roster = add_student(roster, 'Jim', 3)
assert get_students_in_grade(roster, 1) == []
}
fn test_adding_same_student_twice_just_query_grade() {
mut roster := create_new_roster()
roster = add_student(roster, 'Blair', 2)
roster = add_student(roster, 'James', 2)
roster = add_student(roster, 'James', 2)
roster = add_student(roster, 'Paul', 2)
assert get_students_in_grade(roster, 2) == ['Blair', 'James', 'Paul']
}
fn test_adding_same_student_two_grades_just_query_grade_2() {
mut roster := create_new_roster()
roster = add_student(roster, 'Blair', 2)
roster = add_student(roster, 'James', 2)
roster = add_student(roster, 'James', 3)
roster = add_student(roster, 'Paul', 3)
assert get_students_in_grade(roster, 2) == ['Blair', 'James']
}
fn test_adding_same_student_two_grades_just_query_grade_3() {
mut roster := create_new_roster()
roster = add_student(roster, 'Blair', 2)
roster = add_student(roster, 'James', 2)
roster = add_student(roster, 'James', 3)
roster = add_student(roster, 'Paul', 3)
assert get_students_in_grade(roster, 3) == ['Paul']
}
fn test_students_sorted_by_name_in_grade() {
mut roster := create_new_roster()
roster = add_student(roster, 'Franklin', 5)
roster = add_student(roster, 'Bradley', 5)
roster = add_student(roster, 'Jeff', 1)
assert get_students_in_grade(roster, 5) == ['Bradley', 'Franklin']
}