From d2189fa5a7a89557bb83a1c51097de89faf2e4b1 Mon Sep 17 00:00:00 2001 From: Dimitar Dobrev Date: Sun, 22 Feb 2015 23:52:49 +0200 Subject: [PATCH] Moved the improved test for friends to Basic because it's not C#-specific. Signed-off-by: Dimitar Dobrev --- tests/Basic/Basic.Tests.cs | 1 + tests/Basic/Basic.cpp | 5 +++++ tests/Basic/Basic.h | 1 + tests/CSharpTemp/CSharpTemp.Tests.cs | 10 ---------- tests/CSharpTemp/CSharpTemp.h | 24 ------------------------ 5 files changed, 7 insertions(+), 34 deletions(-) diff --git a/tests/Basic/Basic.Tests.cs b/tests/Basic/Basic.Tests.cs index 94566714..8a3b1186 100644 --- a/tests/Basic/Basic.Tests.cs +++ b/tests/Basic/Basic.Tests.cs @@ -474,6 +474,7 @@ public class BasicTests : GeneratorTestFixture HasFriend h1 = 5; HasFriend h2 = 10; Assert.AreEqual(15, (h1 + h2).M); + Assert.AreEqual(-5, (h1 - h2).M); } [Test] diff --git a/tests/Basic/Basic.cpp b/tests/Basic/Basic.cpp index 8be51b31..4e2e8e12 100644 --- a/tests/Basic/Basic.cpp +++ b/tests/Basic/Basic.cpp @@ -358,6 +358,11 @@ DLL_API inline const HasFriend operator+(const HasFriend& f1, const HasFriend& f return HasFriend(f1.m + f2.m); } +DLL_API inline const HasFriend operator-(const HasFriend& f1, const HasFriend& f2) +{ + return HasFriend(f1.m - f2.m); +} + bool DifferentConstOverloads::operator ==(const DifferentConstOverloads& other) { return true; diff --git a/tests/Basic/Basic.h b/tests/Basic/Basic.h index 0b6ede87..2318d3b0 100644 --- a/tests/Basic/Basic.h +++ b/tests/Basic/Basic.h @@ -668,6 +668,7 @@ class DLL_API HasFriend public: HasFriend(int m); DLL_API friend inline const HasFriend operator+(const HasFriend& f1, const HasFriend& f2); + DLL_API friend inline const HasFriend operator-(const HasFriend& f1, const HasFriend& f2); int getM(); private: int m; diff --git a/tests/CSharpTemp/CSharpTemp.Tests.cs b/tests/CSharpTemp/CSharpTemp.Tests.cs index 227aeab9..d9a03bd7 100644 --- a/tests/CSharpTemp/CSharpTemp.Tests.cs +++ b/tests/CSharpTemp/CSharpTemp.Tests.cs @@ -206,14 +206,4 @@ public class CSharpTempTests : GeneratorTestFixture { QMap.Iterator test_iter; } - - [Test] - public void TestMultipleNonMemberFriends() - { - var s1 = new QSize(); - var s2 = new QSize(); - - var sum = s1 + s2; - var sub = s1 - s2; - } } \ No newline at end of file diff --git a/tests/CSharpTemp/CSharpTemp.h b/tests/CSharpTemp/CSharpTemp.h index 951485d8..4f884763 100644 --- a/tests/CSharpTemp/CSharpTemp.h +++ b/tests/CSharpTemp/CSharpTemp.h @@ -403,27 +403,3 @@ template <> struct QIntegerForSize<4> { typedef uint32_t Unsigned; typedef int32 template <> struct QIntegerForSize<8> { typedef uint64_t Unsigned; typedef int64_t Signed; }; typedef QIntegerForSize::Signed qregisterint; typedef QIntegerForSize::Unsigned qregisteruint; - -class QSize -{ -public: - QSize(int w, int h); - friend inline const QSize operator+(const QSize &, const QSize &); - friend inline const QSize operator-(const QSize &, const QSize &); - -private: - int wd; - int ht; -}; - -inline QSize::QSize(int w, int h) : wd(w), ht(h) {} - -inline const QSize operator+(const QSize & s1, const QSize & s2) -{ - return QSize(s1.wd + s2.wd, s1.ht + s2.ht); -} - -inline const QSize operator-(const QSize &s1, const QSize &s2) -{ - return QSize(s1.wd - s2.wd, s1.ht - s2.ht); -} \ No newline at end of file