Skip to content

Commit 947f8d1

Browse files
committed
MathTests.cs: Fix tests for overflow on Oracle by rounding in the Linq expressions.
(cherry picked from commit fe175e0)
1 parent 998d09e commit 947f8d1

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/NHibernate.Test/Linq/MathTests.cs

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ private void IgnoreIfNotSupported(string function)
2020
protected override void OnSetUp()
2121
{
2222
base.OnSetUp();
23-
_orderLines = db.OrderLines.Take(10).ToList().AsQueryable();
23+
_orderLines = db.OrderLines
24+
.OrderBy(ol => ol.Id)
25+
.Take(10).ToList().AsQueryable();
2426
}
2527

2628
[Test]
@@ -47,70 +49,70 @@ public void SignAllNegativeTest()
4749
public void SinTest()
4850
{
4951
IgnoreIfNotSupported("sin");
50-
Test(o => Math.Sin((double) o.UnitPrice));
52+
Test(o => Math.Round(Math.Sin((double) o.UnitPrice), 5));
5153
}
5254

5355
[Test]
5456
public void CosTest()
5557
{
5658
IgnoreIfNotSupported("cos");
57-
Test(o => Math.Cos((double) o.UnitPrice));
59+
Test(o => Math.Round(Math.Cos((double)o.UnitPrice), 5));
5860
}
5961

6062
[Test]
6163
public void TanTest()
6264
{
6365
IgnoreIfNotSupported("tan");
64-
Test(o => Math.Tan((double) o.Discount));
66+
Test(o => Math.Round(Math.Tan((double)o.Discount), 5));
6567
}
6668

6769
[Test]
6870
public void SinhTest()
6971
{
7072
IgnoreIfNotSupported("sinh");
71-
Test(o => Math.Sinh((double) o.Discount));
73+
Test(o => Math.Round(Math.Sinh((double)o.Discount), 5));
7274
}
7375

7476
[Test]
7577
public void CoshTest()
7678
{
7779
IgnoreIfNotSupported("cosh");
78-
Test(o => Math.Cosh((double) o.Discount));
80+
Test(o => Math.Round(Math.Cosh((double)o.Discount), 5));
7981
}
8082

8183
[Test]
8284
public void TanhTest()
8385
{
8486
IgnoreIfNotSupported("tanh");
85-
Test(o => Math.Tanh((double) o.Discount));
87+
Test(o => Math.Round(Math.Tanh((double)o.Discount), 5));
8688
}
8789

8890
[Test]
8991
public void AsinTest()
9092
{
9193
IgnoreIfNotSupported("asin");
92-
Test(o => Math.Asin((double) o.Discount));
94+
Test(o => Math.Round(Math.Asin((double)o.Discount), 5));
9395
}
9496

9597
[Test]
9698
public void AcosTest()
9799
{
98100
IgnoreIfNotSupported("acos");
99-
Test(o => Math.Acos((double) o.Discount));
101+
Test(o => Math.Round(Math.Acos((double)o.Discount), 5));
100102
}
101103

102104
[Test]
103105
public void AtanTest()
104106
{
105107
IgnoreIfNotSupported("atan");
106-
Test(o => Math.Atan((double) o.UnitPrice));
108+
Test(o => Math.Round(Math.Atan((double)o.UnitPrice), 5));
107109
}
108110

109111
[Test]
110112
public void Atan2Test()
111113
{
112114
IgnoreIfNotSupported("atan2");
113-
Test(o => Math.Atan2((double) o.Discount, 0.5d));
115+
Test(o => Math.Round(Math.Atan2((double)o.Discount, 0.5d), 5));
114116
}
115117

116118
private void Test(Expression<Func<OrderLine, double>> selector)
@@ -119,7 +121,9 @@ private void Test(Expression<Func<OrderLine, double>> selector)
119121
.Select(selector)
120122
.ToList();
121123

122-
var actual = db.OrderLines.Select(selector)
124+
var actual = db.OrderLines
125+
.OrderBy(ol => ol.Id)
126+
.Select(selector)
123127
.Take(10)
124128
.ToList();
125129

0 commit comments

Comments
 (0)