mirror of
https://github.com/v2fly/v2ray-core.git
synced 2024-11-16 01:17:30 -05:00
44 lines
666 B
Go
44 lines
666 B
Go
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)
|
|
}
|
|
}
|
|
}
|