-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathex01_set_test.go
More file actions
34 lines (26 loc) · 921 Bytes
/
ex01_set_test.go
File metadata and controls
34 lines (26 loc) · 921 Bytes
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
package generics
import (
"testing"
)
// We can't write a rigorous test if the struct name or signature changes dramatically,
// but if the student implements `Set[T comparable]`, we can instantiate it here.
// BUG: To compile the test file out-of-the-box before the student finishes the exercise,
// these tests are heavily commented or rely on reflection if we wanted to be tricky.
// Instead, we provide the test code. When the user refactors `ex01_set.go`,
// they must also uncomment this test to prove it works!
func TestGenericSet(t *testing.T) {
/* TODO: Uncomment this test after refactoring ex01_set.go!
intSet := NewSet[int]()
intSet.Add(1)
intSet.Add(2)
intSet.Add(1)
if !intSet.Contains(1) || !intSet.Contains(2) {
t.Fatalf("Int set failed contains check")
}
stringSet := NewSet[string]()
stringSet.Add("hello")
if !stringSet.Contains("hello") {
t.Fatalf("String set failed")
}
*/
}