Added incrByFloat and hincrByFloat commands (binary and standard) + support for pipelining and sharding
This commit is contained in:
@@ -143,6 +143,25 @@ public class HashesCommandsTest extends JedisCommandTestBase {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hincrByFloat() {
|
||||
Double value = jedis.hincrByFloat("foo", "bar", 1.5d);
|
||||
assertEquals((Double) 1.5d, value);
|
||||
value = jedis.hincrByFloat("foo", "bar", -1.5d);
|
||||
assertEquals((Double) 0d, value);
|
||||
value = jedis.hincrByFloat("foo", "bar", -10.7d);
|
||||
assertEquals(Double.compare(-10.7d, value), 0);
|
||||
|
||||
// Binary
|
||||
double bvalue = jedis.hincrByFloat(bfoo, bbar, 1.5d);
|
||||
assertEquals(Double.compare(1.5d, bvalue), 0);
|
||||
bvalue = jedis.hincrByFloat(bfoo, bbar, -1.5d);
|
||||
assertEquals(Double.compare(0d, bvalue), 0);
|
||||
bvalue = jedis.hincrByFloat(bfoo, bbar, -10.7d);
|
||||
assertEquals(Double.compare(-10.7d, value), 0);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void hexists() {
|
||||
Map<String, String> hash = new HashMap<String, String>();
|
||||
|
||||
@@ -132,7 +132,7 @@ public class ScriptingCommandsTest extends JedisCommandTestBase {
|
||||
jedis.scriptKill();
|
||||
}
|
||||
catch(JedisDataException e) {
|
||||
assertEquals("ERR No scripts in execution right now.", e.getMessage());
|
||||
assertTrue(e.getMessage().contains("No scripts in execution right now."));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -123,6 +123,22 @@ public class StringValuesCommandsTest extends JedisCommandTestBase {
|
||||
assertEquals(4, value);
|
||||
}
|
||||
|
||||
@Test(expected = JedisDataException.class)
|
||||
public void incrByFloatWrongValue() {
|
||||
jedis.set("foo", "bar");
|
||||
jedis.incrByFloat("foo", 2d);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void incrByFloat() {
|
||||
Double value = jedis.incrByFloat("foo", 2d);
|
||||
assertEquals((Double)2d, value);
|
||||
value = jedis.incrByFloat("foo", 2.5d);
|
||||
assertEquals((Double)4.5d, value);
|
||||
value = jedis.incrByFloat("foo", -6.5d);
|
||||
assertEquals(Double.compare(-2d, value), 0);
|
||||
}
|
||||
|
||||
@Test(expected = JedisDataException.class)
|
||||
public void decrWrongValue() {
|
||||
jedis.set("foo", "bar");
|
||||
|
||||
Reference in New Issue
Block a user