-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathram_test.go
61 lines (46 loc) · 1.07 KB
/
ram_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// V0.7.4
// Author: DIEHL E.
// (C) Sony Pictures Entertainment, Feb 2021
package test
import (
"io"
"testing"
)
func Test_RamWriter(t *testing.T) {
require, assert := Describe(t)
text := RandomString(0)
ramw := NewRAMWriter()
bio := ramw.Writer()
_, err := bio.WriteString(text)
require.NoError(err)
assert.Equal(text, ramw.AsString())
assert.Equal([]byte(text), ramw.AsBytes())
}
func Test_RamReader(t *testing.T) {
require, assert := Describe(t)
text := RandomString(0) + "\n"
ramr := NewRAMReader([]byte(text))
bio := ramr.Reader()
data, err := bio.ReadString('\n')
require.NoError(err)
assert.Equal(text, data)
}
func Test_RamReaderFromString(t *testing.T) {
require, assert := Describe(t)
text := RandomString(0) + "\n"
ramr := NewRAMReaderFromString(text)
bio := ramr.Reader()
data, err := bio.ReadString('\n')
require.NoError(err)
assert.Equal(text, data)
}
func Test_ErrReader(t *testing.T) {
_, assert := Describe(t)
var er ErrReader
assert.Error(fake(er))
}
func fake(rd io.Reader) error {
var p []byte
_, err := rd.Read(p)
return err
}