Skip to content

Commit ef8579c

Browse files
Improve REAL formatting test assertions
- Add more precise assertions to verify typical values don't use scientific notation - Split output by lines to examine data separately from headers - Verify the typical value column doesn't contain 'e' notation Co-authored-by: dlevy-msft-sql <[email protected]>
1 parent 99f5b8d commit ef8579c

1 file changed

Lines changed: 20 additions & 2 deletions

File tree

pkg/sqlcmd/format_test.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,8 +242,26 @@ func TestFormatterRealFormatting(t *testing.T) {
242242

243243
output := buf.buf.String()
244244

245-
// Verify that typical REAL values use decimal notation
246-
assert.Contains(t, output, "123.456", "Output should contain decimal representation of typical REAL value")
245+
// Split output into lines to examine the data row separately from headers
246+
lines := strings.Split(output, SqlcmdEol)
247+
var dataLine string
248+
for _, line := range lines {
249+
// Find the data line (contains actual values, not headers or separators)
250+
if strings.Contains(line, "123.") {
251+
dataLine = line
252+
break
253+
}
254+
}
255+
256+
// Verify that typical REAL values use decimal notation (not scientific)
257+
assert.Contains(t, dataLine, "123.456", "Output should contain decimal representation of typical REAL value")
258+
// 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+
}
247265

248266
// Verify that extreme REAL values use scientific notation
249267
assert.Contains(t, output, "e+", "Output should contain scientific notation for extreme REAL value")

0 commit comments

Comments
 (0)