zenity/internal/zencmd/markup_test.go

36 lines
625 B
Go
Raw Normal View History

2022-06-14 08:03:32 -04:00
package zencmd
2022-12-20 07:23:15 -05:00
import "testing"
2022-06-14 08:03:32 -04:00
var markupTests = []struct {
data string
want string
}{
// success cases
{"", ``},
{"abc", `abc`},
{"&lt;", `<`},
{"&amp;", `&`},
{"&quot;", `"`},
{"<i></i>", ``},
{"<i>abc</i>", `abc`},
{"<i>&quot;</i>", `"`},
{"<!--abc-->", ``},
// failure cases
{"<", `<`},
{"<i", `<i`},
{"<i>", `<i>`},
{"<i></b>", `<i></b>`},
{"<i>&amp</i>", `<i>&amp</i>`},
}
func TestStripMarkup(t *testing.T) {
2022-12-15 09:29:56 -05:00
t.Parallel()
2022-06-14 08:03:32 -04:00
for _, test := range markupTests {
if got := StripMarkup(test.data); got != test.want {
t.Errorf("StripMarkup(%q) = %q; want %q", test.data, got, test.want)
}
}
}