forked from debasishg/scala-redis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixed bug in SortedSetOperations and bumped up the version to 1.2-SNA…
…PSHOT
- Loading branch information
Debasish Ghosh
committed
Mar 18, 2010
1 parent
9c3eaf3
commit f075029
Showing
4 changed files
with
89 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package com.redis | ||
|
||
import org.scalatest.Spec | ||
import org.scalatest.BeforeAndAfterEach | ||
import org.scalatest.BeforeAndAfterAll | ||
import org.scalatest.matchers.ShouldMatchers | ||
import org.scalatest.junit.JUnitRunner | ||
import org.junit.runner.RunWith | ||
|
||
|
||
@RunWith(classOf[JUnitRunner]) | ||
class SortedSetOperationsSpec extends Spec | ||
with ShouldMatchers | ||
with BeforeAndAfterEach | ||
with BeforeAndAfterAll { | ||
|
||
val r = new RedisClient("localhost", 6379) | ||
|
||
override def beforeEach = { | ||
} | ||
|
||
override def afterEach = { | ||
r.flushDb | ||
} | ||
|
||
override def afterAll = { | ||
r.disconnect | ||
} | ||
|
||
import r._ | ||
|
||
private def add = { | ||
zadd("hackers", "1965", "yukihiro matsumoto").get should equal(1) | ||
zadd("hackers", "1953", "richard stallman").get should equal(1) | ||
zadd("hackers", "1916", "claude shannon").get should equal(1) | ||
zadd("hackers", "1969", "linus torvalds").get should equal(1) | ||
zadd("hackers", "1940", "alan kay").get should equal(1) | ||
zadd("hackers", "1912", "alan turing").get should equal(1) | ||
} | ||
|
||
describe("zadd") { | ||
it("should add based on proper sorted set semantics") { | ||
add | ||
zadd("hackers", "1912", "alan turing").get should equal(0) | ||
zcard("hackers").get should equal(6) | ||
} | ||
} | ||
|
||
describe("zrange") { | ||
it("should get the proper range") { | ||
add | ||
zrange("hackers", "0", "-1", RedisClient.ASC, false).get should have size (6) | ||
|
||
// should equal(Some(List(Some("alan turing"), Some("claude shannon"), Some("alan kay"), Some("richard stallman"), Some("yukihiro matsumoto"), Some("linus torvalds")))) | ||
|
||
zrange("hackers", "0", "-1", RedisClient.ASC, true).get should have size(12) | ||
|
||
// should equal(Some(List(Some("alan turing"), Some(1912), Some("claude shannon"), Some(1916), Some("alan kay"), Some(1940), Some("richard stallman"), Some(1953), Some("yukihiro matsumoto"), Some(1965), Some("linus torvalds"), Some(1969)))) | ||
|
||
zrangeWithScore("hackers", "0", "-1", RedisClient.ASC).get should have size(6) | ||
|
||
// should equal (Some(List((Some("alan turing"),Some(1912)), (Some("claude shannon"),Some(1916)), (Some("alan kay"),Some(1940)), (Some("richard stallman"),Some(1953)), (Some("yukihiro matsumoto"),Some(1965)), (Some("linus torvalds"),Some(1969))))) | ||
} | ||
} | ||
} |