package main import ( "testing" ) func TestAddQuotes(t *testing.T) { for s, wanted := range map[string]string{ "toto": "\"toto\"", "\"titi": "\"titi\"", "\"tutu\"": "\"tutu\"", "te\"te": "\"te\\\"te\"", "\"\"ta\"ta": "\"ta\\\"ta\"", } { if res := addQuotes(s); res != wanted { t.Errorf("%s quoted as %s and not %s", s, res, wanted) } } }