ValueOps#increment properly handles negative vals

DATAREDIS-88
This commit is contained in:
Costin Leau
2012-05-23 18:38:23 +03:00
parent ff8184c264
commit 27d7e5dd0b
2 changed files with 11 additions and 6 deletions

View File

@@ -15,6 +15,7 @@
*/
package org.springframework.data.redis.core;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
import java.util.Collection;
@@ -56,4 +57,14 @@ public class TemplateTest {
public void testKeys() throws Exception {
assertTrue(template.keys("*") != null);
}
@Test
public void testIncrement() throws Exception {
StringRedisTemplate sr = new StringRedisTemplate(template.getConnectionFactory());
String key = "test.template.inc";
ValueOperations<String, String> valueOps = sr.opsForValue();
valueOps.set(key, "10");
valueOps.increment(key, -10);
assertEquals(0, Integer.valueOf(valueOps.get(key)).intValue());
}
}