add C pointer type to @typeInfo

See #1059
This commit is contained in:
Andrew Kelley
2019-02-11 16:07:40 -05:00
parent 342bca7f46
commit 90b8cd4a45
7 changed files with 41 additions and 6 deletions
+15
View File
@@ -61,6 +61,21 @@ fn testUnknownLenPtr() void {
expect(u32_ptr_info.Pointer.child == f64);
}
test "type info: C pointer type info" {
testCPtr();
comptime testCPtr();
}
fn testCPtr() void {
const ptr_info = @typeInfo([*c]align(4) const i8);
expect(TypeId(ptr_info) == TypeId.Pointer);
expect(ptr_info.Pointer.size == TypeInfo.Pointer.Size.C);
expect(ptr_info.Pointer.is_const);
expect(!ptr_info.Pointer.is_volatile);
expect(ptr_info.Pointer.alignment == 4);
expect(ptr_info.Pointer.child == i8);
}
test "type info: slice type info" {
testSlice();
comptime testSlice();