This is an automated email from the ASF dual-hosted git repository.

alsay pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/datasketches-go.git

commit 9c2d0e438f8f738ded0563bbd9f089a6aac076b0
Author: Pierre Lacave <[email protected]>
AuthorDate: Wed Dec 20 23:03:13 2023 +0100

    Add string memory corruption test
---
 frequencies/long_sketch_test.go | 15 +++++++++++++++
 frequencies/row.go              | 17 -----------------
 2 files changed, 15 insertions(+), 17 deletions(-)

diff --git a/frequencies/long_sketch_test.go b/frequencies/long_sketch_test.go
index d370994..5ee6557 100644
--- a/frequencies/long_sketch_test.go
+++ b/frequencies/long_sketch_test.go
@@ -291,3 +291,18 @@ func tryBadMem(t *testing.T, mem []byte, byteOffset, 
byteValue int) {
        _, err := NewLongSketchFromSlice(mem)
        assert.Error(t, err)
 }
+
+func TestFreqLongStringSerDeError(t *testing.T) {
+       //sk1, err := NewLongSketchWithMaxMapSize(8)
+       // str1 := sk1.serializeToString()
+       // correct   = "1,10,2,4,0,0,0,4,";
+
+       tryBadString(t, "2,10,2,4,0,0,0,4,")   //bad SerVer of 2
+       tryBadString(t, "1,10,2,0,0,0,0,4,")   //bad empty of 0
+       tryBadString(t, "1,10,2,4,0,0,0,4,0,") //one extra
+}
+
+func tryBadString(t *testing.T, badString string) {
+       _, err := NewLongSketchFromString(badString)
+       assert.Error(t, err)
+}
diff --git a/frequencies/row.go b/frequencies/row.go
index 2d93e76..f428975 100644
--- a/frequencies/row.go
+++ b/frequencies/row.go
@@ -22,23 +22,6 @@ import (
        "sort"
 )
 
-/*
-  public static class Row implements Comparable<Row> {
-    final long item;
-    final long est;
-    final long ub;
-    final long lb;
-    private static final String fmt =  ("  %20d%20d%20d %d");
-    private static final String hfmt = ("  %20s%20s%20s %s");
-
-    Row(final long item, final long estimate, final long ub, final long lb) {
-      this.item = item;
-      est = estimate;
-      this.ub = ub;
-      this.lb = lb;
-    }
-*/
-
 const (
        hfmt string = "  %20s%20s%20s %s"
 )


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to