Add unit test for constantTimeCompare.

This commit is contained in:
Juliusz Chroboczek committed 2025-01-22 00:28:26 +01:00
1 parent 7bb70b4339
commit e8538bdf3b
1 file changed
+22
+22
View File
@@ -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{})