Skip to content

Commit e95c3b3

Browse files
committed
Add BitfieldTypeDefTypeCastTestUnix to cover the typedef case
This case is when typeBacking is not the same as builtinTypeBacking
1 parent 266f93a commit e95c3b3

File tree

1 file changed

+38
-0
lines changed
  • tests/ClangSharp.PInvokeGenerator.UnitTests

1 file changed

+38
-0
lines changed

tests/ClangSharp.PInvokeGenerator.UnitTests/CTest.cs

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -714,6 +714,44 @@ readonly get
714714
return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard);
715715
}
716716

717+
[Test]
718+
[Platform("unix")]
719+
public Task BitfieldTypeDefTypeCastTestUnix()
720+
{
721+
var inputContents = @"
722+
typedef unsigned int Number;
723+
724+
typedef struct Bitfield {
725+
Number bits : 8;
726+
} Bitfield;
727+
";
728+
729+
var expectedOutputContents = @"namespace ClangSharp.Test
730+
{
731+
public partial struct Bitfield
732+
{
733+
public uint _bitfield;
734+
735+
[NativeTypeName(""Number : 8"")]
736+
public uint bits
737+
{
738+
readonly get
739+
{
740+
return _bitfield & 0xFFu;
741+
}
742+
743+
set
744+
{
745+
_bitfield = (_bitfield & ~0xFFu) | (value & 0xFFu);
746+
}
747+
}
748+
}
749+
}
750+
";
751+
752+
return ValidateGeneratedCSharpLatestUnixBindingsAsync(inputContents, expectedOutputContents, commandLineArgs: DefaultCClangCommandLineArgs, language: "c", languageStandard: DefaultCStandard);
753+
}
754+
717755
[Test]
718756
[Platform("win")] // This test has slight platform-specific differences
719757
public Task BitfieldEnumPropertyTypeCastTestWindows()

0 commit comments

Comments
 (0)