summaryrefslogtreecommitdiff
path: root/src/tests/efl_mono
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-11-19 01:48:01 -0300
committerLauro Moura <lauromoura@expertisesolutions.com.br>2019-11-19 21:49:35 -0300
commitb1eb794a913e753929635aa80aeab8c2211db462 (patch)
treed36a71f0f1ba8a08de8d1e3078917088e1d07b59 /src/tests/efl_mono
parente36b1930bf04694fb67dd7e741dbcb5231bf5e58 (diff)
downloadefl-b1eb794a913e753929635aa80aeab8c2211db462.tar.gz
csharp: Fix CA1815 for generated structs and aliases
Summary: Adds IEquatable<T> and friends. Reviewers: felipealmeida, YOhoho, brunobelo Reviewed By: brunobelo Subscribers: cedric, #reviewers, segfaultxavi, #committers Tags: #efl Maniphest Tasks: T8418 Differential Revision: https://phab.enlightenment.org/D10694
Diffstat (limited to 'src/tests/efl_mono')
-rw-r--r--src/tests/efl_mono/Eo.cs36
-rw-r--r--src/tests/efl_mono/Structs.cs44
2 files changed, 80 insertions, 0 deletions
diff --git a/src/tests/efl_mono/Eo.cs b/src/tests/efl_mono/Eo.cs
index 9a52085902..fc3c0d4c86 100644
--- a/src/tests/efl_mono/Eo.cs
+++ b/src/tests/efl_mono/Eo.cs
@@ -675,4 +675,40 @@ class TestHiddenClasses
}
}
+class TestAliasEquality
+{
+ static Dummy.MyInt a = 4;
+ static Dummy.MyInt b = 4;
+ static Dummy.MyInt c = 5;
+
+ public static void test_equals()
+ {
+ Test.AssertEquals(a, b);
+ Test.AssertNotEquals(a, c);
+ }
+
+ public static void test_equals_different_types()
+ {
+ Test.Assert(!(a.Equals(new Object())));
+ }
+
+ public static void test_equatable()
+ {
+ Test.Assert(((IEquatable<Dummy.MyInt>)a).Equals(b));
+ Test.Assert(!((IEquatable<Dummy.MyInt>)a).Equals(c));
+ }
+
+ public static void test_equality_operators()
+ {
+ Test.Assert(a == b);
+ Test.Assert(a != c);
+ }
+
+ public static void test_hash_code()
+ {
+ Test.AssertEquals(a.GetHashCode(), b.GetHashCode());
+ Test.AssertNotEquals(a.GetHashCode(), c.GetHashCode());
+ }
+}
+
}
diff --git a/src/tests/efl_mono/Structs.cs b/src/tests/efl_mono/Structs.cs
index 998610c785..60be42eea5 100644
--- a/src/tests/efl_mono/Structs.cs
+++ b/src/tests/efl_mono/Structs.cs
@@ -377,4 +377,48 @@ internal class TestStructs
// }
}
+internal class TestStructEquality
+{
+ static Dummy.StructSimple a = new Dummy.StructSimple(1, 2, (char)3, 4, Fstring: "", Fmstring: "", Fstringshare: "");
+ static Dummy.StructSimple b = new Dummy.StructSimple(1, 2, (char)3, 4, Fstring: "", Fmstring: "", Fstringshare: "");
+
+ static Dummy.StructSimple c = new Dummy.StructSimple(4, 3, (char)2, 1, Fstring: "", Fmstring: "", Fstringshare: "");
+
+ // to check if we differ on a single struct field
+ static Dummy.StructSimple singleDifferentField = new Dummy.StructSimple(1, 2, (char)3, 5, Fstring: "", Fmstring: "", Fstringshare: "");
+
+ public static void test_equals()
+ {
+ Test.AssertEquals(a, b);
+ Test.AssertNotEquals(a, c);
+ Test.AssertNotEquals(a, singleDifferentField);
+ }
+
+ public static void test_equals_different_types()
+ {
+ Test.Assert(!(a.Equals(new Object())));
+ }
+
+ public static void test_equatable()
+ {
+ Test.Assert(((IEquatable<Dummy.StructSimple>)a).Equals(b));
+ Test.Assert(!((IEquatable<Dummy.StructSimple>)a).Equals(c));
+ Test.Assert(!((IEquatable<Dummy.StructSimple>)a).Equals(singleDifferentField));
+ }
+
+ public static void test_equality_operators()
+ {
+ Test.Assert(a == b);
+ Test.Assert(a != c);
+ Test.Assert(a != singleDifferentField);
+ }
+
+ public static void test_hash_code()
+ {
+ Test.AssertEquals(a.GetHashCode(), b.GetHashCode());
+ Test.AssertNotEquals(a.GetHashCode(), c.GetHashCode());
+ Test.AssertNotEquals(a.GetHashCode(), singleDifferentField.GetHashCode());
+ }
+}
+
}