diff options
author | Jon Bratseth <bratseth@verizonmedia.com> | 2019-05-24 09:55:00 +0200 |
---|---|---|
committer | Jon Bratseth <bratseth@verizonmedia.com> | 2019-05-24 09:55:00 +0200 |
commit | 7d13fda55eebea173d8c0a9dd370676042612e58 (patch) | |
tree | 8c98a7a3595757d470542bd924bff87b8f33fe46 /container-search/src/test | |
parent | 6193d1ff25fb2703c91a6215ba1787bb1c1cb501 (diff) |
Add double API to RankFeatures
Diffstat (limited to 'container-search/src/test')
-rw-r--r-- | container-search/src/test/java/com/yahoo/fs4/test/RankFeaturesTestCase.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/container-search/src/test/java/com/yahoo/fs4/test/RankFeaturesTestCase.java b/container-search/src/test/java/com/yahoo/fs4/test/RankFeaturesTestCase.java index e8c16e572ae..b52c708ce4b 100644 --- a/container-search/src/test/java/com/yahoo/fs4/test/RankFeaturesTestCase.java +++ b/container-search/src/test/java/com/yahoo/fs4/test/RankFeaturesTestCase.java @@ -24,12 +24,31 @@ public class RankFeaturesTestCase { public void requireThatRankPropertiesTakesBothStringAndObject() { RankProperties p = new RankProperties(); p.put("string", "b"); - p.put("object", Integer.valueOf(7)); + p.put("object", 7); assertEquals("7", p.get("object").get(0)); assertEquals("b", p.get("string").get(0)); } @Test + public void requireThatRankFeaturesUsingDoubleAndDoubleToStringEncodeTheSameWay() { + RankFeatures withDouble = new RankFeatures(); + withDouble.put("query(myDouble)", 3.8); + assertEquals(3.8, withDouble.getDouble("query(myDouble)").getAsDouble(), 0.000001); + + RankFeatures withString = new RankFeatures(); + withString.put("query(myDouble)", String.valueOf(3.8)); + + RankProperties withDoubleP = new RankProperties(); + withDouble.prepare(withDoubleP); + RankProperties withStringP = new RankProperties(); + withString.prepare(withStringP); + + byte[] withDoubleEncoded = encode(withDoubleP); + byte[] withStringEncoded = encode(withStringP); + assertEquals(Arrays.toString(withStringEncoded), Arrays.toString(withDoubleEncoded)); + } + + @Test public void requireThatSingleTensorIsBinaryEncoded() { TensorType type = new TensorType.Builder().mapped("x").mapped("y").mapped("z").build(); Tensor tensor = Tensor.from(type, "{ {x:a, y:b, z:c}:2.0, {x:a, y:b, z:c2}:3.0 }"); @@ -113,4 +132,5 @@ public class RankFeaturesTestCase { } return result; } + } |