-
Notifications
You must be signed in to change notification settings - Fork 2
/
image_test.go
47 lines (39 loc) · 920 Bytes
/
image_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
package amdfw
import (
"fmt"
"github.com/stretchr/testify/assert"
"testing"
)
var (
testFlashMapping = DefaultFlashMapping
testImage = Image{
FET: &testFet,
FlashMapping: &testFlashMapping,
Roms: []*Rom{
{
Type: PSPRom,
Directories: []*Directory{
&testPSPMiniDirectory,
},
Raw: nil,
},
&testRawRom,
},
}
)
func mockImage() []byte {
baseImage := mockFetImage()
copy(baseImage[testPSPDirBase-DefaultFlashMapping:], testPSPMiniDirectoryBytes)
copy(baseImage[testXHCRomBase-DefaultFlashMapping:], testRawRomBytes)
return baseImage
}
func TestImage_Write(t *testing.T) {
baseImage := make([]byte, testImage16MB)
baseImage, err := testImage.Write(baseImage)
assert.Nil(t, err)
for pos, byteVal := range mockImage() {
if baseImage[pos] != byteVal {
assert.Equal(t, byteVal, baseImage[pos], fmt.Sprintf("Bytes not Equal at 0x%08X", pos))
}
}
}