You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@geode.apache.org by ri...@apache.org on 2021/06/28 18:35:21 UTC
[geode] branch GEODE-9342-fix-double-infinity-output created (now
97cd8b6)
This is an automated email from the ASF dual-hosted git repository.
ringles pushed a change to branch GEODE-9342-fix-double-infinity-output
in repository https://gitbox.apache.org/repos/asf/geode.git.
at 97cd8b6 Return 'inf' and '-inf' like Redis does, add Coder tests
This branch includes the following new commits:
new 97cd8b6 Return 'inf' and '-inf' like Redis does, add Coder tests
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
[geode] 01/01: Return 'inf' and '-inf' like Redis does,
add Coder tests
Posted by ri...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ringles pushed a commit to branch GEODE-9342-fix-double-infinity-output
in repository https://gitbox.apache.org/repos/asf/geode.git
commit 97cd8b65bb58a4e2680b8f63d94b6453b98fd0c7
Author: Ray Ingles <ri...@vmware.com>
AuthorDate: Mon Jun 28 14:33:53 2021 -0400
Return 'inf' and '-inf' like Redis does, add Coder tests
---
.../apache/geode/redis/internal/netty/Coder.java | 4 ++--
.../geode/redis/internal/netty/CoderTest.java | 23 ++++++++++++++++++++++
2 files changed, 25 insertions(+), 2 deletions(-)
diff --git a/geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/netty/Coder.java b/geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/netty/Coder.java
index b48a09f..c4e08d1 100644
--- a/geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/netty/Coder.java
+++ b/geode-apis-compatible-with-redis/src/main/java/org/apache/geode/redis/internal/netty/Coder.java
@@ -280,10 +280,10 @@ public class Coder {
public static String doubleToString(double d) {
if (d == Double.POSITIVE_INFINITY) {
- return "Infinity";
+ return "inf";
}
if (d == Double.NEGATIVE_INFINITY) {
- return "-Infinity";
+ return "-inf";
}
String stringValue = String.valueOf(d);
diff --git a/geode-apis-compatible-with-redis/src/test/java/org/apache/geode/redis/internal/netty/CoderTest.java b/geode-apis-compatible-with-redis/src/test/java/org/apache/geode/redis/internal/netty/CoderTest.java
index bf6e23a..cda6982 100644
--- a/geode-apis-compatible-with-redis/src/test/java/org/apache/geode/redis/internal/netty/CoderTest.java
+++ b/geode-apis-compatible-with-redis/src/test/java/org/apache/geode/redis/internal/netty/CoderTest.java
@@ -14,7 +14,9 @@
*/
package org.apache.geode.redis.internal.netty;
+import static org.apache.geode.redis.internal.netty.Coder.bytesToDouble;
import static org.apache.geode.redis.internal.netty.Coder.bytesToString;
+import static org.apache.geode.redis.internal.netty.Coder.doubleToString;
import static org.apache.geode.redis.internal.netty.Coder.equalsIgnoreCaseBytes;
import static org.apache.geode.redis.internal.netty.Coder.isInfinity;
import static org.apache.geode.redis.internal.netty.Coder.isNaN;
@@ -63,6 +65,13 @@ public class CoderTest {
assertThat(isNaN(bytes)).isEqualTo(isNaN);
}
+ @Test
+ @Parameters(method = "infinityReturnStrings")
+ public void doubleToString_processesLikeRedis(String inputString, String expectedString) {
+ byte[] bytes = stringToBytes(inputString);
+ assertThat(doubleToString(bytesToDouble(bytes))).isEqualTo(expectedString);
+ }
+
@SuppressWarnings("unused")
private Object[] stringPairs() {
// string1, string2
@@ -102,4 +111,18 @@ public class CoderTest {
new Object[] {null, false, false, false}
};
}
+
+ @SuppressWarnings("unused")
+ private Object[] infinityReturnStrings() {
+ // string, expectedString
+ return new Object[] {
+ new Object[] {"inf", "inf"},
+ new Object[] {"+inf", "inf"},
+ new Object[] {"Infinity", "inf"},
+ new Object[] {"+Infinity", "inf"},
+ new Object[] {"-inf", "-inf"},
+ new Object[] {"-Infinity", "-inf"},
+ };
+ }
+
}