Remove blank lines
This commit is contained in:
@@ -3,6 +3,7 @@ package rss
|
||||
import (
|
||||
"fmt"
|
||||
"net/http"
|
||||
"strings"
|
||||
"testing"
|
||||
|
||||
"github.com/mmcdole/gofeed"
|
||||
@@ -75,3 +76,32 @@ func TestRSSItemNewEncodeDecode(t *testing.T) {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
func TestClearBlankLines(t *testing.T) {
|
||||
cases := map[string]struct {
|
||||
in string
|
||||
outLines int
|
||||
}{
|
||||
"remove with and without whitespace": {
|
||||
in: `<html>
|
||||
<head>
|
||||
<script>something</script>
|
||||
<style>body{hello:"blue";}</style>
|
||||
</head>
|
||||
<body>
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
</body>
|
||||
</html>`,
|
||||
outLines: 8,
|
||||
},
|
||||
}
|
||||
|
||||
for name, c := range cases {
|
||||
out := clearBlankLines(c.in)
|
||||
if v := len(strings.Split(out, "\n")); v != c.outLines {
|
||||
t.Errorf("%v: want %v lines, got %v from %q: %q", name, c.outLines, v, c.in, out)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user