Add unit test for constantTimeCompare.
This commit is contained in:
1 parent
7bb70b4339
commit
e8538bdf3b
1 file changed
+22
@@ -11,6 +11,28 @@ import (
|
||||
"github.com/pion/webrtc/v3"
|
||||
)
|
||||
|
||||
func TestConstantTimeCompare(t *testing.T) {
|
||||
tests := []struct {
|
||||
a, b string
|
||||
}{
|
||||
{"", ""},
|
||||
{"a", "a"},
|
||||
{"foo", "foo"},
|
||||
{"foo", "bar"},
|
||||
{"foo", "foo1"},
|
||||
{"foo1", "foo"},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
e := constantTimeCompare(test.a, test.b)
|
||||
if e != (test.a == test.b) {
|
||||
t.Errorf("constantTimeCompare(%v, %v): got %v",
|
||||
test.a, test.b, e,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
func TestGroup(t *testing.T) {
|
||||
groups.groups = nil
|
||||
Add("group", &Description{})
|
||||
|
||||
Reference in new issue
Block a user