mirror of
				https://gitee.com/gitea/gitea
				synced 2025-11-04 08:30:25 +08:00 
			
		
		
		
	Add generic set type (#21408)
This PR adds a generic set type to get rid of maps used as sets. Co-authored-by: wxiaoguang <wxiaoguang@gmail.com>
This commit is contained in:
		@@ -7,28 +7,23 @@ package public
 | 
			
		||||
import (
 | 
			
		||||
	"testing"
 | 
			
		||||
 | 
			
		||||
	"code.gitea.io/gitea/modules/container"
 | 
			
		||||
 | 
			
		||||
	"github.com/stretchr/testify/assert"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func TestParseAcceptEncoding(t *testing.T) {
 | 
			
		||||
	kases := []struct {
 | 
			
		||||
		Header   string
 | 
			
		||||
		Expected map[string]bool
 | 
			
		||||
		Expected container.Set[string]
 | 
			
		||||
	}{
 | 
			
		||||
		{
 | 
			
		||||
			Header: "deflate, gzip;q=1.0, *;q=0.5",
 | 
			
		||||
			Expected: map[string]bool{
 | 
			
		||||
				"deflate": true,
 | 
			
		||||
				"gzip":    true,
 | 
			
		||||
			},
 | 
			
		||||
			Header:   "deflate, gzip;q=1.0, *;q=0.5",
 | 
			
		||||
			Expected: container.SetOf("deflate", "gzip"),
 | 
			
		||||
		},
 | 
			
		||||
		{
 | 
			
		||||
			Header: " gzip, deflate, br",
 | 
			
		||||
			Expected: map[string]bool{
 | 
			
		||||
				"deflate": true,
 | 
			
		||||
				"gzip":    true,
 | 
			
		||||
				"br":      true,
 | 
			
		||||
			},
 | 
			
		||||
			Header:   " gzip, deflate, br",
 | 
			
		||||
			Expected: container.SetOf("deflate", "gzip", "br"),
 | 
			
		||||
		},
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user