Skip to content

Commit

Permalink
Support the maximum precision for decimals at dfwpnum. (#899)
Browse files Browse the repository at this point in the history
* Support the maximum precision for decimals at dfwpnum.

* Fix error in test.
  • Loading branch information
claudiamurialdo authored Dec 1, 2023
1 parent cdf2e22 commit 9039c5f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion dotnet/src/dotnetframework/GxClasses/Core/GXUtils.cs
Original file line number Diff line number Diff line change
Expand Up @@ -771,14 +771,15 @@ public short dfwnext()
return GX_ASCDEL_WRITEERROR;
}
}
const int MAX_DECIMAL_PRECISION = 29;
public short dfwpnum(decimal num, int dec)
{
if (_writeStatus == FileIOStatus.Closed)
{
GXLogging.Error(log, "Error ADF0004");
return GX_ASCDEL_INVALIDSEQUENCE;
}
appendFld(StringUtil.Str(num, 18, dec).TrimStart(null));
appendFld(StringUtil.Str(num, MAX_DECIMAL_PRECISION, dec).TrimStart(null));
return GX_ASCDEL_SUCCESS;
}
public short dfwptxt(string s, int len)
Expand Down
14 changes: 14 additions & 0 deletions dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,20 @@ public class DfrgFunctions : FileSystemTest
const string APPLICATIONS_CONTENT = "[ { \"Id\": \"4caaaed5-1160-4132-b54f-0191e527a84a\", \"Type\": 1, \"EnvironmentGUID\": \"b3730606-0f2a-4e8a-b395-d8fdf226def8\", \"IsNew\": false }]";
const string DOCUMENT_CONTENT = "Line 1Line 2Line 3";
const string MS923_CONTENT = "1234567890123";

[Fact]
public void dfwpnumTest()
{
GxContext context = new GxContext();
string fileName = Path.Combine(BaseDir, "dfwpnumTest.txt");
context.FileIOInstance.dfwopen(fileName, ",", "\"", 0, "UTF-8");
context.FileIOInstance.dfwpnum(99999999999999999.5M, 5);
context.FileIOInstance.dfwnext();
context.FileIOInstance.dfwclose();

string content = File.ReadAllText(fileName);
Assert.Contains("99999999999999999.5", content, StringComparison.OrdinalIgnoreCase);
}
[Fact]
public void dfrgtxtANSITest()
{
Expand Down

0 comments on commit 9039c5f

Please sign in to comment.