Skip to content

Commit

Permalink
Adds additional test cases for DisableQuote
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Lacroix committed Apr 23, 2020
1 parent c7455de commit aff00fe
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions text_formatter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,32 +59,42 @@ func TestQuoting(t *testing.T) {
checkQuoting(false, "foo@bar")
checkQuoting(false, "foobar^")
checkQuoting(false, "+/-_^@f.oobar")
checkQuoting(true, "foo\n\rbar")
checkQuoting(true, "foobar$")
checkQuoting(true, "&foobar")
checkQuoting(true, "x y")
checkQuoting(true, "x,y")
checkQuoting(false, errors.New("invalid"))
checkQuoting(true, errors.New("invalid argument"))

// Test for quoting disabled
tf.DisableQuote = true
checkQuoting(false, "")
checkQuoting(false, "abcd")
checkQuoting(false, "foo\n\rbar")
checkQuoting(false, errors.New("invalid argument"))
tf.DisableQuote = false

// Test for quoting empty fields.
tf.QuoteEmptyFields = true
checkQuoting(true, "")
checkQuoting(false, "abcd")
checkQuoting(true, "foo\n\rbar")
checkQuoting(true, errors.New("invalid argument"))

// Test forcing quotes.
tf.ForceQuote = true
checkQuoting(true, "")
checkQuoting(true, "abcd")
checkQuoting(true, "foo\n\rbar")
checkQuoting(true, errors.New("invalid argument"))

// Test forcing quotes when also disabling them.
tf.DisableQuote = true
checkQuoting(true, "")
checkQuoting(true, "abcd")
checkQuoting(true, "foo\n\rbar")
checkQuoting(true, errors.New("invalid argument"))

// Test disabling quotes
tf.ForceQuote = false
tf.QuoteEmptyFields = false
checkQuoting(false, "")
checkQuoting(false, "abcd")
checkQuoting(false, "foo\n\rbar")
checkQuoting(false, errors.New("invalid argument"))
}

func TestEscaping(t *testing.T) {
Expand Down

0 comments on commit aff00fe

Please sign in to comment.