-
-
Notifications
You must be signed in to change notification settings - Fork 314
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Go 1.20 slices
package
#738
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -323,34 +323,6 @@ func TestDeleteVertex2(t *testing.T) { | |
} | ||
} | ||
|
||
func TestVertexContains1(t *testing.T) { | ||
v1 := NV("v1") | ||
v2 := NV("v2") | ||
v3 := NV("v3") | ||
if VertexContains(v1, []Vertex{v1, v2, v3}) != true { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can leave all the tests in, let's just test the new methods you're using! There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is there much point in testing stdlib functionality? The point of this change was to reduce the amount of code we're carrying. Less code -> easier to understand/reason about |
||
t.Errorf("should be true instead of false.") | ||
} | ||
|
||
v4 := NV("v4") | ||
v5 := NV("v5") | ||
v6 := NV("v6") | ||
if VertexContains(v4, []Vertex{v5, v6}) != false { | ||
t.Errorf("should be false instead of true.") | ||
} | ||
|
||
v7 := NV("v7") | ||
v8 := NV("v8") | ||
v9 := NV("v9") | ||
if VertexContains(v8, []Vertex{v7, v8, v9}) != true { | ||
t.Errorf("should be true instead of false.") | ||
} | ||
|
||
v1b := NV("v1") // same value, different objects | ||
if VertexContains(v1b, []Vertex{v1, v2, v3}) != false { | ||
t.Errorf("should be false instead of true.") | ||
} | ||
} | ||
|
||
func TestTopoSort1(t *testing.T) { | ||
G, _ := NewGraph("g9") | ||
v1 := NV("v1") | ||
|
@@ -683,31 +655,6 @@ func TestReachability4(t *testing.T) { | |
} | ||
} | ||
|
||
func TestReverse1(t *testing.T) { | ||
v1 := NV("v1") | ||
v2 := NV("v2") | ||
v3 := NV("v3") | ||
v4 := NV("v4") | ||
v5 := NV("v5") | ||
v6 := NV("v6") | ||
|
||
if rev := Reverse([]Vertex{}); !reflect.DeepEqual(rev, []Vertex{}) { | ||
t.Errorf("reverse of vertex slice failed (empty)") | ||
} | ||
|
||
if rev := Reverse([]Vertex{v1}); !reflect.DeepEqual(rev, []Vertex{v1}) { | ||
t.Errorf("reverse of vertex slice failed (single)") | ||
} | ||
|
||
if rev := Reverse([]Vertex{v1, v2, v3, v4, v5, v6}); !reflect.DeepEqual(rev, []Vertex{v6, v5, v4, v3, v2, v1}) { | ||
t.Errorf("reverse of vertex slice failed (1..6)") | ||
} | ||
|
||
if rev := Reverse([]Vertex{v6, v5, v4, v3, v2, v1}); !reflect.DeepEqual(rev, []Vertex{v1, v2, v3, v4, v5, v6}) { | ||
t.Errorf("reverse of vertex slice failed (6..1)") | ||
} | ||
} | ||
|
||
func TestCopy1(t *testing.T) { | ||
g1 := &Graph{} | ||
g2 := g1.Copy() // check this doesn't panic | ||
|
@@ -750,54 +697,6 @@ func TestGraphCmp1(t *testing.T) { | |
// } | ||
//} | ||
|
||
func TestSort0(t *testing.T) { | ||
vs := []Vertex{} | ||
s := Sort(vs) | ||
|
||
if !reflect.DeepEqual(s, []Vertex{}) { | ||
t.Errorf("sort failed!") | ||
if s == nil { | ||
t.Logf("output is nil!") | ||
} else { | ||
str := "Got:" | ||
for _, v := range s { | ||
str += " " + v.String() | ||
} | ||
t.Errorf(str) | ||
} | ||
} | ||
} | ||
|
||
func TestSort1(t *testing.T) { | ||
v1 := NV("v1") | ||
v2 := NV("v2") | ||
v3 := NV("v3") | ||
v4 := NV("v4") | ||
v5 := NV("v5") | ||
v6 := NV("v6") | ||
|
||
vs := []Vertex{v3, v2, v6, v1, v5, v4} | ||
s := Sort(vs) | ||
|
||
if !reflect.DeepEqual(s, []Vertex{v1, v2, v3, v4, v5, v6}) { | ||
t.Errorf("sort failed!") | ||
str := "Got:" | ||
for _, v := range s { | ||
str += " " + v.String() | ||
} | ||
t.Errorf(str) | ||
} | ||
|
||
if !reflect.DeepEqual(vs, []Vertex{v3, v2, v6, v1, v5, v4}) { | ||
t.Errorf("sort modified input!") | ||
str := "Got:" | ||
for _, v := range vs { | ||
str += " " + v.String() | ||
} | ||
t.Errorf(str) | ||
} | ||
} | ||
|
||
func TestSprint1(t *testing.T) { | ||
g, _ := NewGraph("graph1") | ||
v1 := NV("v1") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please leave these alone for now. Explicitly seeing the list is more logical at least for me.