From 422b0769bab929f5e4965de9ef963241e2234ffc Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Thu, 12 Sep 2013 19:58:02 +0300 Subject: [PATCH] Added a new test project for Unicode strings. Signed-off-by: Dimitar Dobrev --- tests/Basic/Basic.Tests.cs | 2 +- tests/Basic/Basic.h | 2 -- tests/UTF16/UTF16.Tests.cs | 15 +++++++++++++++ tests/UTF16/UTF16.cpp | 1 + tests/UTF16/UTF16.cs | 33 +++++++++++++++++++++++++++++++++ tests/UTF16/UTF16.h | 13 +++++++++++++ tests/UTF16/premake4.lua | 2 ++ 7 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 tests/UTF16/UTF16.Tests.cs create mode 100644 tests/UTF16/UTF16.cpp create mode 100644 tests/UTF16/UTF16.cs create mode 100644 tests/UTF16/UTF16.h create mode 100644 tests/UTF16/premake4.lua diff --git a/tests/Basic/Basic.Tests.cs b/tests/Basic/Basic.Tests.cs index 84c4c17f..60510542 100644 --- a/tests/Basic/Basic.Tests.cs +++ b/tests/Basic/Basic.Tests.cs @@ -105,7 +105,7 @@ public class BasicTests } [Test] - public void TestUnicode() + public void TestANSI() { Foo foo = new Foo(); Assert.That(foo.GetANSI(), Is.EqualTo("ANSI")); diff --git a/tests/Basic/Basic.h b/tests/Basic/Basic.h index 45d4f739..b63b74cd 100644 --- a/tests/Basic/Basic.h +++ b/tests/Basic/Basic.h @@ -12,8 +12,6 @@ public: int A; float B; - const char* Unicode; - const char* GetANSI(); }; diff --git a/tests/UTF16/UTF16.Tests.cs b/tests/UTF16/UTF16.Tests.cs new file mode 100644 index 00000000..0a4599b6 --- /dev/null +++ b/tests/UTF16/UTF16.Tests.cs @@ -0,0 +1,15 @@ +using NUnit.Framework; +using UTF16; + +[TestFixture] +public class UTF16Tests +{ + [Test] + public void TestFoo() + { + var foo = new Foo(); + const string georgia = "საქართველო"; + foo.Unicode = georgia; + Assert.That(foo.Unicode, Is.EqualTo(georgia)); + } +} diff --git a/tests/UTF16/UTF16.cpp b/tests/UTF16/UTF16.cpp new file mode 100644 index 00000000..566968cf --- /dev/null +++ b/tests/UTF16/UTF16.cpp @@ -0,0 +1 @@ +#include "UTF16.h" \ No newline at end of file diff --git a/tests/UTF16/UTF16.cs b/tests/UTF16/UTF16.cs new file mode 100644 index 00000000..9884d488 --- /dev/null +++ b/tests/UTF16/UTF16.cs @@ -0,0 +1,33 @@ +using System.Text; +using CppSharp.AST; +using CppSharp.Generators; +using CppSharp.Utils; + +namespace CppSharp.Tests +{ + public class UTF16Tests : LibraryTest + { + public UTF16Tests(LanguageGeneratorKind kind) + : base("UTF16", kind) + { + } + + public override void SetupPasses(Driver driver) + { + driver.Options.Encoding = Encoding.Unicode; + } + + public override void Preprocess(Driver driver, Library lib) + { + + } + + static class Program + { + public static void Main(string[] args) + { + ConsoleDriver.Run(new UTF16Tests(LanguageGeneratorKind.CSharp)); + } + } + } +} diff --git a/tests/UTF16/UTF16.h b/tests/UTF16/UTF16.h new file mode 100644 index 00000000..13da5e79 --- /dev/null +++ b/tests/UTF16/UTF16.h @@ -0,0 +1,13 @@ +#if defined(_MSC_VER) +#define DLL_API __declspec(dllexport) +#else +#define DLL_API +#endif + +class DLL_API Foo +{ +public: + const char* Unicode; +}; + +DLL_API int FooCallFoo(Foo* foo); diff --git a/tests/UTF16/premake4.lua b/tests/UTF16/premake4.lua new file mode 100644 index 00000000..d7f9c89d --- /dev/null +++ b/tests/UTF16/premake4.lua @@ -0,0 +1,2 @@ +group "Tests/UTF16" + SetupTestCSharp("UTF16") \ No newline at end of file