fix output for empty string
diff --git a/formatter.go b/formatter.go
index ea329d1..9578eb9 100644
--- a/formatter.go
+++ b/formatter.go
@@ -79,6 +79,9 @@
s := v.Get()
z := len(s)
n := (z + lim - 1) / lim
+ if n < 1 {
+ n = 1 // empty string still produces output
+ }
sep := append(spacePlusLFBytes, make([]byte, fo.d)...)
for j := 0; j < fo.d; j++ {
sep[3+j] = '\t'
diff --git a/formatter_test.go b/formatter_test.go
index f818b8a..c81813a 100644
--- a/formatter_test.go
+++ b/formatter_test.go
@@ -29,6 +29,8 @@
var long = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
var gosyntax = []test{
+ {"", `""`},
+ {"a", `"a"`},
{1, "1"},
{F(5), "F(5)"},
{long, `"`+long[:50]+"\" +\n\""+long[50:]+`"`},