Skip to content

Commit

Permalink
fix: EnergyConsumptionUnit JSON serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
zeitgeist committed Sep 17, 2024
1 parent f6a2327 commit b1eccb7
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
2 changes: 1 addition & 1 deletion gen/schemas/hoc.json
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
"l",
"kg",
"kWh",
"mJ"
"MJ"
]
},
"Feedstock": {
Expand Down
2 changes: 1 addition & 1 deletion gen/schemas/toc.json
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@
"l",
"kg",
"kWh",
"mJ"
"MJ"
]
},
"Feedstock": {
Expand Down
16 changes: 16 additions & 0 deletions gen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,7 @@ pub enum EnergyConsumptionUnit {
L,
Kg,
KWh,
#[serde(rename = "MJ")]
MJ,
}

Expand Down Expand Up @@ -802,4 +803,19 @@ mod tests {

println!("{footprints:#?}");
}

#[test]
fn test_deser_energyconsumptionunit() {
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());
}
}
}

0 comments on commit b1eccb7

Please sign in to comment.