test(QMCv2): add test data & case "mgg_map"
parent
7cc7aa19fd
commit
7755d47f7a
@ -1,40 +1,53 @@
|
||||
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()
|
||||
if err != nil {
|
||||
t.Fatalf("load testing data failed: %s", err)
|
||||
|
||||
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)
|
||||
}
|
||||
c, err := NewMapCipher(key)
|
||||
if err != nil {
|
||||
t.Errorf("init mapCipher failed: %s", err)
|
||||
return
|
||||
}
|
||||
c.Decrypt(raw, 0)
|
||||
if !reflect.DeepEqual(raw, target) {
|
||||
t.Error("overall")
|
||||
}
|
||||
})
|
||||
}
|
||||
t.Run("overall", func(t *testing.T) {
|
||||
c, err := NewMapCipher(key)
|
||||
if err != nil {
|
||||
t.Errorf("init mapCipher failed: %s", err)
|
||||
return
|
||||
}
|
||||
c.Decrypt(raw, 0)
|
||||
if !reflect.DeepEqual(raw, target) {
|
||||
t.Error("overall")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -0,0 +1 @@
|
||||
zGxNk54pKJ0hDkAo80wHE80ycSWQ7z4m4E846zVy2sqCn14F42Y5S7GqeR11WpOV75sDLbE5dFP992t88l0pHy1yAQ49YK6YX6c543drBYLo55Hc4Y0Fyic6LQPiGqu2bG31r8vaq9wS9v63kg0X5VbnOD6RhO4t0RRhk3ajrA7p0iIy027z0L70LZjtw6E18H0D41nz6ASTx71otdF9z1QNC0JmCl51xvnb39zPExEXyKkV47S6QsK5hFh884QJ
|
@ -0,0 +1 @@
|
||||
ekd4Tms1NHC53JEDO/AKVyF+I0bj0hHB7CZeoLDGSApaQB9Oo/pJTBGA/RO+nk5RXLXdHsffLiY4e8kt3LNo6qMl7S89vkiSFxx4Uoq4bGDJ7Jc+bYL6lLsa3M4sBvXS4XcPChrMDz+LmrJMGG6ua2fYyIz1d6TCRUBf1JJgCIkBbDAEeMVYc13qApitiz/apGAPmAnveCaDhfD5GxWsF+RfQ2OcnvrnIXe80Feh/0jx763DlsOBI3eIede6t5zYHokWkZmVEF1jMrnlvsgbQK2EzUWMblmLMsTKNILyZazEoKUyulqmyLO/c/KYE+USPOXPcbjlYFmLhSGHK7sQB5aBR153Yp+xh61ooh2NGAA=
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in New Issue