Skip to content

Commit aad6a98

Browse files
Copilotjosesimoes
andcommitted
Add F0 and N0 format tests for float/double ToString()
Co-authored-by: josesimoes <[email protected]>
1 parent d42fc4e commit aad6a98

File tree

2 files changed

+22
-3
lines changed

2 files changed

+22
-3
lines changed

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,3 @@ paket-files/
259259
# VS Code
260260
.vscode/settings.json
261261

262-
263-
# Exclude downloaded nuget.exe
264-
.nuget/nuget.exe

Tests/NFUnitTestArithmetic/UnitTestFormat.cs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,20 +103,30 @@ public void FixedFormat()
103103

104104
TestFormat("0", "F", "0.00");
105105
TestFormat("0", "F4", "0.0000");
106+
TestFormat("0", "F0", "0");
106107
TestFormat("123", "F", "123.00");
108+
TestFormat("123", "F0", "123");
107109
TestFormat("129", "F", "129.00");
108110
TestFormat("-129", "F", "-129.00");
111+
TestFormat("-129", "F0", "-129");
109112
TestFormat("128", "F", "128.00");
110113
TestFormat("128", "F4", "128.0000");
114+
TestFormat("128", "F0", "128");
111115
TestFormat("-128", "F", "-128.00");
112116
TestFormat("-128", "F2", "-128.00");
117+
TestFormat("-128", "F0", "-128");
113118
TestFormat("1234", "F2", "1234.00");
119+
TestFormat("1234", "F0", "1234");
114120
TestFormat("-1234", "F", "-1234.00");
121+
TestFormat("-1234", "F0", "-1234");
115122
TestFormat("1234", "F6", "1234.000000");
116123
TestFormat("-1234", "F6", "-1234.000000");
117124
TestFormat("123.78", "F3", "123.780");
118125
TestFormat("123.78", "F1", "123.8");
126+
TestFormat("123.78", "F0", "124");
119127
TestFormat("1234.8999", "F3", "1234.900");
128+
TestFormat("1234.8999", "F0", "1235");
129+
TestFormat("-1234.8999", "F0", "-1235");
120130

121131
sampleDisplay.WriteOutput();
122132

@@ -240,21 +250,33 @@ public void NumberFormat()
240250
sampleDisplay = new SampleDisplay();
241251

242252
TestFormat("123", "N", "123.00"); // default for CultureInvariant is 2 decimal places
253+
TestFormat("123", "N0", "123");
243254
TestFormat("129", "N", "129.00");
255+
TestFormat("129", "N0", "129");
244256
TestFormat("-129", "N", "-129.00");
257+
TestFormat("-129", "N0", "-129");
245258
TestFormat("128", "N", "128.00");
246259
TestFormat("128", "N4", "128.0000");
260+
TestFormat("128", "N0", "128");
247261
TestFormat("-128", "N", "-128.00");
248262
TestFormat("-128", "N2", "-128.00");
263+
TestFormat("-128", "N0", "-128");
249264
TestFormat("1234", "N2", "1,234.00");
265+
TestFormat("1234", "N0", "1,234");
250266
TestFormat("-1234", "N", "-1,234.00");
267+
TestFormat("-1234", "N0", "-1,234");
251268
TestFormat("1234", "N6", "1,234.000000");
252269
TestFormat("-1234", "N6", "-1,234.000000");
253270
TestFormat("1234.567", "N2", "1,234.57");
271+
TestFormat("1234.567", "N0", "1,235");
254272
TestFormat("-1234.567", "N2", "-1,234.57");
273+
TestFormat("-1234.567", "N0", "-1,235");
255274
TestFormat("123456.78", "N2", "123,456.78");
275+
TestFormat("123456.78", "N0", "123,457");
256276
TestFormat("1234567.1210", "N2", "1,234,567.12");
277+
TestFormat("1234567.1210", "N0", "1,234,567");
257278
TestFormat("-0.099999999999999978", "N2", "-0.10");
279+
TestFormat("-0.099999999999999978", "N0", "0");
258280
sampleDisplay.WriteOutput();
259281
}
260282

0 commit comments

Comments
 (0)