test(QMCv2): add test data & case "mgg_map"
This commit is contained in:
parent
7cc7aa19fd
commit
7755d47f7a
@ -1,32 +1,44 @@
|
||||
package qmc
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"reflect"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func loadTestMapCipherData() ([]byte, []byte, []byte, error) {
|
||||
key, err := os.ReadFile("./testdata/mflac_map_key.bin")
|
||||
func loadTestDataMapCipher(name string) ([]byte, []byte, []byte, error) {
|
||||
key, err := os.ReadFile(fmt.Sprintf("./testdata/%s_key.bin", name))
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
raw, err := os.ReadFile("./testdata/mflac_map_raw.bin")
|
||||
raw, err := os.ReadFile(fmt.Sprintf("./testdata/%s_raw.bin", name))
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
target, err := os.ReadFile("./testdata/mflac_map_target.bin")
|
||||
target, err := os.ReadFile(fmt.Sprintf("./testdata/%s_target.bin", name))
|
||||
if err != nil {
|
||||
return nil, nil, nil, err
|
||||
}
|
||||
return key, raw, target, nil
|
||||
}
|
||||
func Test_mapCipher_Decrypt(t *testing.T) {
|
||||
key, raw, target, err := loadTestMapCipherData()
|
||||
|
||||
tests := []struct {
|
||||
name string
|
||||
wantErr bool
|
||||
}{
|
||||
{"mflac_map", false},
|
||||
{"mgg_map", false},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
key, raw, target, err := loadTestDataMapCipher(tt.name)
|
||||
if err != nil {
|
||||
t.Fatalf("load testing data failed: %s", err)
|
||||
}
|
||||
t.Run("overall", func(t *testing.T) {
|
||||
c, err := NewMapCipher(key)
|
||||
if err != nil {
|
||||
t.Errorf("init mapCipher failed: %s", err)
|
||||
@ -37,4 +49,5 @@ func Test_mapCipher_Decrypt(t *testing.T) {
|
||||
t.Error("overall")
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -33,6 +33,7 @@ func TestMflac0Decoder_Read(t *testing.T) {
|
||||
}{
|
||||
{"mflac0_rc4", false},
|
||||
{"mflac_map", false},
|
||||
{"mgg_map", false},
|
||||
{"qmc0_static", false},
|
||||
}
|
||||
|
||||
@ -69,6 +70,7 @@ func TestMflac0Decoder_Validate(t *testing.T) {
|
||||
}{
|
||||
{"mflac0_rc4", ".flac", false},
|
||||
{"mflac_map", ".flac", false},
|
||||
{"mgg_map", ".ogg", false},
|
||||
{"qmc0_static", ".mp3", false},
|
||||
}
|
||||
|
||||
|
1
algo/qmc/testdata/mgg_map_key.bin
vendored
Normal file
1
algo/qmc/testdata/mgg_map_key.bin
vendored
Normal file
@ -0,0 +1 @@
|
||||
zGxNk54pKJ0hDkAo80wHE80ycSWQ7z4m4E846zVy2sqCn14F42Y5S7GqeR11WpOV75sDLbE5dFP992t88l0pHy1yAQ49YK6YX6c543drBYLo55Hc4Y0Fyic6LQPiGqu2bG31r8vaq9wS9v63kg0X5VbnOD6RhO4t0RRhk3ajrA7p0iIy027z0L70LZjtw6E18H0D41nz6ASTx71otdF9z1QNC0JmCl51xvnb39zPExEXyKkV47S6QsK5hFh884QJ
|
1
algo/qmc/testdata/mgg_map_key_raw.bin
vendored
Normal file
1
algo/qmc/testdata/mgg_map_key_raw.bin
vendored
Normal file
@ -0,0 +1 @@
|
||||
ekd4Tms1NHC53JEDO/AKVyF+I0bj0hHB7CZeoLDGSApaQB9Oo/pJTBGA/RO+nk5RXLXdHsffLiY4e8kt3LNo6qMl7S89vkiSFxx4Uoq4bGDJ7Jc+bYL6lLsa3M4sBvXS4XcPChrMDz+LmrJMGG6ua2fYyIz1d6TCRUBf1JJgCIkBbDAEeMVYc13qApitiz/apGAPmAnveCaDhfD5GxWsF+RfQ2OcnvrnIXe80Feh/0jx763DlsOBI3eIede6t5zYHokWkZmVEF1jMrnlvsgbQK2EzUWMblmLMsTKNILyZazEoKUyulqmyLO/c/KYE+USPOXPcbjlYFmLhSGHK7sQB5aBR153Yp+xh61ooh2NGAA=
|
BIN
algo/qmc/testdata/mgg_map_raw.bin
vendored
Normal file
BIN
algo/qmc/testdata/mgg_map_raw.bin
vendored
Normal file
Binary file not shown.
BIN
algo/qmc/testdata/mgg_map_suffix.bin
vendored
Normal file
BIN
algo/qmc/testdata/mgg_map_suffix.bin
vendored
Normal file
Binary file not shown.
BIN
algo/qmc/testdata/mgg_map_target.bin
vendored
Normal file
BIN
algo/qmc/testdata/mgg_map_target.bin
vendored
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user