Skip to content

Commit

Permalink
[WIP] Translate upstream libclang unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
benpye committed Apr 15, 2018
1 parent e9f2e4b commit 37a46f3
Show file tree
Hide file tree
Showing 5 changed files with 436 additions and 0 deletions.
20 changes: 20 additions & 0 deletions ClangSharp.Test/ClangSharp.Test.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp2.0</TargetFramework>

<IsPackable>false</IsPackable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.6.0" />
<PackageReference Include="xunit" Version="2.3.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.3.1" />
<DotNetCliToolReference Include="dotnet-xunit" Version="2.3.1" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\ClangSharp\ClangSharp.csproj" />
</ItemGroup>

</Project>
34 changes: 34 additions & 0 deletions ClangSharp.Test/ModuleMapDescriptor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using System;
using System.Runtime.InteropServices;
using Xunit;

namespace ClangSharp.Test
{
public class ModuleMapDescriptor
{
[Fact]
public void Basic()
{
var contents =
"framework module TestFrame {\n"
+ " umbrella header \"TestFrame.h\"\n"
+ "\n"
+ " export *\n"
+ " module * { export * }\n"
+ "}\n";

CXModuleMapDescriptor mmd = clang.ModuleMapDescriptor_create(0);

clang.ModuleMapDescriptor_setFrameworkModuleName(mmd, "TestFrame");
clang.ModuleMapDescriptor_setUmbrellaHeader(mmd, "TestFrame.h");

IntPtr bufPtr;
uint bufSize = 0;
clang.ModuleMapDescriptor_writeToBuffer(mmd, 0, out bufPtr, out bufSize);
var bufStr = Marshal.PtrToStringAnsi(bufPtr, (int)bufSize);
Assert.Equal(contents, bufStr);
clang.free(bufPtr);
clang.ModuleMapDescriptor_dispose(mmd);
}
}
}
Loading

0 comments on commit 37a46f3

Please sign in to comment.