-
Notifications
You must be signed in to change notification settings - Fork 92
/
remove_invalid_parentheses_test.go
35 lines (30 loc) · 954 Bytes
/
remove_invalid_parentheses_test.go
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 (
"slices"
"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); !slices.Equal(got, test.outputs) {
t.Errorf("Failed test case #%d. Want %#v got %#v", i, test.outputs, got)
}
}
}