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

8 files changed

+36
-36
lines changed

Diff for: uefi-macros/tests/ui/guid.rs

-19
This file was deleted.

Diff for: uefi-macros/tests/ui/guid.stderr

-17
This file was deleted.

Diff for: uefi-macros/tests/ui/guid_bad_hex_group2.rs

+7
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() {}

Diff for: uefi-macros/tests/ui/guid_bad_hex_group2.stderr

+5
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+
| ^^^^

Diff for: uefi-macros/tests/ui/guid_bad_hex_group5.rs

+7
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() {}

Diff for: uefi-macros/tests/ui/guid_bad_hex_group5.stderr

+5
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+
| ^^^^^^^^^^^^

Diff for: uefi-macros/tests/ui/guid_bad_length.rs

+7
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() {}

Diff for: uefi-macros/tests/ui/guid_bad_length.stderr

+5
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)