Skip to content

Commit

Permalink
documenting validation
Browse files Browse the repository at this point in the history
  • Loading branch information
lemire committed Jun 7, 2024
1 parent e18a7ce commit 56d2579
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,15 +249,20 @@ consider the following sample of code:
buf := new(bytes.Buffer)
size,err:=rb.WriteTo(buf)
if err != nil {
t.Errorf("Failed writing")
fmt.Println("Failed writing") // return or panic
}
newrb:= New()
size,err=newrb.ReadFrom(buf)
if err != nil {
t.Errorf("Failed reading")
fmt.Println("Failed reading") // return or panic
}
// if buf is an untrusted source, you should validate the result
// (this adds a bit of complexity but it is necessary for security)
if(!newrb.Validate()) {
fmt.Println("Failed validation") // return or panic
}
if ! rb.Equals(newrb) {
t.Errorf("Cannot retrieve serialized version")
fmt.Println("Cannot retrieve serialized version")
}
```

Expand Down
6 changes: 5 additions & 1 deletion example_roaring_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,11 @@ func TestExample_roaring060(t *testing.T) {
if err != nil {
fmt.Println("Failed reading")
t.Errorf("Failed reading")

}
// if buf is an untrusted source, you should validate the result
// (this adds a bit of complexity but it is necessary for security)
if !newrb.Validate() {

Check failure on line 64 in example_roaring_test.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, windows-latest)

invalid operation: !newrb.Validate() (operator ! not defined on interface)

Check failure on line 64 in example_roaring_test.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, windows-latest)

invalid operation: !newrb.Validate() (operator ! not defined on interface)

Check failure on line 64 in example_roaring_test.go

View workflow job for this annotation

GitHub Actions / test (1.14.x, ubuntu-latest)

invalid operation: ! error

Check failure on line 64 in example_roaring_test.go

View workflow job for this annotation

GitHub Actions / test (1.14.x, ubuntu-latest)

invalid operation: ! error

Check failure on line 64 in example_roaring_test.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, macos-latest)

invalid operation: !newrb.Validate() (operator ! not defined on interface)

Check failure on line 64 in example_roaring_test.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, ubuntu-latest)

invalid operation: !newrb.Validate() (operator ! not defined on interface)

Check failure on line 64 in example_roaring_test.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, windows-latest)

invalid operation: !newrb.Validate() (operator ! not defined on interface)

Check failure on line 64 in example_roaring_test.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, windows-latest)

invalid operation: !newrb.Validate() (operator ! not defined on interface)

Check failure on line 64 in example_roaring_test.go

View workflow job for this annotation

GitHub Actions / test (1.14.x, ubuntu-latest)

invalid operation: ! error

Check failure on line 64 in example_roaring_test.go

View workflow job for this annotation

GitHub Actions / test (1.14.x, ubuntu-latest)

invalid operation: ! error

Check failure on line 64 in example_roaring_test.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, ubuntu-latest)

invalid operation: !newrb.Validate() (operator ! not defined on interface)

Check failure on line 64 in example_roaring_test.go

View workflow job for this annotation

GitHub Actions / test (1.17.x, macos-latest)

invalid operation: !newrb.Validate() (operator ! not defined on interface)
fmt.Println("Failed validation")
}
if !rb1.Equals(newrb) {
fmt.Println("I did not get back to original bitmap?")
Expand Down

0 comments on commit 56d2579

Please sign in to comment.