Browse Source

Sped the test run up by moving the test for ignored system types.

Signed-off-by: Dimitar Dobrev <dpldobrev@protonmail.com>
pull/987/head
Dimitar Dobrev 8 years ago
parent
commit
8958217314
  1. 31
      src/Generator.Tests/AST/TestAST.cs
  2. 3
      src/Generator.Tests/ASTTestFixture.cs
  3. 26
      src/Generator.Tests/Passes/TestPasses.cs
  4. 2
      tests/Native/AST.h
  5. 2
      tests/Native/Passes.h

31
src/Generator.Tests/AST/TestAST.cs

@ -303,13 +303,13 @@ namespace CppSharp.Generator.Tests.AST @@ -303,13 +303,13 @@ namespace CppSharp.Generator.Tests.AST
[Test]
public void TestLineNumber()
{
Assert.AreEqual(70, AstContext.FindClass("HiddenInNamespace").First().LineNumberStart);
Assert.AreEqual(72, AstContext.FindClass("HiddenInNamespace").First().LineNumberStart);
}
[Test]
public void TestLineNumberOfFriend()
{
Assert.AreEqual(93, AstContext.FindFunction("operator+").First().LineNumberStart);
Assert.AreEqual(95, AstContext.FindFunction("operator+").First().LineNumberStart);
}
static string StripWindowsNewLines(string text)
@ -350,7 +350,7 @@ namespace CppSharp.Generator.Tests.AST @@ -350,7 +350,7 @@ namespace CppSharp.Generator.Tests.AST
[Test]
public void TestMacroLineNumber()
{
Assert.AreEqual(103, AstContext.FindClass("HasAmbiguousFunctions").First().Specifiers.Last().LineNumberStart);
Assert.AreEqual(105, AstContext.FindClass("HasAmbiguousFunctions").First().Specifiers.Last().LineNumberStart);
}
[Test]
@ -576,5 +576,30 @@ namespace CppSharp.Generator.Tests.AST @@ -576,5 +576,30 @@ namespace CppSharp.Generator.Tests.AST
var @classC = AstContext.FindClass("ClassC").First();
Assert.That(@classC.Redeclarations.Count, Is.EqualTo(2));
}
[Test]
public void TestRemovalOfUnusedStdTypes()
{
new IgnoreSystemDeclarationsPass { Context = Driver.Context }.VisitASTContext(AstContext);
if (Platform.IsWindows)
{
Assert.That(AstContext.GetEnumWithMatchingItem("_ALLOC_MASK").Ignore, Is.True);
Assert.That(AstContext.FindClass("_Ctypevec").First().Ignore, Is.True);
return;
}
if (Platform.IsLinux)
{
Assert.That(AstContext.GetEnumWithMatchingItem("PTHREAD_RWLOCK_PREFER_READER_NP").Ignore, Is.True);
Assert.That(AstContext.FindClass("pthread_mutex_t").First().Ignore, Is.True);
return;
}
if (Platform.IsMacOS)
{
Assert.That(AstContext.GetEnumWithMatchingItem("__n_words").Ignore, Is.True);
Assert.That(AstContext.FindClass("__darwin_fp_control").First().Ignore, Is.True);
return;
}
}
}
}

3
src/Generator.Tests/ASTTestFixture.cs

@ -3,6 +3,7 @@ using CppSharp.AST; @@ -3,6 +3,7 @@ using CppSharp.AST;
using CppSharp.Utils;
using CppSharp.Parser;
using CppSharp.Passes;
using CppSharp.Generators;
namespace CppSharp.Generator.Tests
{
@ -15,7 +16,7 @@ namespace CppSharp.Generator.Tests @@ -15,7 +16,7 @@ namespace CppSharp.Generator.Tests
protected void ParseLibrary(params string[] files)
{
Options = new DriverOptions();
Options = new DriverOptions { GeneratorKind = GeneratorKind.CSharp };
ParserOptions = new ParserOptions();
var testsPath = GeneratorTest.GetTestsDirectory("Native");

26
src/Generator.Tests/Passes/TestPasses.cs

@ -231,31 +231,5 @@ namespace CppSharp.Generator.Tests.Passes @@ -231,31 +231,5 @@ namespace CppSharp.Generator.Tests.Passes
var @class = AstContext.FindDecl<Class>("ClassWithAbstractOperator").First();
Assert.AreEqual(@class.Operators.First().GenerationKind, GenerationKind.None);
}
[Test]
public void TestRemovalOfUnusedStdTypes()
{
passBuilder.AddPass(new IgnoreSystemDeclarationsPass());
passBuilder.RunPasses(pass => pass.VisitASTContext(AstContext));
if (Platform.IsWindows)
{
Assert.That(AstContext.GetEnumWithMatchingItem("_ALLOC_MASK").Ignore, Is.True);
Assert.That(AstContext.FindClass("_Ctypevec").First().Ignore, Is.True);
return;
}
if (Platform.IsLinux)
{
Assert.That(AstContext.GetEnumWithMatchingItem("PTHREAD_RWLOCK_PREFER_READER_NP").Ignore, Is.True);
Assert.That(AstContext.FindClass("pthread_mutex_t").First().Ignore, Is.True);
return;
}
if (Platform.IsMacOS)
{
Assert.That(AstContext.GetEnumWithMatchingItem("__n_words").Ignore, Is.True);
Assert.That(AstContext.FindClass("__darwin_fp_control").First().Ignore, Is.True);
return;
}
}
}
}

2
tests/Native/AST.h

@ -1,3 +1,5 @@ @@ -1,3 +1,5 @@
#include <string>
#define Q_SIGNALS protected
// Tests assignment of AST.Parameter properties

2
tests/Native/Passes.h

@ -1,5 +1,3 @@ @@ -1,5 +1,3 @@
#include <string>
enum FlagEnum
{
A = 1 << 0,

Loading…
Cancel
Save