Skip to content

Commit

Permalink
CastStructTest
Browse files Browse the repository at this point in the history
  • Loading branch information
Andreas-Dorfer committed Nov 21, 2022
1 parent b68b494 commit aa49f07
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/AD.BaseTypes.Tests/CastTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,29 @@ public class CastTest
public void None(NonEmptyString str) =>
Assert.AreNotEqual(str.Item, BaseType<NoneString, string>.Create(str.Item));
}


[Int] public partial record struct DefaultIntStruct;
[Int, BaseType(Cast.Explicit)] public readonly partial record struct ExplicitIntStruct;
[Int, BaseType(Cast.Implicit)] public readonly partial record struct ImplicitIntStruct;
[Int, BaseType(Cast.None)] public readonly partial record struct NoneIntStruct;

[TestClass]
public class CastStructTest
{
[Property]
public void Default_is_explicit(int x) =>
Assert.AreEqual(x, (int)BaseType<DefaultIntStruct, int>.Create(x));

[Property]
public void Explicit(int x) =>
Assert.AreEqual(x, (int)BaseType<ExplicitIntStruct, int>.Create(x));

[Property]
public void Implicit(int x) =>
Assert.AreEqual(x, BaseType<ImplicitIntStruct, int>.Create(x));

[Property]
public void None(int x) =>
Assert.AreNotEqual(x, BaseType<NoneIntStruct, int>.Create(x));
}

0 comments on commit aa49f07

Please sign in to comment.