Go-based FM stereo transmitter with RDS, Windows-first and cross-platform
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

40 linhas
844B

  1. package aoiprxkit
  2. import "testing"
  3. func TestDecodeL24BE(t *testing.T) {
  4. payload := []byte{
  5. 0x7f, 0xff, 0xff,
  6. 0x80, 0x00, 0x00,
  7. 0x00, 0x00, 0x01,
  8. 0xff, 0xff, 0xff,
  9. }
  10. got, err := DecodeL24BE(payload, 2)
  11. if err != nil {
  12. t.Fatalf("unexpected err: %v", err)
  13. }
  14. want := []int32{8388607, -8388608, 1, -1}
  15. if len(got) != len(want) {
  16. t.Fatalf("len mismatch: got=%d want=%d", len(got), len(want))
  17. }
  18. for i := range want {
  19. if got[i] != want[i] {
  20. t.Fatalf("sample %d mismatch: got=%d want=%d", i, got[i], want[i])
  21. }
  22. }
  23. }
  24. func TestDecodeS32LE(t *testing.T) {
  25. payload := []byte{
  26. 0x01, 0x00, 0x00, 0x00,
  27. 0xff, 0xff, 0xff, 0xff,
  28. }
  29. got, err := DecodeS32LE(payload, 1)
  30. if err != nil {
  31. t.Fatalf("unexpected err: %v", err)
  32. }
  33. if len(got) != 2 || got[0] != 1 || got[1] != -1 {
  34. t.Fatalf("unexpected samples: %+v", got)
  35. }
  36. }