Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 364f816

Browse files
Create connecting-cities-with-minimum-cost_test.go
1 parent d3bc759 commit 364f816

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package connecting_cities_with_minimum_cost
2+
3+
import "testing"
4+
5+
func Test_minimumCost(t *testing.T) {
6+
type args struct {
7+
n int
8+
connections [][]int
9+
}
10+
tests := []struct {
11+
name string
12+
args args
13+
want int
14+
}{
15+
{
16+
name: "test case 1",
17+
args: args{
18+
n: 3,
19+
connections: [][]int{
20+
{1, 2, 5},
21+
{1, 3, 6},
22+
{2, 3, 1},
23+
},
24+
},
25+
want: 6,
26+
},
27+
{
28+
name: "test case 2",
29+
args: args{
30+
n: 4,
31+
connections: [][]int{
32+
{1, 2, 3},
33+
{3, 4, 4},
34+
},
35+
},
36+
want: -1,
37+
},
38+
}
39+
for _, tt := range tests {
40+
t.Run(tt.name, func(t *testing.T) {
41+
if got := minimumCost(tt.args.n, tt.args.connections); got != tt.want {
42+
t.Errorf("minimumCost() = %v, want %v", got, tt.want)
43+
}
44+
})
45+
}
46+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /