-
-
Notifications
You must be signed in to change notification settings - Fork 723
/
FloatTypeTests.cs
87 lines (68 loc) · 2.3 KB
/
FloatTypeTests.cs
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
using System;
using HotChocolate.Language;
using Xunit;
namespace HotChocolate.Types
{
public class FloatTypeTests
: NumberTypeTests<double, FloatType, FloatValueNode>
{
protected override FloatValueNode GetValueNode =>
new FloatValueNode("1.000000E+000");
protected override IValueNode GetWrongValueNode =>
new StringValueNode("1");
protected override double GetValue => 1.0d;
protected override object GetWrongValue => 1.0m;
protected override double GetAssertValue => 1.0d;
protected override double GetMaxValue => double.MaxValue;
protected override string GetAssertMaxValue => "1.797693E+308";
protected override double GetMinValue => double.MinValue;
protected override string GetAssertMinValue => "-1.797693E+308";
[Fact]
public void ParseValue_Float_Max()
{
// arrange
FloatType type = new FloatType();
float input = float.MaxValue;
// act
FloatValueNode literal =
(FloatValueNode)type.ParseValue(input);
// assert
Assert.Equal("3.402823E+038", literal.Value);
}
[Fact]
public void ParseValue_Float_Min()
{
// arrange
FloatType type = new FloatType();
float input = float.MinValue;
// act
FloatValueNode literal =
(FloatValueNode)type.ParseValue(input);
// assert
Assert.Equal("-3.402823E+038", literal.Value);
}
[Fact]
public void IsInstanceOfType_IntValueNode()
{
// arrange
FloatType type = new FloatType();
IntValueNode input = new IntValueNode("123");
// act
bool result = type.IsInstanceOfType(input);
// assert
Assert.True(result);
}
[Fact]
public void ParseLiteral_IntValueNode()
{
// arrange
FloatType type = new FloatType();
IntValueNode input = new IntValueNode("123");
// act
object result = type.ParseLiteral(input);
// assert
Assert.IsType<double>(result);
Assert.Equal(123d, result);
}
}
}