github.com/imannamdari/v2ray-core/v5@v5.0.5/infra/conf/v4/policy_test.go (about)

     1  package v4_test
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/imannamdari/v2ray-core/v5/common"
     7  	v4 "github.com/imannamdari/v2ray-core/v5/infra/conf/v4"
     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 := v4.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  }