rts-sim-testing-service/third_party/radar/radar_test.go

40 lines
698 B
Go
Raw Normal View History

2024-01-24 17:12:34 +08:00
package radar
import (
"encoding/json"
"fmt"
"joylink.club/bj-rtsts-server/third_party/message"
"joylink.club/bj-rtsts-server/third_party/udp"
2024-01-26 17:57:35 +08:00
"math"
2024-01-24 17:12:34 +08:00
"testing"
)
2024-01-26 17:57:35 +08:00
func TestA1(t *testing.T) {
a := 112.12
b := 0.1
fmt.Println(math.Mod(a, b))
fmt.Println(a / 0.1)
fmt.Println(math.Mod(1121, 0.1))
fmt.Println(math.Round(math.Mod(1121, 0.1)))
}
2024-01-24 17:12:34 +08:00
func TestUdp(t *testing.T) {
2024-01-26 17:57:35 +08:00
2024-01-24 17:12:34 +08:00
fmt.Println("准备启动服务...")
addr := fmt.Sprintf("%v:%v", "127.0.0.1", "8899")
server := udp.NewServer(addr, handle)
server.Listen()
for {
}
}
func handle(d []byte) {
ri := message.RadarInfo{}
err := ri.Decode(d)
if err == nil {
jsonD, _ := json.Marshal(ri)
fmt.Println(string(jsonD))
}
}