summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLauro Moura <lauromoura@expertisesolutions.com.br>2019-06-27 19:26:44 -0300
committerVitor Sousa <vitorsousa@expertisesolutions.com.br>2019-06-27 19:28:53 -0300
commit0f514b484bb3f14ec7c7ef2882f990ff73815527 (patch)
tree4ff94956f7ad9f24b9ab9f924eae0355801f16c1
parentaccaaa1ff7be168a16dd682760943dee429619eb (diff)
csharp: Rename test util parameters
Summary: Instead of 'expected' and 'actual', use 'lhs' and 'rhs', as it allows the actually expected value to be in any position. Reviewers: vitor.sousa Reviewed By: vitor.sousa Subscribers: cedric, #reviewers, #committers Tags: #efl, #expertise_solutions Differential Revision: https://phab.enlightenment.org/D9196
-rw-r--r--src/tests/efl_mono/TestUtils.cs26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/tests/efl_mono/TestUtils.cs b/src/tests/efl_mono/TestUtils.cs
index b66f15a0bc..21b8ec7794 100644
--- a/src/tests/efl_mono/TestUtils.cs
+++ b/src/tests/efl_mono/TestUtils.cs
@@ -37,46 +37,46 @@ public static class Test
37 throw new AssertionException($"Assertion failed: {file}:{line} ({member}) {msg}"); 37 throw new AssertionException($"Assertion failed: {file}:{line} ({member}) {msg}");
38 } 38 }
39 39
40 /// <summary> Asserts if expected is equal to actual, using expected.Equals(actual).</summary> 40 /// <summary> Asserts if lhs is equal to rhs, using lhs.Equals(rhs).</summary>
41 public static void AssertEquals<T>(T expected, T actual, String msg = null, 41 public static void AssertEquals<T>(T lhs, T rhs, String msg = null,
42 [CallerLineNumber] int line = 0, 42 [CallerLineNumber] int line = 0,
43 [CallerFilePath] string file = null, 43 [CallerFilePath] string file = null,
44 [CallerMemberName] string member = null) 44 [CallerMemberName] string member = null)
45 { 45 {
46 if (expected == null && actual == null) 46 if (lhs == null && rhs == null)
47 return; 47 return;
48 if (expected == null || !expected.Equals(actual)) 48 if (lhs == null || !lhs.Equals(rhs))
49 { 49 {
50 if (file == null) 50 if (file == null)
51 file = "(unknown file)"; 51 file = "(unknown file)";
52 if (member == null) 52 if (member == null)
53 member = "(unknown member)"; 53 member = "(unknown member)";
54 if (msg == null || msg.Length == 0) 54 if (msg == null || msg.Length == 0)
55 msg = $"Expected \"{expected}\", actual \"{actual}\""; 55 msg = $"Left hand side \"{lhs}\", right hand side \"{rhs}\"";
56 throw new AssertionException($"{file}:{line} ({member}) {msg}"); 56 throw new AssertionException($"{file}:{line} ({member}) {msg}");
57 } 57 }
58 } 58 }
59 59
60 /// <summary> Asserts if expected is not equal to actual, using !expected.Equals(actual).</summary> 60 /// <summary> Asserts if lhs is not equal to rhs, using !lhs.Equals(rhs).</summary>
61 public static void AssertNotEquals<T>(T expected, T actual, String msg = null, 61 public static void AssertNotEquals<T>(T lhs, T rhs, String msg = null,
62 [CallerLineNumber] int line = 0, 62 [CallerLineNumber] int line = 0,
63 [CallerFilePath] string file = null, 63 [CallerFilePath] string file = null,
64 [CallerMemberName] string member = null) 64 [CallerMemberName] string member = null)
65 { 65 {
66 if (expected == null ? actual == null : expected.Equals(actual)) 66 if (lhs == null ? rhs == null : lhs.Equals(rhs))
67 { 67 {
68 if (file == null) 68 if (file == null)
69 file = "(unknown file)"; 69 file = "(unknown file)";
70 if (member == null) 70 if (member == null)
71 member = "(unknown member)"; 71 member = "(unknown member)";
72 if (msg == null || msg.Length == 0) 72 if (msg == null || msg.Length == 0)
73 msg = $"Expected \"{expected}\" shouldn't be equal to actual \"{actual}\""; 73 msg = $"Left hand side \"{lhs}\" shouldn't be equal to right hand side \"{rhs}\"";
74 throw new AssertionException($"{file}:{line} ({member}) {msg}"); 74 throw new AssertionException($"{file}:{line} ({member}) {msg}");
75 } 75 }
76 } 76 }
77 77
78 /// <summary> Asserts if actual is near enough of expected, using the optional tolerance (default 0.00001).</summary> 78 /// <summary> Asserts if rhs is near enough of lhs, using the optional tolerance (default 0.00001).</summary>
79 public static void AssertAlmostEquals(double expected, double actual, double tolerance=0.00001, 79 public static void AssertAlmostEquals(double lhs, double rhs, double tolerance=0.00001,
80 String msg = null, 80 String msg = null,
81 [CallerLineNumber] int line = 0, 81 [CallerLineNumber] int line = 0,
82 [CallerFilePath] string file = null, 82 [CallerFilePath] string file = null,
@@ -86,10 +86,10 @@ public static class Test
86 file = "(unknown file)"; 86 file = "(unknown file)";
87 if (member == null) 87 if (member == null)
88 member = "(unknown member)"; 88 member = "(unknown member)";
89 double difference = Math.Abs(expected - actual); 89 double difference = Math.Abs(lhs - rhs);
90 if (difference > tolerance) { 90 if (difference > tolerance) {
91 if (msg == null || msg.Length == 0) 91 if (msg == null || msg.Length == 0)
92 msg = $"Expected \"{expected}\". Difference: \"{difference}\""; 92 msg = $"Left hand side \"{lhs}\". Difference: \"{difference}\"";
93 throw new AssertionException($"{file}:{line} ({member}) {msg}"); 93 throw new AssertionException($"{file}:{line} ({member}) {msg}");
94 } 94 }
95 } 95 }