39 lines
1.2 KiB
Go
39 lines
1.2 KiB
Go
// Copyright 2021, Henrik Sölver henrik.solver@gmail.com
|
|
// SPDX-License-Identifier: BSD-3-Clause
|
|
package ipp
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
// func TestUnmarshalSimpleKeyword(T *testing.T) {
|
|
// testdata := []byte{
|
|
// 0x00, 0x14,
|
|
// 0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x65, 0x64, 0x2d, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73,
|
|
// 0x00, 0x16,
|
|
// 0x70, 0x72, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x2d, 0x6d, 0x61, 0x6b, 0x65, 0x2d, 0x61, 0x6e, 0x64, 0x2d, 0x6d, 0x6f, 0x64, 0x65, 0x6c,
|
|
// }
|
|
// buf := bytes.NewBuffer(testdata)
|
|
// var k keyWord
|
|
// k.unmarshal(buf)
|
|
// assert.Equal(T, k.name, "requested-attributes")
|
|
// assert.Equal(T, k.values[0], "printer-make-and-model")
|
|
// }
|
|
|
|
func TestMarshalSimpleKeyword(T *testing.T) {
|
|
testdata := []byte{
|
|
0x44, 0x00, 0x14,
|
|
0x72, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x65, 0x64, 0x2d, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x73,
|
|
0x00, 0x16,
|
|
0x70, 0x72, 0x69, 0x6e, 0x74, 0x65, 0x72, 0x2d, 0x6d, 0x61, 0x6b, 0x65, 0x2d, 0x61, 0x6e, 0x64, 0x2d, 0x6d, 0x6f, 0x64, 0x65, 0x6c,
|
|
}
|
|
|
|
k := NewKeyWord("requested-attributes")
|
|
k.addValue("printer-make-and-model")
|
|
m := k.marshal()
|
|
assert.Equal(T, testdata, m, "Should be equal")
|
|
|
|
}
|