go(util): modify SanitiseFName, add test
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
c9f15c9b99
commit
fda5f46623
|
@ -12,9 +12,9 @@
|
|||
)
|
||||
|
||||
// SanitiseFName clears spaces from the string that is supposed to be a file
|
||||
// name.
|
||||
// name so that the result is safer to use with e.g. latex.
|
||||
func SanitiseFName(s string) string {
|
||||
return strings.ReplaceAll(s, " ", "_")
|
||||
return strings.ReplaceAll(s, " ", "--")
|
||||
}
|
||||
|
||||
// CreateFolder creates a folder at the specified path, if it doesn't already
|
||||
|
|
|
@ -41,3 +41,12 @@ func TestCreatePath(t *testing.T) {
|
|||
t.Error("error cleaning up: ", err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSanitiseFname(t *testing.T) {
|
||||
want := "Stochastic--Hill--Climbing"
|
||||
got := SanitiseFName("Stochastic Hill Climbing")
|
||||
|
||||
if want != got {
|
||||
t.Errorf("failed to sanitise file name, want: %s, got: %s", want, got)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue