Sha256: db52d37b7853607336ebced7a23d6f7100e9bd3f3f9d2e06531362872a6a5d31

Contents?: true

Size: 1.58 KB

Versions: 54

Compression:

Stored size: 1.58 KB

Contents

test "RPUSH" do |r|
  r.rpush "foo", "s1"
  r.rpush "foo", "s2"

  assert 2 == r.llen("foo")
  assert "s2" == r.rpop("foo")
end

test "LPUSH" do |r|
  r.lpush "foo", "s1"
  r.lpush "foo", "s2"

  assert 2 == r.llen("foo")
  assert "s2" == r.lpop("foo")
end

test "LLEN" do |r|
  r.rpush "foo", "s1"
  r.rpush "foo", "s2"

  assert 2 == r.llen("foo")
end

test "LRANGE" do |r|
  r.rpush "foo", "s1"
  r.rpush "foo", "s2"
  r.rpush "foo", "s3"

  assert ["s2", "s3"] == r.lrange("foo", 1, -1)
  assert ["s1", "s2"] == r.lrange("foo", 0, 1)

  assert [] == r.lrange("bar", 0, -1)
end

test "LTRIM" do |r|
  r.rpush "foo", "s1"
  r.rpush "foo", "s2"
  r.rpush "foo", "s3"

  r.ltrim "foo", 0, 1

  assert 2 == r.llen("foo")
  assert ["s1", "s2"] == r.lrange("foo", 0, -1)
end

test "LINDEX" do |r|
  r.rpush "foo", "s1"
  r.rpush "foo", "s2"

  assert "s1" == r.lindex("foo", 0)
  assert "s2" == r.lindex("foo", 1)
end

test "LSET" do |r|
  r.rpush "foo", "s1"
  r.rpush "foo", "s2"

  assert "s2" == r.lindex("foo", 1)
  assert r.lset("foo", 1, "s3")
  assert "s3" == r.lindex("foo", 1)

  assert_raise RuntimeError do
    r.lset("foo", 4, "s3")
  end
end

test "LREM" do |r|
  r.rpush "foo", "s1"
  r.rpush "foo", "s2"

  assert 1 == r.lrem("foo", 1, "s1")
  assert ["s2"] == r.lrange("foo", 0, -1)
end

test "LPOP" do |r|
  r.rpush "foo", "s1"
  r.rpush "foo", "s2"

  assert 2 == r.llen("foo")
  assert "s1" == r.lpop("foo")
  assert 1 == r.llen("foo")
end

test "RPOP" do |r|
  r.rpush "foo", "s1"
  r.rpush "foo", "s2"

  assert 2 == r.llen("foo")
  assert "s2" == r.rpop("foo")
  assert 1 == r.llen("foo")
end


Version data entries

54 entries across 54 versions & 7 rubygems

Version Path
abaci-0.3.0 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.7.5 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.7.4 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.7.3 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.7.2 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.7.1 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.7.0 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.6.9 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.6.8 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.6.7 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.6.6 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.6.5 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.6.4 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.6.3 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.6.2 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.6.1 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.6.0 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.5.17 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.5.16 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb
classiccms-0.5.15 vendor/bundle/gems/redis-2.2.2/test/lint/lists.rb