Пример #1
0
func TestDecode(t *testing.T) {
	want := []byte{80, 55, 87, 90, 79}

	got := sevensegment.Decode(12345)

	if !bytes.Equal(want, got) {
		t.Fatalf("expected %v but got %v", want, got)
	}

	want = []byte{119, 125, 84, 127, 94}

	got = sevensegment.Decode(60789)

	if !bytes.Equal(want, got) {
		t.Fatalf("expected %v but got %v", want, got)
	}
}
Пример #2
0
func Example_sevensegment() {
	b := sevensegment.Decode(12345)
	for i := 0; i < len(b); i++ {
		fmt.Printf("%b ", b[i])
	}
	// Output:
	// 1010000 110111 1010111 1011010 1001111
}