File: urlencode_test.go

package info (click to toggle)
golang-github-valyala-quicktemplate 1.8.0%2Bds1-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 492 kB
  • sloc: makefile: 16; xml: 15
file content (22 lines) | stat: -rw-r--r-- 525 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package quicktemplate

import (
	"net/url"
	"testing"
)

func TestAppendURLEncode(t *testing.T) {
	testAppendURLEncode(t, "")
	testAppendURLEncode(t, "f")
	testAppendURLEncode(t, " ")
	testAppendURLEncode(t, ".-_")
	testAppendURLEncode(t, "ั‚ะตัั‚+this/&=;?\n\t\rabc")
}

func testAppendURLEncode(t *testing.T, s string) {
	expectedResult := url.QueryEscape(s)
	result := appendURLEncode(nil, s)
	if string(result) != expectedResult {
		t.Fatalf("unexpected result %q. Expecting %q. str=%q", result, expectedResult, s)
	}
}