Remove blank lines

This commit is contained in:
bel
2019-12-29 11:18:26 -07:00
parent 1aadfc65b6
commit 8c7f52eb70
2 changed files with 39 additions and 0 deletions

View File

@@ -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)
}
}
}