amuz.es/src/go/misc@v1.0.1/han/euckr_test.go (about) 1 package han 2 3 import ( 4 "testing" 5 ) 6 7 func TestConvertToEUCKRUrlEncoded(t *testing.T) { 8 9 // result string get from http://code.cside.com/3rdpage/us/url/converter.html 10 cases := []struct { 11 in string 12 out string 13 }{ 14 { 15 "가나다 abc ABC 123 ~!@#$%^&*()_+`-=[]{}|;':,./<>?", 16 "%B0%A1%B3%AA%B4%D9+abc+ABC+123+%7E%21%40%23%24%25%5E%26%2A%28%29_%2B%60-%3D%5B%5D%7B%7D%7C%3B%27%3A%2C.%2F%3C%3E%3F", 17 }, 18 } 19 20 for _, c := range cases { 21 result, err := ConvertToEUCKRUrlEncoded(c.in) 22 if err != nil { 23 t.Error(err) 24 } else if result != c.out { 25 t.Errorf("src=%s\nresult1=%s\nresult2=%s\n", c.in, c.out, result) 26 } else { 27 t.Log("OK") 28 } 29 result2, err := ConvertFromEUCKRUrlEncoded(result) 30 if err != nil { 31 t.Error("decode err", err) 32 } else { 33 if result2 != c.in { 34 t.Error("decode err2", result2, c.in) 35 } 36 } 37 } 38 }