mirror of https://github.com/v2ray/v2ray-core
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
666 B
44 lines
666 B
6 years ago
|
package compare_test
|
||
|
|
||
|
import (
|
||
|
"testing"
|
||
|
|
||
|
. "v2ray.com/core/common/compare"
|
||
|
)
|
||
|
|
||
|
func TestBytesEqual(t *testing.T) {
|
||
|
testCases := []struct {
|
||
|
Input1 []byte
|
||
|
Input2 []byte
|
||
|
Result bool
|
||
|
}{
|
||
|
{
|
||
|
Input1: []byte{},
|
||
|
Input2: []byte{1},
|
||
|
Result: false,
|
||
|
},
|
||
|
{
|
||
|
Input1: nil,
|
||
|
Input2: []byte{},
|
||
|
Result: true,
|
||
|
},
|
||
|
{
|
||
|
Input1: []byte{1},
|
||
|
Input2: []byte{1},
|
||
|
Result: true,
|
||
|
},
|
||
|
{
|
||
|
Input1: []byte{1, 2},
|
||
|
Input2: []byte{1, 3},
|
||
|
Result: false,
|
||
|
},
|
||
|
}
|
||
|
|
||
|
for _, testCase := range testCases {
|
||
|
cmp := BytesEqual(testCase.Input1, testCase.Input2)
|
||
|
if cmp != testCase.Result {
|
||
|
t.Errorf("unexpected result %v from %v", cmp, testCase)
|
||
|
}
|
||
|
}
|
||
|
}
|