You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
29 lines
677 B
Go
29 lines
677 B
Go
// Copyright (c) 2015 Dalton Hubble. All rights reserved.
|
|
// Copyrights licensed under the MIT License.
|
|
|
|
package oauth1
|
|
|
|
import "testing"
|
|
|
|
func testPercentEncode(t *testing.T) {
|
|
cases := []struct {
|
|
input string
|
|
expected string
|
|
}{
|
|
{" ", "%20"},
|
|
{"%", "%25"},
|
|
{"&", "%26"},
|
|
{"-._", "-._"},
|
|
{" /=+", "%20%2F%3D%2B"},
|
|
{"Ladies + Gentlemen", "Ladies%20%2B%20Gentlemen"},
|
|
{"An encoded string!", "An%20encoded%20string%21"},
|
|
{"Dogs, Cats & Mice", "Dogs%2C%20Cats%20%26%20Mice"},
|
|
{"☃", "%E2%98%83"},
|
|
}
|
|
for _, c := range cases {
|
|
if output := percentEncode(c.input); output != c.expected {
|
|
t.Errorf("expected %s, got %s", c.expected, output)
|
|
}
|
|
}
|
|
}
|