Browse Source

Moved the improved test for friends to Basic because it's not C#-specific.

Signed-off-by: Dimitar Dobrev <dpldobrev@yahoo.com>
pull/413/head
Dimitar Dobrev 10 years ago
parent
commit
d2189fa5a7
  1. 1
      tests/Basic/Basic.Tests.cs
  2. 5
      tests/Basic/Basic.cpp
  3. 1
      tests/Basic/Basic.h
  4. 10
      tests/CSharpTemp/CSharpTemp.Tests.cs
  5. 24
      tests/CSharpTemp/CSharpTemp.h

1
tests/Basic/Basic.Tests.cs

@ -474,6 +474,7 @@ public class BasicTests : GeneratorTestFixture
HasFriend h1 = 5; HasFriend h1 = 5;
HasFriend h2 = 10; HasFriend h2 = 10;
Assert.AreEqual(15, (h1 + h2).M); Assert.AreEqual(15, (h1 + h2).M);
Assert.AreEqual(-5, (h1 - h2).M);
} }
[Test] [Test]

5
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); 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) bool DifferentConstOverloads::operator ==(const DifferentConstOverloads& other)
{ {
return true; return true;

1
tests/Basic/Basic.h

@ -668,6 +668,7 @@ class DLL_API HasFriend
public: public:
HasFriend(int m); 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);
DLL_API friend inline const HasFriend operator-(const HasFriend& f1, const HasFriend& f2);
int getM(); int getM();
private: private:
int m; int m;

10
tests/CSharpTemp/CSharpTemp.Tests.cs

@ -206,14 +206,4 @@ public class CSharpTempTests : GeneratorTestFixture
{ {
QMap.Iterator test_iter; QMap.Iterator test_iter;
} }
[Test]
public void TestMultipleNonMemberFriends()
{
var s1 = new QSize();
var s2 = new QSize();
var sum = s1 + s2;
var sub = s1 - s2;
}
} }

24
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; }; template <> struct QIntegerForSize<8> { typedef uint64_t Unsigned; typedef int64_t Signed; };
typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Signed qregisterint; typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Signed qregisterint;
typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::Unsigned qregisteruint; typedef QIntegerForSize<Q_PROCESSOR_WORDSIZE>::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);
}
Loading…
Cancel
Save