1 module dunitconversion.tests.tools;
2 
3 import dunitconversion.linearfunction;
4 import dunitconversion.tools;
5 
6 import std.math;
7 
8 /// Combined function test with testing conversion from
9 /// celsius to farenheights through kelvins
10 unittest {
11     auto cToK = LinearFunction(1, 273.15);
12     auto KToF = LinearFunction(1.8, -459.67);
13     auto combined = combined(cToK, KToF);
14 
15     assert(approxEqual(combined.y(-273.15), -459.67));
16     assert(approxEqual(combined.y(-45.56), -50.008));
17     assert(approxEqual(combined.y(-40), -40));
18     assert(approxEqual(combined.y(-34.44), -29.992));
19     assert(approxEqual(combined.y(-28.89), -20.002));
20     assert(approxEqual(combined.y(-23.33), -9.994));
21     assert(approxEqual(combined.y(-12.22), 10.004));
22     assert(approxEqual(combined.y(-6.67), 19.994));
23     assert(approxEqual(combined.y(-1.11), 30.002));
24     assert(approxEqual(combined.y(0), 32));
25     assert(approxEqual(combined.y(4.44), 39.992));
26     assert(approxEqual(combined.y(10), 50));
27     assert(approxEqual(combined.y(60), 140));
28     assert(approxEqual(combined.y(65.56), 150.008));
29     assert(approxEqual(combined.y(100), 212));
30     assert(approxEqual(combined.y(260), 500));
31     assert(approxEqual(combined.y(537.78), 1000.004));
32 }