forked from TotallyGamerJet/bsdiff
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbsdiff_test.go
35 lines (32 loc) · 1.44 KB
/
bsdiff_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
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: 2019 Gabriel Ochsenhofer
// SPDX-FileCopyrightText: 2025 TotallyGamerJet
package bsdiff
import (
"bytes"
"testing"
)
func TestDiff(t *testing.T) {
oldbs := []byte{0xFF, 0xFA, 0xB7, 0xDD}
newbs := []byte{0xFF, 0xFA, 0x90, 0xB7, 0xDD, 0xFE}
var diffbs []byte
var err error
if diffbs, err = Diff(oldbs, newbs); err != nil {
t.Fatal(err)
}
z := []byte{
0x42, 0x53, 0x44, 0x49, 0x46, 0x46, 0x34, 0x30, 0x2D, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x42, 0x5A, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0xC9, 0x9D, 0x1D, 0x33, 0x00, 0x00,
0x06, 0xC0, 0x40, 0x5C, 0x00, 0x40, 0x00, 0x20, 0x00, 0x21, 0x8C, 0xA0, 0x60, 0x6C, 0xE2, 0xC8,
0xF1, 0x47, 0xC5, 0xDC, 0x91, 0x4E, 0x14, 0x24, 0x32, 0x67, 0x47, 0x4C, 0xC0, 0x42, 0x5A, 0x68,
0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0xFF, 0x48, 0x9B, 0x82, 0x00, 0x00, 0x00, 0xC0, 0x00,
0x40, 0x00, 0x20, 0x00, 0x21, 0x18, 0x46, 0xC2, 0xEE, 0x48, 0xA7, 0x0A, 0x12, 0x1F, 0xE9, 0x13,
0x70, 0x40, 0x42, 0x5A, 0x68, 0x39, 0x31, 0x41, 0x59, 0x26, 0x53, 0x59, 0xDD, 0x13, 0xBF, 0x5C,
0x00, 0x00, 0x00, 0x00, 0x2A, 0xC0, 0x00, 0x00, 0x80, 0x00, 0x02, 0x00, 0x01, 0x20, 0x00, 0x22,
0x1B, 0x03, 0x0C, 0x70, 0xC2, 0xEE, 0x48, 0xA7, 0x0A, 0x12, 0x1B, 0xA2, 0x77, 0xEB, 0x80,
}
if !bytes.Equal(diffbs[:len(z)], z) {
t.Fatal(diffbs[:len(z)], "!=", z)
}
}