1 module dunitconversion.tests.conversionfamily;
2 
3 import dunitconversion.conversionfamily;
4 import dunitconversion.conversionrule;
5 import dunitconversion.linearfunction;
6 
7 import std.exception;
8 
9 unittest {
10     auto family = new ConversionFamily;
11     family.addConversionRule(ConversionRule("length", "m", "km", LinearFunction(0.001, 0)));
12     auto f = family.convert("m", "km");
13     assert(f.k == 0.001);
14     assert(f.b == 0);
15     
16     f = family.convert("km", "m");
17     assert(f.k == 1000);
18     assert(f.b == 0);
19 
20     assertThrown!Exception(family.convert("km", "ft"));
21 }