1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
|
// Tideland Go Libray - Feed Utils
//
// Copyright (C) 2012-2017 Frank Mueller / Tideland / Oldenburg / Germany
//
// All rights reserved. Use of this source code is governed
// by the new BSD license.
package utils_test
//--------------------
// IMPORTS
//--------------------
import (
"testing"
"github.com/tideland/golib/audit"
"github.com/tideland/golib/feed/utils"
)
//--------------------
// TESTS
//--------------------
func TestStripTags(t *testing.T) {
assert := audit.NewTestingAssertion(t, true)
in := "<p>The quick brown <b>fox</b> jumps over the lazy <em>dog</em>.</p>"
out, err := utils.StripTags(in, true, false)
assert.Nil(err, "No error during stripping.")
assert.Equal(out, "The quick brown fox jumps over the lazy dog .", "Tags have been removed.")
in = "<p>The quick brown <b>fox</b> jumps over the lazy <em>dog.</p>"
out, err = utils.StripTags(in, true, false)
assert.ErrorMatch(err, `XML syntax error on line 1.*`, "Error in document detected.")
in = "<p>The quick brown <b>fox</b> jumps over the lazy <em>dog.</p>"
out, err = utils.StripTags(in, false, false)
assert.Nil(err, "No error during stripping.")
assert.Equal(out, "The quick brown fox jumps over the lazy dog.", "Tags have been removed.")
in = "<p>The quick brown <b>fox & goose</b> jump over the lazy <em>dog</em>.</p>"
out, err = utils.StripTags(in, true, false)
assert.Nil(err, "No error during stripping.")
assert.Equal(out, "The quick brown fox & goose jump over the lazy <em>dog</em>.", "Tags have been removed.")
in = "<p>The quick brown <b>fox &amp; goose</b> jump over the lazy <em>dog</em>.</p>"
out, err = utils.StripTags(in, true, true)
assert.Nil(err, "No error during stripping.")
assert.Equal(out, "The quick brown fox & goose jump over the lazy dog .", "Tags have been removed.")
}
// EOF
|