-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(v0.0.4/CLI): Add option to specify floating point precision
With option "-f" or "--fpp" a floating point precision may be specified. NOTE: These is valid for REAL and LREAL values, since we cannot distinguish between them anymore (JSON string).
- Loading branch information
1 parent
9b987f5
commit dbf0eae
Showing
31 changed files
with
194 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
examples/examples/.snappy-verified/MyTestSuiteName.MyTestName.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...nappy.examples.PRG_TcUnit.fbTcunitExample.Test some stuff with TcHaxx.Snappy.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 0 additions & 23 deletions
23
...y-verified/TcHaxx_Snappy.examples.PRG_TcUnit.fbTcunitExample.Test some stuff.verified.txt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global using Xunit; |
6 changes: 6 additions & 0 deletions
6
...ests/JsonConverter/DoubleConverterTests.ShouldUseDoublePrecision_precision=0.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
0, | ||
-1, | ||
3, | ||
1234568 | ||
] |
6 changes: 6 additions & 0 deletions
6
...ests/JsonConverter/DoubleConverterTests.ShouldUseDoublePrecision_precision=1.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
0.0, | ||
-1.0, | ||
3.0, | ||
1234568.0 | ||
] |
6 changes: 6 additions & 0 deletions
6
...ests/JsonConverter/DoubleConverterTests.ShouldUseDoublePrecision_precision=2.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
0.00, | ||
-1.00, | ||
3.00, | ||
1234567.99 | ||
] |
6 changes: 6 additions & 0 deletions
6
...ests/JsonConverter/DoubleConverterTests.ShouldUseDoublePrecision_precision=3.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
0.000, | ||
-1.000, | ||
3.000, | ||
1234567.988 | ||
] |
6 changes: 6 additions & 0 deletions
6
...ests/JsonConverter/DoubleConverterTests.ShouldUseDoublePrecision_precision=4.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
0.0000, | ||
-1.0000, | ||
3.0000, | ||
1234567.9877 | ||
] |
6 changes: 6 additions & 0 deletions
6
...ests/JsonConverter/DoubleConverterTests.ShouldUseDoublePrecision_precision=5.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
[ | ||
0.00000, | ||
-1.00001, | ||
3.00000, | ||
1234567.98765 | ||
] |
7 changes: 7 additions & 0 deletions
7
...ests/JsonConverter/DoubleConverterTests.ShouldUseDoublePrecision_precision=6.verified.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
[ | ||
0.000000, | ||
-1.000010, | ||
3.000000, | ||
1234567.987654, | ||
-98765433209999996300983879418780084752989155443507930248275595876839919513686268729884672.000000 | ||
] |
30 changes: 30 additions & 0 deletions
30
src/TcHaxx.Snappy.Verifier.Tests/JsonConverter/DoubleConverterTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using TcHaxx.Snappy.Verifier.JsonConverter; | ||
|
||
namespace TcHaxx.Snappy.Verifier.Tests.JsonConverter; | ||
|
||
public class DoubleConverterTests : VerifyBase | ||
{ | ||
public DoubleConverterTests() | ||
: base() | ||
{ | ||
|
||
} | ||
[Theory] | ||
[InlineData(0, 0.0, -1.00001, 3.00000000000000007, 1234567.987654321)] | ||
[InlineData(1, 0.0, -1.00001, 3.00000000000000007, 1234567.987654321)] | ||
[InlineData(2, 0.0, -1.00001, 3.00000000000000007, 1234567.987654321)] | ||
[InlineData(3, 0.0, -1.00001, 3.00000000000000007, 1234567.987654321)] | ||
[InlineData(4, 0.0, -1.00001, 3.00000000000000007, 1234567.987654321)] | ||
[InlineData(5, 0.0, -1.00001, 3.00000000000000007, 1234567.987654321)] | ||
[InlineData(6, 0.0, -1.00001, 3.00000000000000007, 1234567.987654321, -9.876543321e88)] | ||
public async Task ShouldUseDoublePrecision(ushort precision, params double[] values) | ||
{ | ||
var settings = new VerifySettings(); | ||
settings.AddExtraSettings(_ => | ||
{ | ||
_.Converters.Add(new DoubleConverter(precision)); | ||
}); | ||
|
||
await Verify(values, settings).UseParameters(precision); | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
src/TcHaxx.Snappy.Verifier.Tests/TcHaxx.Snappy.Verifier.Tests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFrameworks>net6.0;net8.0</TargetFrameworks> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
<LangVersion>Latest</LangVersion> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" /> | ||
<PackageReference Include="xunit" Version="2.6.6" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.6"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="coverlet.collector" Version="6.0.0"> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
<PrivateAssets>all</PrivateAssets> | ||
</PackageReference> | ||
<PackageReference Include="Verify.xunit" Version="23.1.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\TcHaxx.Snappy.Verifier\TcHaxx.Snappy.Verifier.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
using System.Runtime.CompilerServices; | ||
|
||
[assembly: InternalsVisibleTo("TcHaxx.Snappy.Verifier.Tests")] |
10 changes: 10 additions & 0 deletions
10
src/TcHaxx.Snappy.Verifier/JsonConverter/DoubleConverter.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using System.Globalization; | ||
|
||
namespace TcHaxx.Snappy.Verifier.JsonConverter; | ||
|
||
internal class DoubleConverter(ushort precision) : WriteOnlyJsonConverter<double> | ||
{ | ||
|
||
public override void Write(VerifyJsonWriter writer, double theDouble) => | ||
writer.WriteValue(theDouble.ToString($"F{precision}", CultureInfo.InvariantCulture)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.