policy_test.go 591 B

12345678910111213141516171819202122232425262728293031323334353637383940
  1. package conf_test
  2. import (
  3. "testing"
  4. "github.com/xtls/xray-core/common"
  5. . "github.com/xtls/xray-core/infra/conf"
  6. )
  7. func TestBufferSize(t *testing.T) {
  8. cases := []struct {
  9. Input int32
  10. Output int32
  11. }{
  12. {
  13. Input: 0,
  14. Output: 0,
  15. },
  16. {
  17. Input: -1,
  18. Output: -1,
  19. },
  20. {
  21. Input: 1,
  22. Output: 1024,
  23. },
  24. }
  25. for _, c := range cases {
  26. bs := c.Input
  27. pConf := Policy{
  28. BufferSize: &bs,
  29. }
  30. p, err := pConf.Build()
  31. common.Must(err)
  32. if p.Buffer.Connection != c.Output {
  33. t.Error("expected buffer size ", c.Output, " but got ", p.Buffer.Connection)
  34. }
  35. }
  36. }