(t *testing.T)
| 164 | } |
| 165 | |
| 166 | func TestTSQL_NationalStringLiteral(t *testing.T) { |
| 167 | tkz := newSQLServerTokenizer(t) |
| 168 | |
| 169 | tests := []struct { |
| 170 | name string |
| 171 | input string |
| 172 | wantValue string |
| 173 | }{ |
| 174 | {"N'hello'", "N'hello'", "hello"}, |
| 175 | {"n'hello' lowercase", "n'hello'", "hello"}, |
| 176 | {"N'unicode chars'", "N'こんにちは'", "こんにちは"}, |
| 177 | {"N'' empty", "N''", ""}, |
| 178 | {"in expression", "SELECT N'test'", "test"}, |
| 179 | } |
| 180 | |
| 181 | for _, tt := range tests { |
| 182 | t.Run(tt.name, func(t *testing.T) { |
| 183 | tokens := tokenize(t, tkz, tt.input) |
| 184 | found := false |
| 185 | for _, tok := range tokens { |
| 186 | if tok.Token.Type == models.TokenTypeNationalStringLiteral { |
| 187 | if tok.Token.Value != tt.wantValue { |
| 188 | t.Errorf("expected value %q, got %q", tt.wantValue, tok.Token.Value) |
| 189 | } |
| 190 | if tok.Token.Quote != 'N' { |
| 191 | t.Errorf("expected Quote='N', got %q", tok.Token.Quote) |
| 192 | } |
| 193 | found = true |
| 194 | break |
| 195 | } |
| 196 | } |
| 197 | if !found { |
| 198 | t.Errorf("did not find TokenTypeNationalStringLiteral in tokens:") |
| 199 | for i, tok := range tokens { |
| 200 | t.Logf(" [%d] type=%v value=%q", i, tok.Token.Type, tok.Token.Value) |
| 201 | } |
| 202 | } |
| 203 | }) |
| 204 | } |
| 205 | } |
| 206 | |
| 207 | func TestTSQL_NWithoutQuoteIsIdentifier(t *testing.T) { |
| 208 | // N not followed by quote should be a regular identifier |
nothing calls this directly
no test coverage detected