diff options
| author | Daniele Cocca <daniele.cocca@gmail.com> | 2021-04-28 01:00:32 +0100 |
|---|---|---|
| committer | Daniele Cocca <dcocca@google.com> | 2021-06-16 22:02:52 +0100 |
| commit | 171102ea7ca3a11113d2ccfb7206b0eaddab19ac (patch) | |
| tree | e86fc48c104325a4ba2df95a7fb900872278e254 /test/behavior/bugs | |
| parent | 00e1c0082c7c3cee377cc4e31b205c26f8943419 (diff) | |
| download | zig-171102ea7ca3a11113d2ccfb7206b0eaddab19ac.tar.gz zig-171102ea7ca3a11113d2ccfb7206b0eaddab19ac.zip | |
errorName: return a null-terminated slice
Diffstat (limited to 'test/behavior/bugs')
| -rw-r--r-- | test/behavior/bugs/3779.zig | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/test/behavior/bugs/3779.zig b/test/behavior/bugs/3779.zig index 8866b39de3..5423a6f265 100644 --- a/test/behavior/bugs/3779.zig +++ b/test/behavior/bugs/3779.zig @@ -9,3 +9,13 @@ test "@tagName() returns a string literal" { try std.testing.expectEqualStrings("TestEnumValue", tag_name); try std.testing.expectEqualStrings("TestEnumValue", ptr_tag_name[0..tag_name.len]); } + +const TestError = error{TestErrorCode}; +const error_name = @errorName(TestError.TestErrorCode); +const ptr_error_name: [*:0]const u8 = error_name; + +test "@errorName() returns a string literal" { + try std.testing.expectEqual([:0]const u8, @TypeOf(error_name)); + try std.testing.expectEqualStrings("TestErrorCode", error_name); + try std.testing.expectEqualStrings("TestErrorCode", ptr_error_name[0..error_name.len]); +} |
