github.com/ncw/rclone@v1.48.1-0.20190724201158-a35aa1360e3e/backend/fichier/replace_test.go (about)

     1  package fichier
     2  
     3  import "testing"
     4  
     5  func TestReplace(t *testing.T) {
     6  	for _, test := range []struct {
     7  		in  string
     8  		out string
     9  	}{
    10  		{"", ""},
    11  		{"abc 123", "abc 123"},
    12  		{"\"'<>/\\$`", `"'<>/\$``},
    13  		{" leading space", "␠leading space"},
    14  	} {
    15  		got := replaceReservedChars(test.in)
    16  		if got != test.out {
    17  			t.Errorf("replaceReservedChars(%q) want %q got %q", test.in, test.out, got)
    18  		}
    19  		got2 := restoreReservedChars(got)
    20  		if got2 != test.in {
    21  			t.Errorf("restoreReservedChars(%q) want %q got %q", got, test.in, got2)
    22  		}
    23  	}
    24  }