Skip to content

Commit cc3217b

Browse files
committed
added travis CI
1 parent 3610263 commit cc3217b

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

.travis.yml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: go
2+
go:
3+
- 1.8.x
4+
- 1.9.x
5+
- 1.10.x
6+
- 1.11.x
7+
script:
8+
- go build -v ./...
9+
- go test -v -cover -race ./...
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
// ====================================================
2+
// Data-Structures-with-Go Copyright(C) 2017 Furkan Türkal
3+
// This program comes with ABSOLUTELY NO WARRANTY; This is free software,
4+
// and you are welcome to redistribute it under certain conditions; See
5+
// file LICENSE, which is part of this source code package, for details.
6+
// ====================================================
7+
8+
package main
9+
10+
import (
11+
"reflect"
12+
"testing"
13+
)
14+
15+
func TestMergeTwoSortedNew(t *testing.T) {
16+
var testDatas = []struct {
17+
ArrayIn1 []int
18+
ArrayIn2 []int
19+
Out []int
20+
}{
21+
{[]int{20, 4, 15, 85}, []int{6, 7}, []int{20, 4, 15, 85, -1, 6, 7}},
22+
{[]int{10, 20, 30}, []int{5, 6}, []int{10, 20, 30, -1, 5, 6}},
23+
{[]int{7}, []int{7}, []int{7, -1, 7}},
24+
{[]int{}, []int{}, []int{-1}},
25+
}
26+
27+
for _, data := range testDatas {
28+
29+
a := New()
30+
b := New()
31+
32+
for i := 0; i < len(data.ArrayIn1); i++ {
33+
Push(&a, data.ArrayIn1[i])
34+
}
35+
36+
for i := 0; i < len(data.ArrayIn2); i++ {
37+
Push(&b, data.ArrayIn2[i])
38+
}
39+
40+
actual := SortedMerge(a, b)
41+
42+
expected := New()
43+
44+
for i := 0; i < len(data.Out); i++ {
45+
Push(&expected, data.Out[i])
46+
}
47+
48+
if !reflect.DeepEqual(actual, expected) {
49+
t.Errorf("MergeTwoSorted: Expected: %v, Actual: %v", GetDataList(expected), GetDataList(actual))
50+
}
51+
}
52+
}

0 commit comments

Comments
 (0)