Skip to content

Commit c53be10

Browse files
Fix test configuration issues
- Add SQLCMDMAXVARTYPEWIDTH setting to TestFormatterFloatFormatting to enable width-based fallback testing - Fix TestFormatterRealFormatting to parse columns using whitespace (default separator) instead of semicolon - Ensure tests properly validate decimal vs scientific notation behavior Co-authored-by: dlevy-msft-sql <[email protected]>
1 parent ef8579c commit c53be10

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

pkg/sqlcmd/format_test.go

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,10 @@ func TestFormatterFloatFormatting(t *testing.T) {
166166
s, buf := setupSqlCmdWithMemoryOutput(t)
167167
defer buf.Close()
168168

169+
// Set SQLCMDMAXVARTYPEWIDTH to a non-zero value so FLOAT columns use the 24-char display width
170+
// This enables the width-based fallback logic to be tested properly
171+
s.vars.Set(SQLCMDMAXVARTYPEWIDTH, "256")
172+
169173
// Test query with float values from the issue
170174
query := `SELECT
171175
CAST(788991.19988463481 AS FLOAT) as Longitude1,
@@ -255,12 +259,18 @@ func TestFormatterRealFormatting(t *testing.T) {
255259

256260
// Verify that typical REAL values use decimal notation (not scientific)
257261
assert.Contains(t, dataLine, "123.456", "Output should contain decimal representation of typical REAL value")
262+
258263
// Check that the typical value portion doesn't use scientific notation
259-
// by verifying characters before the extreme value don't contain 'e'
260-
parts := strings.Split(dataLine, ";")
261-
if len(parts) >= 2 {
262-
typicalValuePart := parts[1] // Assuming TypicalValue is the second column (after RowNumber or first column)
263-
assert.NotContains(t, typicalValuePart, "e", "Typical REAL value should not use scientific notation")
264+
// Parse columns using whitespace (the default column separator)
265+
fields := strings.Fields(dataLine)
266+
if len(fields) >= 1 {
267+
// Find the field containing the typical value
268+
for _, field := range fields {
269+
if strings.Contains(field, "123.") {
270+
assert.NotContains(t, field, "e", "Typical REAL value should not use scientific notation")
271+
break
272+
}
273+
}
264274
}
265275

266276
// Verify that extreme REAL values use scientific notation

0 commit comments

Comments
 (0)