Signed-off-by: demoManito <1430482733@qq.com>
This commit is contained in:
demoManito 2022-09-16 17:08:29 +08:00
parent 72cf0cc04a
commit 5b26fc0101
3 changed files with 9 additions and 12 deletions

View File

@ -90,7 +90,7 @@ func (us *unsafeSet) Length() int {
// Values returns the values of the Set in an unspecified order.
func (us *unsafeSet) Values() (values []string) {
values = make([]string, 0)
values = make([]string, 0, len(us.d))
for val := range us.d {
values = append(values, val)
}

View File

@ -39,10 +39,9 @@ func equal(a, b []string) bool {
func driveSetTests(t *testing.T, s Set) {
// Verify operations on an empty set
var eValues []string
values := s.Values()
if !reflect.DeepEqual(values, eValues) {
t.Fatalf("Expect values=%v got %v", eValues, values)
if len(values) != 0 {
t.Fatalf("Expect values=%v got %v", []string{}, values)
}
if l := s.Length(); l != 0 {
t.Fatalf("Expected length=0, got %d", l)
@ -58,7 +57,7 @@ func driveSetTests(t *testing.T, s Set) {
s.Add("bar")
s.Add("baz")
eValues = []string{"foo", "bar", "baz"}
eValues := []string{"foo", "bar", "baz"}
values = s.Values()
if !equal(values, eValues) {
t.Fatalf("Expect values=%v got %v", eValues, values)

View File

@ -353,17 +353,15 @@ func TestKVDeleteRange(t *testing.T) {
ctx := context.TODO()
tests := []struct {
key string
opts []clientv3.OpOption
key string
opts []clientv3.OpOption
wkeys []string
}{
// *
{
key: "\x00",
opts: []clientv3.OpOption{clientv3.WithFromKey()},
wkeys: []string{},
key: "\x00",
opts: []clientv3.OpOption{clientv3.WithFromKey()},
wkeys: nil,
},
}