(t *testing.T)
| 90 | } |
| 91 | |
| 92 | func TestScanAll(t *testing.T) { |
| 93 | scenarios := []struct { |
| 94 | name string |
| 95 | content string |
| 96 | separators []rune |
| 97 | keepSeparator bool |
| 98 | keepEmptyTokens bool |
| 99 | ignoreParenthesis bool |
| 100 | expectError bool |
| 101 | expectTokens []string |
| 102 | }{ |
| 103 | { |
| 104 | name: "empty string", |
| 105 | content: "", |
| 106 | separators: DefaultSeparators, |
| 107 | keepSeparator: false, |
| 108 | keepEmptyTokens: false, |
| 109 | ignoreParenthesis: false, |
| 110 | expectError: false, |
| 111 | expectTokens: nil, |
| 112 | }, |
| 113 | { |
| 114 | name: "unbalanced parenthesis", |
| 115 | content: `(a,b() c`, |
| 116 | separators: DefaultSeparators, |
| 117 | keepSeparator: false, |
| 118 | keepEmptyTokens: false, |
| 119 | ignoreParenthesis: false, |
| 120 | expectError: true, |
| 121 | expectTokens: []string{}, |
| 122 | }, |
| 123 | { |
| 124 | name: "unmatching quotes", |
| 125 | content: `'asd"`, |
| 126 | separators: DefaultSeparators, |
| 127 | keepSeparator: false, |
| 128 | keepEmptyTokens: false, |
| 129 | ignoreParenthesis: false, |
| 130 | expectError: true, |
| 131 | expectTokens: []string{}, |
| 132 | }, |
| 133 | { |
| 134 | name: "no separators", |
| 135 | content: `a, b, c, d, e 123, "abc"`, |
| 136 | separators: nil, |
| 137 | keepSeparator: false, |
| 138 | keepEmptyTokens: false, |
| 139 | ignoreParenthesis: false, |
| 140 | expectError: false, |
| 141 | expectTokens: []string{`a, b, c, d, e 123, "abc"`}, |
| 142 | }, |
| 143 | { |
| 144 | name: "default separators", |
| 145 | content: `a, b , c , d e , "a,b, c " , ,, , (123, 456) |
| 146 | `, |
| 147 | separators: DefaultSeparators, |
| 148 | keepSeparator: false, |
| 149 | keepEmptyTokens: false, |
nothing calls this directly
no test coverage detected
searching dependent graphs…