| 8 | ) |
| 9 | |
| 10 | func TestExtractStringValue(t *testing.T) { |
| 11 | tests := []struct { |
| 12 | name string |
| 13 | input string |
| 14 | expected any |
| 15 | expectError bool |
| 16 | }{ |
| 17 | { |
| 18 | name: "empty string", |
| 19 | input: "", |
| 20 | expected: "", |
| 21 | expectError: true, |
| 22 | }, |
| 23 | { |
| 24 | name: "empty quoted string", |
| 25 | input: "", |
| 26 | expected: "", |
| 27 | expectError: true, |
| 28 | }, |
| 29 | { |
| 30 | name: "quoted string", |
| 31 | input: "'hello world'", |
| 32 | expected: "hello world", |
| 33 | }, |
| 34 | { |
| 35 | name: "quoted number string", |
| 36 | input: "'123'", |
| 37 | expected: "123", |
| 38 | }, |
| 39 | { |
| 40 | name: "quoted string with spaces", |
| 41 | input: "' spaced '", |
| 42 | expected: " spaced ", |
| 43 | }, |
| 44 | { |
| 45 | name: "empty quoted string", |
| 46 | input: "''", |
| 47 | expected: "", |
| 48 | }, |
| 49 | { |
| 50 | name: "not quoted string", |
| 51 | input: "not_quoted", |
| 52 | expectError: true, |
| 53 | }, |
| 54 | { |
| 55 | name: "quoted only at start", |
| 56 | input: "'missing_end", |
| 57 | expectError: true, |
| 58 | }, |
| 59 | { |
| 60 | name: "quoted only at end", |
| 61 | input: "missing_start'", |
| 62 | expectError: true, |
| 63 | }, |
| 64 | } |
| 65 | |
| 66 | for _, tt := range tests { |
| 67 | t.Run(tt.name, func(t *testing.T) { |