From 12ab0a040a543fd7a306e401827cfa4e3e322e69 Mon Sep 17 00:00:00 2001 From: Shekhar Gulati Date: Sun, 17 Jul 2016 20:28:11 +0530 Subject: [PATCH] deleted files --- .../src/problems/closestpair.go | 25 --------------- .../src/problems/closestpair_test.go | 32 ------------------- .../src/problems/equalornoequal_test.go | 26 --------------- .../src/problems/equalornotequal.go | 9 ------ 4 files changed, 92 deletions(-) delete mode 100644 29-go-unit-testing/src/problems/closestpair.go delete mode 100644 29-go-unit-testing/src/problems/closestpair_test.go delete mode 100644 29-go-unit-testing/src/problems/equalornoequal_test.go delete mode 100644 29-go-unit-testing/src/problems/equalornotequal.go diff --git a/29-go-unit-testing/src/problems/closestpair.go b/29-go-unit-testing/src/problems/closestpair.go deleted file mode 100644 index c4fc717..0000000 --- a/29-go-unit-testing/src/problems/closestpair.go +++ /dev/null @@ -1,25 +0,0 @@ -package problems - -import ( - "math" - "sort" -) - -type Pair struct { - First, Second int -} - -func ClosestPair(numbers []int) Pair { - sort.Ints(numbers) - var pair Pair - var diff int = math.MaxInt32 - for index := 0; index < len(numbers)-1; index++ { - cur := numbers[index] - next := numbers[index+1] - if next-cur < diff { - diff = next - cur - pair = Pair{cur, next} - } - } - return pair -} diff --git a/29-go-unit-testing/src/problems/closestpair_test.go b/29-go-unit-testing/src/problems/closestpair_test.go deleted file mode 100644 index 84d192b..0000000 --- a/29-go-unit-testing/src/problems/closestpair_test.go +++ /dev/null @@ -1,32 +0,0 @@ -package problems_test - -import ( - "fmt" - "github.com/stretchr/testify/assert" - . "problems" - "testing" -) - -func TestFindClosestPair(t *testing.T) { - numbers := []int{2, 10, 5, 6, 15} - pair := ClosestPair(numbers) - assert.Equal(t, 5, pair.First, fmt.Sprintf("first should be 5 but was %d", pair.First)) - assert.Equal(t, 6, pair.Second, fmt.Sprintf("second should be 6 but was %d", pair.Second)) -} - -var closestPairTests = []struct { - in []int - out Pair -}{ - {[]int{2, 10, 5, 6, 15}, Pair{5, 6}}, - {[]int{2, 4, 5}, Pair{4, 5}}, - {[]int{100, 5, 7, 99, 11}, Pair{99, 100}}, -} - -func TestClosestPair(t *testing.T) { - for _, tt := range closestPairTests { - pair := ClosestPair(tt.in) - assert.Equal(t, tt.out.First, pair.First) - assert.Equal(t, tt.out.Second, pair.Second) - } -} diff --git a/29-go-unit-testing/src/problems/equalornoequal_test.go b/29-go-unit-testing/src/problems/equalornoequal_test.go deleted file mode 100644 index fb2e937..0000000 --- a/29-go-unit-testing/src/problems/equalornoequal_test.go +++ /dev/null @@ -1,26 +0,0 @@ -package problems_test - -import ( - "github.com/stretchr/testify/assert" - . "problems" - "testing" -) - -func TestShouldBeTrueWhenThreeNumbersAreEqual(t *testing.T) { - isThreeNumbersEqual := EqualOrNotEqual(1, 1, 1) - if !isThreeNumbersEqual { - t.Error("Expected true, got ", isThreeNumbersEqual) - } -} - -func TestShouldBeFalseWhenThreeNumbersAreNotEqual(t *testing.T) { - isThreeNumbersEqual := EqualOrNotEqual(1, 2, 3) - if isThreeNumbersEqual { - t.Error("Expected false, got", isThreeNumbersEqual) - } -} - -func TestShouldAssertThatFunctionReturnsFalseWhenThreeNumbersAreNotEqual(t *testing.T) { - isThreeNumbersEqual := EqualOrNotEqual(1, 2, 3) - assert.False(t, isThreeNumbersEqual, "Expected false got true") -} diff --git a/29-go-unit-testing/src/problems/equalornotequal.go b/29-go-unit-testing/src/problems/equalornotequal.go deleted file mode 100644 index 2e6f530..0000000 --- a/29-go-unit-testing/src/problems/equalornotequal.go +++ /dev/null @@ -1,9 +0,0 @@ -package problems - -func EqualOrNotEqual(first, second, third int) bool { - if first == second && second == third { - return true - } else { - return false - } -}