-
Notifications
You must be signed in to change notification settings - Fork 0
/
cdimage_test.go
68 lines (62 loc) · 1.71 KB
/
cdimage_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
62
63
64
65
66
67
68
package magicnumber_test
import (
"os"
"testing"
"github.com/Defacto2/magicnumber"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
const (
DaaFile = "uncompress.daa"
ISOFile = "uncompress.iso"
MdfFile = "uncompress.bin"
)
func TestDaa(t *testing.T) {
t.Parallel()
t.Log("TestDaa")
r, err := os.Open(imgfile(DaaFile))
require.NoError(t, err)
defer r.Close()
assert.True(t, magicnumber.Daa(r))
sign := magicnumber.Find(r)
assert.Equal(t, magicnumber.CDPowerISO, sign)
assert.Equal(t, "CD, PowerISO", sign.String())
assert.Equal(t, "CD PowerISO", sign.Title())
b, sign, err := magicnumber.MatchExt(DaaFile, r)
require.NoError(t, err)
assert.True(t, b)
assert.Equal(t, magicnumber.CDPowerISO, sign)
sign, err = magicnumber.DiscImage(r)
require.NoError(t, err)
assert.Equal(t, magicnumber.CDPowerISO, sign)
}
func TestCDISO(t *testing.T) {
t.Parallel()
t.Log("TestCDISO")
r, err := os.Open(imgfile(ISOFile))
require.NoError(t, err)
defer r.Close()
assert.True(t, magicnumber.ISO(r))
sign := magicnumber.Find(r)
assert.Equal(t, magicnumber.CDISO9660, sign)
assert.Equal(t, "CD, ISO 9660", sign.String())
assert.Equal(t, "CD ISO 9660", sign.Title())
b, sign, err := magicnumber.MatchExt(ISOFile, r)
require.NoError(t, err)
assert.True(t, b)
assert.Equal(t, magicnumber.CDISO9660, sign)
}
func TestMdf(t *testing.T) {
t.Parallel()
t.Log("TestMdf")
r, err := os.Open(imgfile(MdfFile))
require.NoError(t, err)
defer r.Close()
assert.True(t, magicnumber.Mdf(r))
sign := magicnumber.Find(r)
assert.Equal(t, magicnumber.CDAlcohol120, sign)
b, sign, err := magicnumber.MatchExt(DaaFile, r)
require.NoError(t, err)
assert.False(t, b)
assert.Equal(t, magicnumber.CDAlcohol120, sign)
}