MCPcopy
hub / github.com/RoaringBitmap/roaring / TestSerializationToFile038

Function TestSerializationToFile038

serialization_test.go:65–96  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

63}
64
65func TestSerializationToFile038(t *testing.T) {
66 rb := BitmapOf(1, 2, 3, 4, 5, 100, 1000)
67 fname := filepath.Join(t.TempDir(), "myfile.bin")
68 fout, err := os.OpenFile(fname, os.O_RDWR|os.O_CREATE|os.O_TRUNC, 0660)
69 if err != nil {
70 fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
71 return
72 }
73
74 var l int64
75 l, err = rb.WriteTo(fout)
76 if err != nil {
77 fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
78 return
79 }
80
81 assert.EqualValues(t, l, rb.GetSerializedSizeInBytes())
82
83 fout.Close()
84
85 newrb := NewBitmap()
86 fin, err := os.Open(fname)
87 if err != nil {
88 fmt.Fprintf(os.Stderr, "\n\nIMPORTANT: For testing file IO, the roaring library requires disk access.\nWe omit some tests for now.\n\n")
89 return
90 }
91
92 defer fin.Close()
93
94 _, _ = newrb.ReadFrom(fin)
95 assert.True(t, rb.Equals(newrb))
96}
97
98func TestSerializationReadRunsFromFile039(t *testing.T) {
99 fn := "testdata/bitmapwithruns.bin"

Callers

nothing calls this directly

Calls 6

ReadFromMethod · 0.95
BitmapOfFunction · 0.70
NewBitmapFunction · 0.70
WriteToMethod · 0.45
EqualsMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…