Skip to content

Commit 1d0a081

Browse files
uefi-macros: Refactor GUID tests
Switch the tests from using `unsafe_guid!` to `guid!`. Both use the same internal code, so we're testing more or less the same thing, but `guid!` is a little more direct. Also, as we previously did with the entry macro, split the GUID tests into multiple files to make it easier to visually inspect the error output. The "good" test case has been removed since that's already covered in plenty of places elsewhere.
1 parent 2af0775 commit 1d0a081

File tree

8 files changed

+36
-36
lines changed

8 files changed

+36
-36
lines changed

uefi-macros/tests/ui/guid.rs

Lines changed: 0 additions & 19 deletions
This file was deleted.

uefi-macros/tests/ui/guid.stderr

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use uefi::Guid;
2+
use uefi_macros::guid;
3+
4+
// Error span should point to the second group.
5+
const BadHexGroup2: Guid = guid!("aaaaaaaa-Gaaa-aaaa-aaaa-aaaaaaaaaaaa");
6+
7+
fn main() {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
error: GUID component "Gaaa" is not a hexadecimal number
2+
--> tests/ui/guid_bad_hex_group2.rs:5:44
3+
|
4+
5 | const BadHexGroup2: Guid = guid!("aaaaaaaa-Gaaa-aaaa-aaaa-aaaaaaaaaaaa");
5+
| ^^^^
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use uefi::Guid;
2+
use uefi_macros::guid;
3+
4+
// Error span should point to the fifth group.
5+
const BadHexGroup5: Guid = guid!("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaG");
6+
7+
fn main() {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
error: GUID component "aaaaaaaaaaaG" is not a hexadecimal number
2+
--> tests/ui/guid_bad_hex_group5.rs:5:59
3+
|
4+
5 | const BadHexGroup5: Guid = guid!("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaG");
5+
| ^^^^^^^^^^^^
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
use uefi::Guid;
2+
use uefi_macros::guid;
3+
4+
// Fail because the length is wrong.
5+
const TooShort: Guid = guid!("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa");
6+
7+
fn main() {}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
error: "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa" is not a canonical GUID string (expected 36 bytes, found 35)
2+
--> tests/ui/guid_bad_length.rs:5:30
3+
|
4+
5 | const TooShort: Guid = guid!("aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaa");
5+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)