File tree 6 files changed +44
-7
lines changed
6 files changed +44
-7
lines changed Original file line number Diff line number Diff line change 1
1
package lzss
2
2
3
3
import (
4
- "fmt"
4
+ "bytes"
5
+ "io/ioutil"
5
6
"testing"
6
7
)
7
8
8
- func TestContains (t * testing.T ) {
9
- buf := []byte ("ciao a tutti" )
10
- occ := []byte ("tut" )
11
- fmt .Println (contains (buf , occ ))
12
- occ = []byte ("ti" )
13
- fmt .Println (contains (buf , occ ))
9
+ func TestEncode (t * testing.T ) {
10
+ tests := []struct {
11
+ name string
12
+ infile string
13
+ outfile string
14
+ }{
15
+ {
16
+ name : "lorem" ,
17
+ infile : "testdata/lorem.txt" ,
18
+ outfile : "testdata/lorem.lzss" ,
19
+ },
20
+ {
21
+ name : "short" ,
22
+ infile : "testdata/short.txt" ,
23
+ outfile : "testdata/short.lzss" ,
24
+ },
25
+ {
26
+ name : "blink" ,
27
+ infile : "testdata/blink.bin" ,
28
+ outfile : "testdata/blink.lzss" ,
29
+ },
30
+ }
31
+
32
+ for _ , tt := range tests {
33
+ t .Run (tt .name , func (t * testing.T ) {
34
+ input , err := ioutil .ReadFile (tt .infile )
35
+ if err != nil {
36
+ t .Fatal ("couldn't open test file" )
37
+ }
38
+
39
+ want , err := ioutil .ReadFile (tt .outfile )
40
+ if err != nil {
41
+ t .Fatal ("couldn't open test file" )
42
+ }
43
+
44
+ got := Encode (input )
45
+ if ! bytes .Equal (want , got ) {
46
+ t .Error ("encoding failed" )
47
+ }
48
+ })
49
+ }
14
50
}
Original file line number Diff line number Diff line change
1
+ Lorem ipsum dolor sit amet, consectetur adipiscing elit.
You can’t perform that action at this time.
0 commit comments