Browse Source

Added tests for C++ STL vectors.

pull/131/head
triton 12 years ago
parent
commit
a766ba7255
  1. 6
      build/Tests.lua
  2. 20
      tests/STL/STL.Tests.cs
  3. 20
      tests/STL/STL.cpp
  4. 23
      tests/STL/STL.cs
  5. 15
      tests/STL/STL.h
  6. 2
      tests/STL/premake4.lua

6
build/Tests.lua

@ -28,6 +28,12 @@ function SetupTestCSharp(name) @@ -28,6 +28,12 @@ function SetupTestCSharp(name)
SetupTestProjectsCSharp(name)
end
function SetupTestCLI(name)
SetupTestGeneratorProject(name)
SetupTestNativeProject(name)
SetupTestProjectsCLI(name)
end
function SetupManagedTestProject()
kind "SharedLib"
language "C#"

20
tests/STL/STL.Tests.cs

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
using System.Collections.Generic;
using System.Linq;
using NUnit.Framework;
[TestFixture]
public class STLTests
{
[Test]
public void TestVectors()
{
var vectors = new STL.TestVectors();
var sum = vectors.SumIntVector(new List<int> { 1, 2, 3 });
Assert.AreEqual(sum, 6);
var list = vectors.GetIntVector();
Assert.True(list.SequenceEqual(new List<int> { 2, 3, 4 }));
}
}

20
tests/STL/STL.cpp

@ -0,0 +1,20 @@ @@ -0,0 +1,20 @@
#include "STL.h"
std::vector<int> TestVectors::GetIntVector()
{
std::vector<int> vec;
vec.push_back(2);
vec.push_back(3);
vec.push_back(4);
return vec;
}
int TestVectors::SumIntVector(std::vector<int>& vec)
{
int sum = 0;
for (unsigned I = 0, E = vec.size(); I != E; ++I)
sum += vec[I];
return sum;
}

23
tests/STL/STL.cs

@ -0,0 +1,23 @@ @@ -0,0 +1,23 @@
using CppSharp.AST;
using CppSharp.Generators;
using CppSharp.Utils;
namespace CppSharp.Tests
{
public class STL : LibraryTest
{
public STL(GeneratorKind kind)
: base("STL", kind)
{
}
public override void Preprocess(Driver driver, ASTContext lib)
{
}
public static void Main(string[] args)
{
ConsoleDriver.Run(new STL(GeneratorKind.CLI));
}
}
}

15
tests/STL/STL.h

@ -0,0 +1,15 @@ @@ -0,0 +1,15 @@
#if defined(_MSC_VER)
#define DLL_API __declspec(dllexport)
#else
#define DLL_API
#endif
#include <vector>
struct DLL_API TestVectors
{
std::vector<int> GetIntVector();
int SumIntVector(std::vector<int>& vec);
std::vector<int> IntVector;
};

2
tests/STL/premake4.lua

@ -0,0 +1,2 @@ @@ -0,0 +1,2 @@
group "Tests/STL"
SetupTestCLI("STL")
Loading…
Cancel
Save