newline battles continue
This commit is contained in:
@@ -92,15 +92,61 @@ func TestClearBlankLines(t *testing.T) {
|
||||
<br>
|
||||
<br>
|
||||
<br>
|
||||
<br/><br/>
|
||||
<br/> <br/>
|
||||
</body>
|
||||
</html>`,
|
||||
outLines: 8,
|
||||
outLines: 1,
|
||||
},
|
||||
"sample content": {
|
||||
in: `<html>
|
||||
Linux
|
||||
Blog
|
||||
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
|
||||
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
|
||||
<img src="https://www.jeremymorgan.com/images/programming-blog.png" alt="Programming
|
||||
Blog"/><h1><a href="https://www.jeremymorgan.com/" rel="noopener noreferrer" target="_blank" referrerpolicy="no-referrer">Jeremy
|
||||
Morgan</a></h1><h2>Mostly
|
||||
Coherent
|
||||
Ramblings
|
||||
of
|
||||
a
|
||||
Silicon
|
||||
Forest
|
||||
Software
|
||||
Developer</h2><br/><br/><br/>
|
||||
<ul><br/>
|
||||
<li>RSS</li><br/>
|
||||
<br/></ul><br/>
|
||||
<br/><br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/><br/>
|
||||
<br/><ul><li><a href="https://www.jeremymorgan.com/" rel="noopener noreferrer" target="_blank" referrerpolicy="no-referrer">Home</a></li><li><a href="https://www.jeremymorgan.com/tutorials/" rel="noopener noreferrer" target="_blank" referrerpolicy="no-referrer">Tutorials</a></li><li><a href="https://www.jeremymorgan.com/blog/programming/" rel="noopener noreferrer" target="_blank" referrerpolicy="no-referrer">Programming</a></li><li><a href="https://www.jeremymorgan.com/blog/raspberry-pi/" rel="noopener noreferrer" target="_blank" referrerpolicy="no-referrer">Raspberry
|
||||
Pi</a></li><li><a href="https://www.jeremymorgan.com/blog/linux/" rel="noopener noreferrer" target="_blank" referrerpolicy="no-referrer">Linux</a></li><li><a href="https://www.jeremymorgan.com/blog/dotnet/" rel="noopener noreferrer" target="_blank" referrerpolicy="no-referrer">.Net</a></li><li><a href="https://github.com/JeremyMorgan" rel="noopener noreferrer" target="_blank" referrerpolicy="no-referrer">My
|
||||
Projects</a></li><li><a href="https://www.jeremymorgan.com/contact/" rel="noopener noreferrer" target="_blank" referrerpolicy="no-referrer">Contact
|
||||
Me</a></li></ul><br/><br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/><br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<br/>
|
||||
<h1>Trying
|
||||
Out
|
||||
</html>`,
|
||||
outLines: 6,
|
||||
},
|
||||
}
|
||||
|
||||
for name, c := range cases {
|
||||
out := clearBlankLines(c.in)
|
||||
if v := len(strings.Split(out, "\n")); v != c.outLines {
|
||||
cnts := []int{
|
||||
strings.Count(out, "<br>"),
|
||||
strings.Count(out, "<br/>"),
|
||||
}
|
||||
if v := cnts[0] + cnts[1]; 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