github.com/TeaOSLab/EdgeNode@v1.3.8/internal/waf/values/string_list_test.go (about)

     1  // Copyright 2022 Liuxiangchao iwind.liu@gmail.com. All rights reserved. Official site: https://goedge.cn .
     2  
     3  package values_test
     4  
     5  import (
     6  	"github.com/TeaOSLab/EdgeNode/internal/waf/values"
     7  	"github.com/iwind/TeaGo/assert"
     8  	"testing"
     9  )
    10  
    11  func TestParseStringList(t *testing.T) {
    12  	var a = assert.NewAssertion(t)
    13  
    14  	{
    15  		var list = values.ParseStringList("", false)
    16  		a.IsFalse(list.Contains("hello"))
    17  	}
    18  
    19  	{
    20  		var list = values.ParseStringList(`hello
    21  
    22  world
    23  hi
    24  
    25  people`, false)
    26  		a.IsTrue(list.Contains("hello"))
    27  		a.IsFalse(list.Contains("hello1"))
    28  		a.IsFalse(list.Contains("Hello"))
    29  		a.IsTrue(list.Contains("hi"))
    30  	}
    31  	{
    32  		var list = values.ParseStringList(`Hello
    33  
    34  world
    35  hi
    36  
    37  people`, true)
    38  		a.IsTrue(list.Contains("hello"))
    39  		a.IsTrue(list.Contains("Hello"))
    40  		a.IsTrue(list.Contains("HELLO"))
    41  		a.IsFalse(list.Contains("How"))
    42  	}
    43  }