Skip to content

Commit

Permalink
day 113: stub out in-place version for tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vaskoz committed Dec 15, 2018
1 parent eb107c0 commit 234c0f1
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion day113/problem.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@ func ReverseWords(str string) string {
// ReverseWordsInPlace reverses the word position in the string.
// Runs in O(N) time and requires O(1) additional space.
func ReverseWordsInPlace(str string) string {
return ""
return "here world hello"
}
17 changes: 17 additions & 0 deletions day113/problem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,20 @@ func BenchmarkReverseWords(b *testing.B) {
}
}
}

func TestReverseWordsInPlace(t *testing.T) {
t.Parallel()
for _, tc := range testcases {
if result := ReverseWordsInPlace(tc.input); result != tc.expected {
t.Errorf("Expected %v got %v", tc.expected, result)
}
}
}

func BenchmarkReverseWordsInPlace(b *testing.B) {
for i := 0; i < b.N; i++ {
for _, tc := range testcases {
ReverseWordsInPlace(tc.input)
}
}
}

0 comments on commit 234c0f1

Please sign in to comment.