(t *testing.T)
| 84 | } |
| 85 | |
| 86 | func TestFileReader_Read_LargeFile(t *testing.T) { |
| 87 | bFile, err := bfs.OpenBlocksFile("testdata/test.b", bfs.DefaultBlockFileOptions) |
| 88 | if err != nil { |
| 89 | if os.IsNotExist(err) { |
| 90 | t.Log(err) |
| 91 | return |
| 92 | } |
| 93 | t.Fatal(err) |
| 94 | } |
| 95 | |
| 96 | reader, err := bFile.OpenFileReader(bfs.Hash("123456@LARGE"), false) |
| 97 | if err != nil { |
| 98 | if os.IsNotExist(err) { |
| 99 | t.Log(err) |
| 100 | return |
| 101 | } |
| 102 | t.Fatal(err) |
| 103 | } |
| 104 | |
| 105 | defer func() { |
| 106 | _ = reader.Close() |
| 107 | }() |
| 108 | |
| 109 | var buf = make([]byte, 16<<10) |
| 110 | var totalSize int64 |
| 111 | var before = time.Now() |
| 112 | for { |
| 113 | n, readErr := reader.Read(buf) |
| 114 | if n > 0 { |
| 115 | totalSize += int64(n) |
| 116 | } |
| 117 | if readErr != nil { |
| 118 | if readErr == io.EOF { |
| 119 | break |
| 120 | } |
| 121 | t.Fatal(readErr) |
| 122 | } |
| 123 | } |
| 124 | t.Log("totalSize:", totalSize>>20, "MiB", "cost:", fmt.Sprintf("%.4fms", time.Since(before).Seconds()*1000)) |
| 125 | } |
| 126 | |
| 127 | func TestFileReader_ReadAt(t *testing.T) { |
| 128 | bFile, err := bfs.OpenBlocksFile("testdata/test.b", bfs.DefaultBlockFileOptions) |
nothing calls this directly
no test coverage detected