2020-11-17 13:37:19 +00:00
|
|
|
// Copyright (C) 2020 Storj Labs, Inc.
|
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
|
|
|
package metabase
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
)
|
|
|
|
|
2021-02-28 18:27:38 +00:00
|
|
|
func TestPrefixLimit(t *testing.T) {
|
2020-11-17 13:37:19 +00:00
|
|
|
unchanged := ObjectKey("unchanged")
|
2021-02-28 18:27:38 +00:00
|
|
|
_ = prefixLimit(unchanged)
|
2020-11-17 13:37:19 +00:00
|
|
|
require.Equal(t, ObjectKey("unchanged"), unchanged)
|
|
|
|
|
|
|
|
tests := []struct{ in, exp ObjectKey }{
|
|
|
|
{"", ""},
|
|
|
|
{"a", "b"},
|
|
|
|
{"\xF1", "\xF2"},
|
2021-02-28 18:27:38 +00:00
|
|
|
{"\xFF", "\xFF\x00"},
|
2020-11-17 13:37:19 +00:00
|
|
|
}
|
|
|
|
for _, test := range tests {
|
2021-02-28 18:27:38 +00:00
|
|
|
require.Equal(t, test.exp, prefixLimit(test.in))
|
2020-11-17 13:37:19 +00:00
|
|
|
if test.in != "" {
|
|
|
|
require.True(t, lessKey(test.in, test.exp))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|