rts-sim-testing-service/third_party/balise/conv_test.go

45 lines
1.3 KiB
Go

package balise_test
import (
"testing"
"github.com/stretchr/testify/assert"
"joylink.club/bj-rtsts-server/third_party/balise"
)
var by830 = []int{
0x90, 0x02, 0x7F, 0xC7, 0x8C, 0x0A, 0xC5, 0x40, 0x7B, 0x20, 0x00, 0x21, 0x68, 0x05, 0x9A, 0x04, 0x09, 0x61, 0x0B, 0x0A,
0xF0, 0x05, 0x0B, 0xB9, 0x05, 0x0E, 0xD8, 0x03, 0x1E, 0xDD, 0x09, 0x09, 0xC4, 0x09, 0x0D, 0x4E, 0xFF, 0x1B, 0x00, 0xAC,
0x80, 0x00, 0x64, 0x00, 0x5A, 0x9A, 0x7F, 0x00, 0xB0, 0x0D, 0x68, 0x04, 0x0C, 0xB2, 0x00, 0x00, 0xC2, 0x00, 0x75, 0xC0,
0x30, 0x74, 0x86, 0x10, 0x74, 0xA0, 0x30, 0x78, 0x66, 0x10, 0x78, 0x60, 0x30, 0x75, 0x26, 0x10, 0x75, 0x20, 0x30, 0x79,
0x86, 0x10, 0x79, 0x80, 0x30, 0x7A, 0x06, 0x10, 0x7A, 0x00, 0x30, 0x7C, 0x46, 0x10, 0x7C, 0x60, 0x30, 0x7C, 0xA6, 0x10,
0x82, 0x9F, 0xFF, 0xFF,
}
func TestConvList(t *testing.T) {
// 数量
assert.Equal(t, 1024, len(balise.ConvWords))
// 后面的数比前面大
for i := 0; i < 1023; i++ {
assert.Less(t, balise.ConvWords[i], balise.ConvWords[i+1])
}
// 前512项和
sum_q := 0
for i := 0; i < 512; i++ {
sum_q += int(balise.ConvWords[i])
}
assert.Equal(t, 267528, sum_q)
// 后512项和
sum_b := 0
for i := 512; i < 1024; i++ {
sum_b += int(balise.ConvWords[i])
}
// 总1024项和
assert.Equal(t, 1048064, sum_q+sum_b)
}
func TestTo11(t *testing.T) {
b10 := []int{0, 0, 0, 0, 0, 0, 0, 0, 0, 1}
balise.To11(b10)
}