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)
}
}
|