Home | History | Annotate | Download | only in goobj
      1 // Copyright 2013 The Go Authors.  All rights reserved.
      2 // Use of this source code is governed by a BSD-style
      3 // license that can be found in the LICENSE file.
      4 
      5 package goobj
      6 
      7 import "testing"
      8 
      9 var importPathToPrefixTests = []struct {
     10 	in  string
     11 	out string
     12 }{
     13 	{"runtime", "runtime"},
     14 	{"sync/atomic", "sync/atomic"},
     15 	{"golang.org/x/tools/godoc", "golang.org/x/tools/godoc"},
     16 	{"foo.bar/baz.quux", "foo.bar/baz%2equux"},
     17 	{"", ""},
     18 	{"%foo%bar", "%25foo%25bar"},
     19 	{"\x01\x00\x7F", "%01%00%7f%e2%98%ba"},
     20 }
     21 
     22 func TestImportPathToPrefix(t *testing.T) {
     23 	for _, tt := range importPathToPrefixTests {
     24 		if out := importPathToPrefix(tt.in); out != tt.out {
     25 			t.Errorf("importPathToPrefix(%q) = %q, want %q", tt.in, out, tt.out)
     26 		}
     27 	}
     28 }
     29