pipe_test.go 586 B

12345678910111213141516171819202122232425262728
  1. package ndr
  2. import (
  3. "bytes"
  4. "encoding/hex"
  5. "testing"
  6. "github.com/stretchr/testify/assert"
  7. )
  8. const testPipe = "04000000010000000200000003000000040000000300000001000000020000000300000000000000"
  9. type structWithPipe struct {
  10. A []uint32 `ndr:"pipe"`
  11. }
  12. func TestFillPipe(t *testing.T) {
  13. hexStr := TestHeader + testPipe
  14. b, _ := hex.DecodeString(hexStr)
  15. a := new(structWithPipe)
  16. dec := NewDecoder(bytes.NewReader(b))
  17. err := dec.Decode(a)
  18. if err != nil {
  19. t.Fatalf("%v", err)
  20. }
  21. tp := []uint32{1, 2, 3, 4, 1, 2, 3}
  22. assert.Equal(t, tp, a.A, "Value of pipe not as expected")
  23. }