-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathLinksConstantsTests.cs
More file actions
62 lines (58 loc) · 2.17 KB
/
LinksConstantsTests.cs
File metadata and controls
62 lines (58 loc) · 2.17 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System.Numerics;
using Xunit;
using Platform.Reflection;
using Platform.Converters;
using Platform.Numbers;
namespace Platform.Data.Tests
{
/// <summary>
/// <para>
/// Represents the links constants tests.
/// </para>
/// <para></para>
/// </summary>
public static class LinksConstantsTests
{
/// <summary>
/// <para>
/// Tests that constructor test.
/// </para>
/// <para></para>
/// </summary>
[Fact]
public static void ConstructorTest()
{
var constants = new LinksConstants<ulong>(enableExternalReferencesSupport: true);
Assert.Equal((ulong)0, constants.ExternalReferencesRange.Value.Minimum);
Assert.Equal(ulong.MaxValue, constants.ExternalReferencesRange.Value.Maximum);
}
/// <summary>
/// <para>
/// Tests that external references test.
/// </para>
/// <para></para>
/// </summary>
[Fact]
public static void ExternalReferencesTest()
{
TestExternalReferences<ulong, long>();
TestExternalReferences<uint, int>();
TestExternalReferences<ushort, short>();
TestExternalReferences<byte, sbyte>();
}
private static void TestExternalReferences<TUnsigned, TSigned>() where TUnsigned : IUnsignedNumber<TUnsigned> where TSigned : ISignedNumber<TSigned>
{
var unsingedOne = TUnsigned.One;
var half = TUnsigned.CreateTruncating((NumericType<TSigned>.MaxValue));
LinksConstants<TUnsigned> constants = new LinksConstants<TUnsigned>((unsingedOne, half), (half+unsingedOne, NumericType<TUnsigned>.MaxValue));
var minimum = new Hybrid<TUnsigned>(default, isExternal: true);
var maximum = new Hybrid<TUnsigned>(half, isExternal: true);
Assert.True(constants.IsExternalReference(minimum));
Assert.True(minimum.IsExternal);
Assert.False(minimum.IsInternal);
Assert.True(constants.IsExternalReference(maximum));
Assert.True(maximum.IsExternal);
Assert.False(maximum.IsInternal);
}
}
}