@@ -40,6 +40,7 @@ class UnitTypeTests: XCTestCase {
4040 " temperature " : " fahrenheit " ,
4141 " precipitation_level " : " in " ,
4242 " water_rate " : " american_quart " ,
43+ " wind_speed " : " mile_per_hour " ,
4344 " fuel_consumption " : " mile_per_uk_gallon " ,
4445 " short_length " : " ft " ,
4546 " depth " : " in " ,
@@ -110,6 +111,10 @@ class UnitTypeTests: XCTestCase {
110111 XCTAssertEqual ( units. waterRate. to ( 369.89696315500004 ) , 865 )
111112 XCTAssertEqual ( units. waterRate. localization. short, " Cuarto/acre " )
112113
114+ XCTAssertEqual ( units. windSpeed. from ( 10 ) , 22.369362920544 )
115+ XCTAssertEqual ( units. windSpeed. to ( 5.6 ) , 2.5034240000000025 )
116+ XCTAssertEqual ( units. windSpeed. localization. short, " mph " )
117+
113118 XCTAssertEqual ( units. weight. from ( 8712 ) , 8712.0 )
114119 XCTAssertEqual ( units. weight. to ( 871.2 ) , 871.2 )
115120 XCTAssertEqual ( units. weight. localization. short, " t " )
@@ -187,6 +192,10 @@ class UnitTypeTests: XCTestCase {
187192 XCTAssertEqual ( units. waterRate. to ( 369.89696315500004 ) , 369.89696315500004 )
188193 XCTAssertEqual ( units. waterRate. localization. short, " л/га " )
189194
195+ XCTAssertEqual ( units. windSpeed. from ( 10 ) , 10 )
196+ XCTAssertEqual ( units. windSpeed. to ( 5.6 ) , 5.6 )
197+ XCTAssertEqual ( units. windSpeed. localization. short, " м/с " )
198+
190199 XCTAssertEqual ( units. weight. from ( 8712 ) , 87120.0 )
191200 XCTAssertEqual ( units. weight. to ( 871.2 ) , 87.12 )
192201 XCTAssertEqual ( units. weight. localization. short, " ц " )
@@ -245,6 +254,7 @@ class UnitTypeTests: XCTestCase {
245254 " temperature " : " fahrenheit " ,
246255 " precipitation_level " : " in " ,
247256 " water_rate " : " american_quart " ,
257+ " wind_speed " : " mile_per_hour " ,
248258 " fuel_consumption " : " mile_per_uk_gallon " ,
249259 " short_length " : " ft " ,
250260 " depth " : " in " ,
@@ -299,6 +309,7 @@ class UnitTypeTests: XCTestCase {
299309 " temperature " : " fahrenheit " ,
300310 " precipitation_level " : " in " ,
301311 " water_rate " : " american_quart " ,
312+ " wind_speed " : " mile_per_hour " ,
302313 " fuel_consumption " : " mile_per_uk_gallon " ,
303314 " short_length " : " ft " ,
304315 " depth " : " in " ,
@@ -314,12 +325,43 @@ class UnitTypeTests: XCTestCase {
314325 }
315326 }
316327
328+ func testWindSpeedMigration( ) {
329+ let table = [ // table with old wind speed unit
330+ " length " : " mile " ,
331+ " area " : " decare " ,
332+ " weight " : " tonn " ,
333+ " machinery_weight " : " pound " ,
334+ " volume " : " pint " ,
335+ " tank_volume " : " american_gallon " ,
336+ " productivity " : " kg_per_decare " ,
337+ " speed " : " mile_per_hour " ,
338+ " temperature " : " fahrenheit " ,
339+ " precipitation_level " : " in " ,
340+ " water_rate " : " american_quart " ,
341+ " fuel_consumption " : " mile_per_uk_gallon " ,
342+ " short_length " : " ft " ,
343+ " depth " : " in " ,
344+ " row_spacing " : " cm " ,
345+ " plant_spacing " : " m "
346+ ]
347+
348+ do {
349+ let units = try Units ( units: table, language: " uk " )
350+ XCTAssertEqual ( units. windSpeed. from ( 1 ) , 1 )
351+ XCTAssertEqual ( units. windSpeed. localization. short, " м/с " )
352+ } catch {
353+ XCTFail ( " error - \( error) " )
354+ }
355+ }
356+
317357 static var allTests = [
318358 ( " testFromError " , testFromError) ,
319359 ( " testUnits " , testUnits) ,
320360 ( " testDefaultUnits " , testDefaultUnits) ,
321361 ( " testDefaultUnitsError " , testDefaultUnitsError) ,
322362 ( " testUnitsError " , testUnitsError) ,
323- ( " testOptionalExtension " , testOptionalExtension)
363+ ( " testOptionalExtension " , testOptionalExtension) ,
364+ ( " testDekareUnits " , testDekareUnits) ,
365+ ( " testWindSpeedMigration " , testWindSpeedMigration)
324366 ]
325367}
0 commit comments