github.com/xmplusdev/xray-core@v1.8.10/infra/conf/policy_test.go (about)

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