github.com/google/syzkaller@v0.0.0-20240517125934-c0f1611a36d6/pkg/html/html_test.go (about) 1 // Copyright 2023 syzkaller project authors. All rights reserved. 2 // Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. 3 4 package html 5 6 import ( 7 "testing" 8 9 "github.com/stretchr/testify/assert" 10 ) 11 12 func TestDropParam(t *testing.T) { 13 tests := []struct { 14 in string 15 key string 16 value string 17 out string 18 }{ 19 { 20 in: `/upstream?first=a&second=b`, 21 key: `first`, 22 value: ``, 23 out: `/upstream?second=b`, 24 }, 25 { 26 in: `/upstream?first=a&first=b&second=c`, 27 key: `second`, 28 value: ``, 29 out: `/upstream?first=a&first=b`, 30 }, 31 { 32 in: `/upstream?first=a&first=b&second=c`, 33 key: `first`, 34 value: ``, 35 out: `/upstream?second=c`, 36 }, 37 { 38 in: `/upstream?first=a&first=b&second=c`, 39 key: `first`, 40 value: `b`, 41 out: `/upstream?first=a&second=c`, 42 }, 43 } 44 45 for _, test := range tests { 46 got := DropParam(test.in, test.key, test.value) 47 assert.Equal(t, test.out, got) 48 } 49 }