package secs2

import (
	"testing"

	"github.com/stretchr/testify/require"
)

func TestShortcuts(t *testing.T) {
	require := require.New(t)

	item := L(
		A("test"),
		J("こんにちは世界"),
		BOOLEAN(true, false),
		B(0x3, 0x4),
		I1(1),
		I2(1),
		I4(1),
		I8(1),
		U1(1),
		U2(1),
		U4(1),
		U8(1),
		F4(1.23),
		F8(1.23),
	)
	require.NoError(item.Error())
	require.Equal(`<L[14]
  <A[4] "test">
  <J[21] "こんにちは世界">
  <BOOLEAN[2] True False>
  <B[2] 0b11 0b100>
  <I1[1] 1>
  <I2[1] 1>
  <I4[1] 1>
  <I8[1] 1>
  <U1[1] 1>
  <U2[1] 1>
  <U4[1] 1>
  <U8[1] 1>
  <F4[1] 1.23000002>
  <F8[1] 1.23>
>`, item.ToSML())

	require.Equal(item.ToBytes(), []byte{
		0x1, 0xe, 0x41, 0x4, 0x74, 0x65, 0x73, 0x74, 0x45, 0x15, 0xe3, 0x81, 0x93, 0xe3, 0x82, 0x93,
		0xe3, 0x81, 0xab, 0xe3, 0x81, 0xa1, 0xe3, 0x81, 0xaf, 0xe4, 0xb8, 0x96, 0xe7, 0x95, 0x8c,
		0x25, 0x2, 0x1, 0x0, 0x21, 0x2, 0x3, 0x4, 0x65, 0x1, 0x1, 0x69, 0x2, 0x0, 0x1, 0x71, 0x4,
		0x0, 0x0, 0x0, 0x1, 0x61, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1, 0xa5, 0x1, 0x1, 0xa9,
		0x2, 0x0, 0x1, 0xb1, 0x4, 0x0, 0x0, 0x0, 0x1, 0xa1, 0x8, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
		0x1, 0x91, 0x4, 0x3f, 0x9d, 0x70, 0xa4, 0x81, 0x8, 0x3f, 0xf3, 0xae, 0x14, 0x7a, 0xe1, 0x47, 0xae,
	})
}
