| 123456789101112131415161718192021222324252627282930 |
- package protocol
- import (
- "testing"
- "time"
- )
- func TestResidualUntrustedEmptyOK(t *testing.T) {
- if err := ResidualUntrusted(nil, time.Unix(0, 0)); err != nil {
- t.Fatal(err)
- }
- if err := ResidualUntrusted([][]byte{{}}, time.Unix(0, 0)); err != nil {
- t.Fatal(err)
- }
- }
- func TestResidualUntrustedAnyBytesFailClosed(t *testing.T) {
- now := time.Unix(0, 0)
- cases := [][][]byte{
- {{0x01}},
- {make([]byte, 4096)},
- {{0xA5}, {0x5A, 0x82}},
- {append([]byte{0x11, 0x22}, GetTemperatureRequest()...)},
- }
- for i, c := range cases {
- if err := ResidualUntrusted(c, now); err == nil {
- t.Fatalf("case %d must fail closed", i)
- }
- }
- }
|