test.js 744 B

12345678910111213141516171819202122232425262728293031323334353637
  1. const test = require('brittle')
  2. const cyclist = require('./')
  3. test('basic put and get', function (t) {
  4. const list = cyclist(2)
  5. list.put(0, 'hello')
  6. list.put(1, 'world')
  7. t.is(list.get(0), 'hello')
  8. t.is(list.get(1), 'world')
  9. t.end()
  10. })
  11. test('overflow put and get', function (t) {
  12. const list = cyclist(2)
  13. list.put(0, 'hello')
  14. list.put(1, 'world')
  15. list.put(2, 'verden')
  16. t.is(list.get(0), 'verden')
  17. t.is(list.get(1), 'world')
  18. t.is(list.get(2), 'verden')
  19. t.end()
  20. })
  21. test('del', function (t) {
  22. const list = cyclist(2)
  23. list.put(0, 'hello')
  24. t.is(list.get(0), 'hello')
  25. list.del(0)
  26. t.ok(!list.get(0))
  27. t.end()
  28. })
  29. test('multiple of two', function (t) {
  30. const list = cyclist(3)
  31. t.is(list.size, 4)
  32. t.end()
  33. })