-
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.
Feature/issue 6 handle type string (#112)
* build: remove global.json * build: remove .netstandard dependency and old msbuild dependencies * tests: add more tests for coverage * build: remove unused dependency on Microsoft.CodeAnalysis.CSharp.Workspaces * refactor: remove SQ complaint * test: add more tests for better coverage * feat: add parameterized `ToString` functions for REAL and BOOLEAN Fixes #111 --------- Co-authored-by: Stephen Reindl <[email protected]>
- Loading branch information
Showing
11 changed files
with
344 additions
and
69 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
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,33 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
|
||
<IsPackable>false</IsPackable> | ||
<IsTestProject>true</IsTestProject> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="coverlet.collector" Version="6.0.2"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" /> | ||
<PackageReference Include="xunit" Version="2.9.2" /> | ||
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Oberon0.System\Oberon0.System.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Using Include="Xunit" /> | ||
</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
namespace Oberon0.System.Tests; | ||
|
||
using Oberon0System; | ||
using Xunit; | ||
|
||
public static partial class Oberon0SystemTests | ||
{ | ||
[Theory] | ||
[InlineData(0.0, false)] | ||
[InlineData(double.NegativeInfinity, true)] | ||
[InlineData(double.PositiveInfinity, true)] | ||
public static void CanCallIsInfinity(double value, bool expected) | ||
{ | ||
// Act | ||
bool result = Oberon0System.IsInfinity(value); | ||
|
||
// Assert | ||
Assert.Equal(expected, result); | ||
} | ||
} |
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,77 @@ | ||
using System.Globalization; | ||
|
||
namespace Oberon0.System.Tests; | ||
|
||
using Oberon0System; | ||
using Xunit; | ||
|
||
public static partial class Oberon0SystemTests | ||
{ | ||
[Theory] | ||
[InlineData(0)] | ||
[InlineData(int.MaxValue)] | ||
[InlineData(int.MinValue)] | ||
[InlineData(5274097)] | ||
[InlineData(-771204301)] | ||
public static void CanCallConvertToStringWithInt(int value) | ||
{ | ||
// Act | ||
string result = Oberon0System.ConvertToString(value); | ||
|
||
// Assert | ||
Assert.Equal(value.ToString(), result); | ||
} | ||
|
||
[Theory] | ||
[InlineData(0.0)] | ||
[InlineData(1.0)] | ||
[InlineData(double.MinValue)] | ||
[InlineData(5274097.9283)] | ||
[InlineData(-771204301.211)] | ||
public static void CanCallConvertToStringWithReal(double value) | ||
{ | ||
// Act | ||
string result = Oberon0System.ConvertToString(value); | ||
|
||
// Assert | ||
Assert.Equal(value.ToString(CultureInfo.InvariantCulture), result); | ||
} | ||
|
||
[Theory] | ||
[InlineData(false)] | ||
[InlineData(true)] | ||
public static void CanCallConvertToStringWithBoolean(bool value) | ||
{ | ||
// Act | ||
string result = Oberon0System.ConvertToString(value); | ||
|
||
// Assert | ||
Assert.Equal(value.ToString(), result); | ||
} | ||
|
||
|
||
[Theory] | ||
[InlineData(0.0, "0", "G")] | ||
[InlineData(1.0, "1", "G")] | ||
[InlineData(10000000000000.00001, "10000000000000", "G")] | ||
[InlineData(0.1, "0.1", "G")] | ||
[InlineData(2.3E-06, "2.3E-06", "G")] | ||
[InlineData(2.3E06, "2300000", "G")] | ||
[InlineData(double.MinValue, "-1.7976931348623157E+308", "G")] | ||
public static void TestToStringRealFormat(double value, string expected, string format) | ||
{ | ||
string result = Oberon0System.ConvertToString(value, format); | ||
Assert.Equal(expected, result); | ||
} | ||
|
||
[Theory] | ||
[InlineData(false, "false", "true", "false")] | ||
[InlineData(true, "true", "true", "false")] | ||
[InlineData(false, "0", "1", "0")] | ||
[InlineData(true, "1", "1", "0")] | ||
public static void TestToStringBooleanFormat(bool value, string expected, string trueVal, string falseVal) | ||
{ | ||
string result = Oberon0System.ConvertToString(value, trueVal, falseVal); | ||
Assert.Equal(expected, result); | ||
} | ||
} |
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.