package aoiprxkit

import "testing"

func TestDecodeL24BE(t *testing.T) {
	payload := []byte{
		0x7f, 0xff, 0xff,
		0x80, 0x00, 0x00,
		0x00, 0x00, 0x01,
		0xff, 0xff, 0xff,
	}
	got, err := DecodeL24BE(payload, 2)
	if err != nil {
		t.Fatalf("unexpected err: %v", err)
	}
	want := []int32{8388607, -8388608, 1, -1}
	if len(got) != len(want) {
		t.Fatalf("len mismatch: got=%d want=%d", len(got), len(want))
	}
	for i := range want {
		if got[i] != want[i] {
			t.Fatalf("sample %d mismatch: got=%d want=%d", i, got[i], want[i])
		}
	}
}

func TestDecodeS32LE(t *testing.T) {
	payload := []byte{
		0x01, 0x00, 0x00, 0x00,
		0xff, 0xff, 0xff, 0xff,
	}
	got, err := DecodeS32LE(payload, 1)
	if err != nil {
		t.Fatalf("unexpected err: %v", err)
	}
	if len(got) != 2 || got[0] != 1 || got[1] != -1 {
		t.Fatalf("unexpected samples: %+v", got)
	}
}
