diff --git a/gen/schemas/hoc.json b/gen/schemas/hoc.json index 96afec8..7645cc0 100644 --- a/gen/schemas/hoc.json +++ b/gen/schemas/hoc.json @@ -178,7 +178,7 @@ "l", "kg", "kWh", - "mJ" + "MJ" ] }, "Feedstock": { diff --git a/gen/schemas/toc.json b/gen/schemas/toc.json index 6e54090..78cc4a3 100644 --- a/gen/schemas/toc.json +++ b/gen/schemas/toc.json @@ -189,7 +189,7 @@ "l", "kg", "kWh", - "mJ" + "MJ" ] }, "Feedstock": { diff --git a/gen/src/lib.rs b/gen/src/lib.rs index e458bb5..36d3de1 100644 --- a/gen/src/lib.rs +++ b/gen/src/lib.rs @@ -355,6 +355,7 @@ pub enum EnergyConsumptionUnit { L, Kg, KWh, + #[serde(rename = "MJ")] MJ, } diff --git a/gen/tests/tests.rs b/gen/tests/tests.rs index c2eadd6..1487a7b 100644 --- a/gen/tests/tests.rs +++ b/gen/tests/tests.rs @@ -127,3 +127,18 @@ fn test_ship_foot_deser() { let ship_foot: ShipmentFootprint = serde_json::from_str(json).unwrap(); assert_eq!(ship_foot, expected) } + +#[test] +fn test_energyconsumptionunit_deser() { + use EnergyConsumptionUnit::*; + let test_vectors = vec![ + ("\"l\"", L), + ("\"kg\"", Kg), + ("\"kWh\"", KWh), + ("\"MJ\"", MJ), + ]; + + for (expect, input) in &test_vectors { + assert_eq!(expect, &serde_json::to_string(input).unwrap()); + } +}