forked from spring1843/go-dsa
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove_invalid_parentheses_test.go
More file actions
35 lines (30 loc) · 960 Bytes
/
remove_invalid_parentheses_test.go
File metadata and controls
35 lines (30 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package graph
import (
"reflect"
"testing"
)
/*
TestRemoveInvalidParentheses tests solution(s) with the following signature and problem description:
func RemoveInvalidParentheses(input string) []string
Given a string containing parentheses and other alphabet letters like `(z)())()`, remove the minimum
amount of parentheses to make the string valid like `(z())()` and `(z)()()`.
*/
func TestRemoveInvalidParentheses(t *testing.T) {
tests := []struct {
input string
outputs []string
}{
{"", []string{}},
{")(", []string{""}},
{")v(", []string{"v"}},
{"(v)", []string{"(v)"}},
{"(z)())()", []string{"(z())()", "(z)()()"}},
{"()()z)()", []string{"(()z)()", "()(z)()", "()()z()"}},
{"()())()", []string{"(())()", "()()()"}},
}
for i, test := range tests {
if got := RemoveInvalidParentheses(test.input); !reflect.DeepEqual(got, test.outputs) {
t.Errorf("Failed test case #%d. Want %#v got %#v", i, test.outputs, got)
}
}
}