1// +build !386
2
3package cbor
4
5import (
6	"encoding/hex"
7	"testing"
8)
9
10var enc2 = Encoder{}
11
12var integerTestCases_64bit = []struct {
13	val    int
14	binary string
15}{
16	// Value in 8 bytes.
17	{0xabcd100000000, "\x1b\x00\x0a\xbc\xd1\x00\x00\x00\x00"},
18	{1000000000000, "\x1b\x00\x00\x00\xe8\xd4\xa5\x10\x00"},
19	// Value in 8 bytes.
20	{-0xabcd100000001, "\x3b\x00\x0a\xbc\xd1\x00\x00\x00\x00"},
21	{-1000000000001, "\x3b\x00\x00\x00\xe8\xd4\xa5\x10\x00"},
22}
23
24func TestAppendInt_64bit(t *testing.T) {
25	for _, tc := range integerTestCases_64bit {
26		s := enc2.AppendInt([]byte{}, tc.val)
27		got := string(s)
28		if got != tc.binary {
29			t.Errorf("AppendInt(0x%x)=0x%s, want: 0x%s",
30				tc.val, hex.EncodeToString(s),
31				hex.EncodeToString([]byte(tc.binary)))
32		}
33	}
34}
35