Permalink
Browse files

[WIP] Translate upstream libclang unit tests

  • Loading branch information...
benpye committed Apr 13, 2018
1 parent e9f2e4b commit 37a46f3e0085b03ea179fefe8f869571cdea6d46
Showing with 436 additions and 0 deletions.
  1. +20 −0 ClangSharp.Test/ClangSharp.Test.csproj
  2. +34 −0 ClangSharp.Test/ModuleMapDescriptor.cs
  3. +366 −0 ClangSharp.Test/VirtualFileOverlay.cs
  4. +14 −0 ClangSharp.sln
  5. +2 −0 build.sh
@@ -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>
@@ -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);
}
}
}
Oops, something went wrong.

0 comments on commit 37a46f3

Please sign in to comment.