(t *testing.T)
| 167 | } |
| 168 | |
| 169 | func TestListStructure_LRange(t *testing.T) { |
| 170 | list, _ := initList() |
| 171 | defer list.db.Clean() |
| 172 | |
| 173 | // Test LRange function when the key exists |
| 174 | listErr = list.LPush(string(randkv.GetTestKey(1)), randkv.RandomValue(100), 0) |
| 175 | assert.Nil(t, listErr) |
| 176 | values, err := list.LRange(string(randkv.GetTestKey(1)), 0, 1) |
| 177 | assert.Nil(t, err) |
| 178 | assert.NotNil(t, values) |
| 179 | |
| 180 | // Test LRange function when the key does not exist |
| 181 | _, err = list.LRange(string(randkv.GetTestKey(2)), 0, 1) |
| 182 | assert.Equal(t, err, _const.ErrKeyNotFound) |
| 183 | |
| 184 | // Test LRange function when the list is empty |
| 185 | err = list.LPush(string(randkv.GetTestKey(3)), randkv.RandomValue(100), 0) |
| 186 | assert.Nil(t, err) |
| 187 | _, err = list.LPop(string(randkv.GetTestKey(3))) |
| 188 | assert.Nil(t, err) |
| 189 | _, err = list.LRange(string(randkv.GetTestKey(3)), 0, 1) |
| 190 | assert.Equal(t, err, ErrListEmpty) |
| 191 | } |
| 192 | |
| 193 | func TestListStructure_LLen(t *testing.T) { |
| 194 | list, _ := initList() |
nothing calls this directly
no test coverage detected