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.

(cherry picked from commit 9039c5f)
  • Loading branch information
claudiamurialdo committed Dec 1, 2023
1 parent 16c10bd commit 9ecd7b1
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 @@ -9,6 +9,20 @@ public class DfrgFunctions
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");

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

The name 'Path' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

The name 'BaseDir' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

The name 'Path' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

The name 'BaseDir' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

The name 'Path' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

The name 'BaseDir' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The name 'Path' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The name 'BaseDir' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The name 'Path' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The name 'BaseDir' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The name 'Path' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / build

The name 'Path' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / build

The name 'BaseDir' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / build

The name 'Path' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / build

The name 'BaseDir' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / build

The name 'Path' does not exist in the current context

Check failure on line 17 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / build

The name 'BaseDir' does not exist in the current context
context.FileIOInstance.dfwopen(fileName, ",", "\"", 0, "UTF-8");
context.FileIOInstance.dfwpnum(99999999999999999.5M, 5);
context.FileIOInstance.dfwnext();
context.FileIOInstance.dfwclose();

string content = File.ReadAllText(fileName);

Check failure on line 23 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

The name 'File' does not exist in the current context

Check failure on line 23 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

The name 'File' does not exist in the current context

Check failure on line 23 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The name 'File' does not exist in the current context

Check failure on line 23 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The name 'File' does not exist in the current context

Check failure on line 23 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / build

The name 'File' does not exist in the current context

Check failure on line 23 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / build

The name 'File' does not exist in the current context
Assert.Contains("99999999999999999.5", content, StringComparison.OrdinalIgnoreCase);

Check failure on line 24 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

The name 'StringComparison' does not exist in the current context

Check failure on line 24 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / test-external-storages

The name 'StringComparison' does not exist in the current context

Check failure on line 24 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The name 'StringComparison' does not exist in the current context

Check failure on line 24 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / Analyze (csharp)

The name 'StringComparison' does not exist in the current context

Check failure on line 24 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / build

The name 'StringComparison' does not exist in the current context

Check failure on line 24 in dotnet/test/DotNetUnitTest/FileIO/DfrgFunctions.cs

View workflow job for this annotation

GitHub Actions / build

The name 'StringComparison' does not exist in the current context
}
[Fact]
public void dfrgtxtANSITest()
{
Expand Down

0 comments on commit 9ecd7b1

Please sign in to comment.