Skip to content

Commit 4180a46

Browse files
committed
Add unit tests
1 parent e8fbeed commit 4180a46

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

meson.build

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ project(
1010
)
1111

1212
fs = import('fs')
13+
rust = import('rust')
1314

1415
rustc = meson.get_compiler('rust')
1516
if rustc.version().version_compare('<1.69')
@@ -106,3 +107,5 @@ executable(
106107
],
107108
install: true
108109
)
110+
111+
rust.test('unit tests', lib_refivar)

src/lib/efivar/types/efi_guid.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,3 +214,24 @@ impl TryFrom<&str> for EfiGuid {
214214
return value.parse::<Self>();
215215
}
216216
}
217+
218+
#[cfg(test)]
219+
mod tests {
220+
use super::*;
221+
222+
#[test]
223+
fn from_str() {
224+
assert_eq!(
225+
EfiGuid {
226+
a: 0x78563412,
227+
b: 0xbc9a,
228+
c: 0xf0de,
229+
d: [0x01u8, 0x23u8, 0x45u8, 0x67u8, 0x89u8, 0xabu8, 0xcdu8, 0xefu8]
230+
},
231+
EfiGuid::from(&[
232+
0x12u8, 0x34u8, 0x56u8, 0x78u8, 0x9au8, 0xbcu8, 0xdeu8, 0xf0u8, 0x01u8, 0x23u8,
233+
0x45u8, 0x67u8, 0x89u8, 0xabu8, 0xcdu8, 0xefu8
234+
])
235+
)
236+
}
237+
}

0 commit comments

Comments
 (0)