package mobileconfig import ( "testing" "github.com/stretchr/testify/require" ) func TestXMLEscapeString(t *testing.T) { tests := []struct { input string expected string }{ // characters that should be escaped {"hello & world", "hello & world"}, {"this is a ", "this is a <test>"}, {"\"quotes\" and 'single quotes'", ""quotes" and 'single quotes'"}, {"special chars: \t\n\r", "special chars: "}, // no special characters {"plain string", "plain string"}, // string that already contains escaped characters {"already <escaped>", "already &lt;escaped&gt;"}, // empty string {"", ""}, // multiple special characters {"A&BD\"'E\tF\nG\r", "A&B<C>D"'E F G "}, } for _, tt := range tests { t.Run(tt.input, func(t *testing.T) { out, err := XMLEscapeString(tt.input) require.NoError(t, err) require.Equal(t, tt.expected, out) }) } }