mirror of
https://gitee.com/johng/gf.git
synced 2024-11-30 11:18:02 +08:00
40 lines
1.1 KiB
Go
40 lines
1.1 KiB
Go
// Copyright 2017 gf Author(https://github.com/gogf/gf). All Rights Reserved.
|
|
//
|
|
// This Source Code Form is subject to the terms of the MIT License.
|
|
// If a copy of the MIT was not distributed with this file,
|
|
// You can obtain one at https://github.com/gogf/gf.
|
|
package ghtml_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/gogf/gf/encoding/ghtml"
|
|
"github.com/gogf/gf/test/gtest"
|
|
)
|
|
|
|
func TestStripTags(t *testing.T) {
|
|
gtest.C(t, func(t *gtest.T) {
|
|
src := `<p>Test paragraph.</p><!-- Comment --> <a href="#fragment">Other text</a>`
|
|
dst := `Test paragraph. Other text`
|
|
t.Assert(ghtml.StripTags(src), dst)
|
|
})
|
|
}
|
|
|
|
func TestEntities(t *testing.T) {
|
|
gtest.C(t, func(t *gtest.T) {
|
|
src := `A 'quote' "is" <b>bold</b>`
|
|
dst := `A 'quote' "is" <b>bold</b>`
|
|
t.Assert(ghtml.Entities(src), dst)
|
|
t.Assert(ghtml.EntitiesDecode(dst), src)
|
|
})
|
|
}
|
|
|
|
func TestSpecialChars(t *testing.T) {
|
|
gtest.C(t, func(t *gtest.T) {
|
|
src := `A 'quote' "is" <b>bold</b>`
|
|
dst := `A 'quote' "is" <b>bold</b>`
|
|
t.Assert(ghtml.SpecialChars(src), dst)
|
|
t.Assert(ghtml.SpecialCharsDecode(dst), src)
|
|
})
|
|
}
|