From cc3217b0107f6103a71bab0cf3f55914dc8c3c2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furkan=20T=C3=BCrkal?= Date: Tue, 12 Feb 2019 14:13:40 +0300 Subject: [PATCH] added travis CI --- .travis.yml | 9 ++++ .../linked-list-merge-two-sorted.go_test.go | 52 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 .travis.yml create mode 100644 linked-list-merge-two-sorted/linked-list-merge-two-sorted.go_test.go diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..035c75c --- /dev/null +++ b/.travis.yml @@ -0,0 +1,9 @@ +language: go +go: + - 1.8.x + - 1.9.x + - 1.10.x + - 1.11.x +script: + - go build -v ./... + - go test -v -cover -race ./... diff --git a/linked-list-merge-two-sorted/linked-list-merge-two-sorted.go_test.go b/linked-list-merge-two-sorted/linked-list-merge-two-sorted.go_test.go new file mode 100644 index 0000000..ef6ba08 --- /dev/null +++ b/linked-list-merge-two-sorted/linked-list-merge-two-sorted.go_test.go @@ -0,0 +1,52 @@ +// ==================================================== +// Data-Structures-with-Go Copyright(C) 2017 Furkan Türkal +// This program comes with ABSOLUTELY NO WARRANTY; This is free software, +// and you are welcome to redistribute it under certain conditions; See +// file LICENSE, which is part of this source code package, for details. +// ==================================================== + +package main + +import ( + "reflect" + "testing" +) + +func TestMergeTwoSortedNew(t *testing.T) { + var testDatas = []struct { + ArrayIn1 []int + ArrayIn2 []int + Out []int + }{ + {[]int{20, 4, 15, 85}, []int{6, 7}, []int{20, 4, 15, 85, -1, 6, 7}}, + {[]int{10, 20, 30}, []int{5, 6}, []int{10, 20, 30, -1, 5, 6}}, + {[]int{7}, []int{7}, []int{7, -1, 7}}, + {[]int{}, []int{}, []int{-1}}, + } + + for _, data := range testDatas { + + a := New() + b := New() + + for i := 0; i < len(data.ArrayIn1); i++ { + Push(&a, data.ArrayIn1[i]) + } + + for i := 0; i < len(data.ArrayIn2); i++ { + Push(&b, data.ArrayIn2[i]) + } + + actual := SortedMerge(a, b) + + expected := New() + + for i := 0; i < len(data.Out); i++ { + Push(&expected, data.Out[i]) + } + + if !reflect.DeepEqual(actual, expected) { + t.Errorf("MergeTwoSorted: Expected: %v, Actual: %v", GetDataList(expected), GetDataList(actual)) + } + } +}