1 module contract.enums; 2 3 4 import contract; 5 6 7 @("legacy") 8 @safe unittest { 9 10 import clang.c.index; 11 12 const tu = parse( 13 Cpp( 14 q{ 15 enum Enum { 16 foo, 17 bar, 18 baz, 19 }; 20 } 21 ) 22 ); 23 24 tu.children.length.should == 1; 25 const enum_ = tu.children[0]; 26 enum_.shouldMatch(Cursor.Kind.EnumDecl, "Enum"); 27 printChildren(enum_); 28 enum_.children.length.should == 3; 29 30 version(Windows) 31 Type(clang_getEnumDeclIntegerType(enum_.cx)).shouldMatch(Type.Kind.Int, "int"); 32 else 33 Type(clang_getEnumDeclIntegerType(enum_.cx)).shouldMatch(Type.Kind.UInt, "unsigned int"); 34 } 35 36 37 @("class.type") 38 @safe unittest { 39 40 import clang.c.index; 41 42 const tu = parse( 43 Cpp( 44 q{ 45 enum class Enum: unsigned char { 46 foo, 47 bar, 48 baz, 49 }; 50 } 51 ) 52 ); 53 54 tu.children.length.should == 1; 55 const enum_ = tu.children[0]; 56 enum_.shouldMatch(Cursor.Kind.EnumDecl, "Enum"); 57 printChildren(enum_); 58 enum_.children.length.should == 3; 59 60 Type(clang_getEnumDeclIntegerType(enum_.cx)).shouldMatch(Type.Kind.UChar, "unsigned char"); 61 }