Skip to content
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

Go challenge 3 #427

Merged
merged 4 commits into from
Jan 24, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add test cases
  • Loading branch information
naren committed Jan 18, 2017
commit 69d824d28318a901c42cfab9d5241b985bfcb912
41 changes: 41 additions & 0 deletions challenge_2/rust/makernaren/max_occurance_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
// max_occurance_test
package main

import (
"testing"
)

func TestIntegers(t *testing.T) {
input := []interface{}{2, 2, 3, 3, 4, 4, 4, 4, 5, 5, 6}
output := 4
result := FindMajority(input)
if result != output {
t.Error("for", input,
"expected", output,
"got", result)
}
}

func TestStrings(t *testing.T) {
input := []interface{}{"a", "a", "b", "b", "b", "b", "c", "c", "c", "c",
"c", "d", "d", "e"}
output := "c"
result := FindMajority(input)
if result != output {
t.Error("for", input,
"expected", output,
"got", result)
}
}

func TestMultipleTypes(t *testing.T) {
input := []interface{}{2, "a", "l", 3, "l", 4, "k", 2, 3, 4, "a", 6, "c",
4, "m", 6, "m", "k", 9, 10, 9, 8, 7, 8, 10, 7, 7, 7, 7, 7, 7, 7, 7, 7}
output := 7
result := FindMajority(input)
if result != output {
t.Error("for", input,
"expected", output,
"got", result)
}
}