Skip to content

Commit

Permalink
Merge pull request #40 from vnagarnaik/main
Browse files Browse the repository at this point in the history
Fix CIMTYPE `CHAR16` support
  • Loading branch information
ohadravid authored Oct 10, 2021
2 parents 90ca1f7 + e5cac20 commit 47e69f9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/variant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ macro_rules! cast_num {
Ok(Variant::R4($var as f32))
} else if $cim_type == wbemcli::CIM_REAL64 {
Ok(Variant::R8($var as f64))
} else if $cim_type == wbemcli::CIM_CHAR16 {
Ok(Variant::String(String::from_utf16(&[$var as u16])?))
} else {
Err(WMIError::ConvertVariantError(format!(
"Value {:?} cannot be turned into a CIMTYPE {}",
Expand Down Expand Up @@ -438,6 +440,14 @@ mod tests {
assert_eq!(converted, Variant::R8(1.0));
}

#[test]
fn it_convert_into_cim_char16() {
let cim_type = wbemcli::CIM_CHAR16;
let variant = Variant::UI2(67);
let converted = variant.convert_into_cim_type(cim_type).unwrap();
assert_eq!(converted, Variant::String("C".to_string()));
}

#[test]
fn it_convert_into_cim_type_datetime() {
let cim_type = wbemcli::CIM_DATETIME;
Expand Down

0 comments on commit 47e69f9

Please sign in to comment.