| 214 | } |
| 215 | |
| 216 | func TestStringLen(t *testing.T) { |
| 217 | setValue(t, TestExistKey, value) |
| 218 | tests := []struct { |
| 219 | name string |
| 220 | key []byte |
| 221 | want int |
| 222 | }{ |
| 223 | { |
| 224 | name: "TestString_Len", |
| 225 | key: TestExistKey, |
| 226 | want: 11, |
| 227 | }, |
| 228 | { |
| 229 | name: "TestString_Len", |
| 230 | key: TestNoExistKey, |
| 231 | want: 0, |
| 232 | }, |
| 233 | } |
| 234 | for _, tt := range tests { |
| 235 | t.Run(tt.name, func(t *testing.T) { |
| 236 | callFunc := func(txn *Transaction) { |
| 237 | s, err := GetString(txn, tt.key) |
| 238 | assert.NoError(t, err) |
| 239 | got, err := s.Len() |
| 240 | assert.Equal(t, tt.want, got) |
| 241 | } |
| 242 | MockTest(t, callFunc) |
| 243 | }) |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | func TestStringExist(t *testing.T) { |
| 248 | setValue(t, TestExistKey, value) |