MCPcopy
hub / github.com/tinylib/msgp / TestReadWriteFile

Function TestReadWriteFile

msgp/file_test.go:32–62  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

30}
31
32func TestReadWriteFile(t *testing.T) {
33 t.Parallel()
34
35 f, err := os.Create("tmpfile")
36 if err != nil {
37 t.Fatal(err)
38 }
39 defer func() {
40 f.Close()
41 os.Remove("tmpfile")
42 }()
43
44 data := make([]byte, 1024*1024)
45 rand.Read(data)
46
47 err = msgp.WriteFile(rawBytes(data), f)
48 if err != nil {
49 t.Fatal(err)
50 }
51
52 var out rawBytes
53 f.Seek(0, io.SeekStart)
54 err = msgp.ReadFile(&out, f)
55 if err != nil {
56 t.Fatal(err)
57 }
58
59 if !bytes.Equal([]byte(out), data) {
60 t.Fatal("Input and output not equal.")
61 }
62}
63
64var (
65 blobstrings = []string{"", "a string", "a longer string here!"}

Callers

nothing calls this directly

Calls 5

WriteFileFunction · 0.92
ReadFileFunction · 0.92
rawBytesTypeAlias · 0.85
ReadMethod · 0.45
EqualMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…