package helper import "testing" func Test_htmlSpecialChars(t *testing.T) { type args struct { text string flags int } tests := []struct { name string args args want string }{ { name: "t1", args: args{text: "Test", flags: EntQuotes}, want: "<a href='test'>Test</a>", }, { name: "t2", args: args{text: "Test", flags: EntCompat}, want: "<a href='test'>Test</a>", }, { name: "t3", args: args{text: "T est", flags: EntCompat | EntSpace}, want: "<a href='test'>T est</a>", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := htmlSpecialChars(tt.args.text, tt.args.flags); got != tt.want { t.Errorf("htmlSpecialChars() = %v, want %v", got, tt.want) } }) } } func Test_htmlSpecialCharsDecode(t *testing.T) { type args struct { text string flags int } tests := []struct { name string args args want string }{ { name: "t1", args: args{ text: "<a href='test'>Test</a>", flags: EntCompat, }, want: "Test", }, { name: "t2", args: args{ text: "<a href='test'>Test</a>", flags: EntQuotes, }, want: "Test", }, { name: "t3", args: args{ text: "
this -> "
\n", flags: EntNoQuotes, }, want: "this -> "
\n", }, { name: "t4", args: args{ text: "this -> "
\n", flags: EntCompat, }, want: "this -> \"
\n", }, { name: "t5", args: args{ text: "this -> "
\n", flags: EntCompat | EntSpace, }, want: "this -> \"
\n", }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := htmlSpecialCharsDecode(tt.args.text, tt.args.flags); got != tt.want { t.Errorf("htmlSpecialCharsDecode() = %v, want %v", got, tt.want) } }) } }