[tests] Apply formatting rules
This commit is contained in:
parent
50d3068a57
commit
94b7eb7c66
2 changed files with 27 additions and 26 deletions
|
@ -66,7 +66,8 @@ public class MfmTests
|
||||||
[TestMethod]
|
[TestMethod]
|
||||||
public void TestMention()
|
public void TestMention()
|
||||||
{
|
{
|
||||||
const string input = "test @test test @test@instance.tld @test_ @_test @test_@ins-tance.tld @_test@xn--mastodn-f1a.de @_test@-xn--mastodn-f1a.de";
|
const string input =
|
||||||
|
"test @test test @test@instance.tld @test_ @_test @test_@ins-tance.tld @_test@xn--mastodn-f1a.de @_test@-xn--mastodn-f1a.de";
|
||||||
List<MfmNode> expected =
|
List<MfmNode> expected =
|
||||||
[
|
[
|
||||||
new MfmTextNode("test "),
|
new MfmTextNode("test "),
|
||||||
|
@ -81,7 +82,7 @@ public class MfmTests
|
||||||
new MfmMentionNode("test_@ins-tance.tld", "test_", "ins-tance.tld"),
|
new MfmMentionNode("test_@ins-tance.tld", "test_", "ins-tance.tld"),
|
||||||
new MfmTextNode(" "),
|
new MfmTextNode(" "),
|
||||||
new MfmMentionNode("_test@xn--mastodn-f1a.de", "_test", "xn--mastodn-f1a.de"),
|
new MfmMentionNode("_test@xn--mastodn-f1a.de", "_test", "xn--mastodn-f1a.de"),
|
||||||
new MfmTextNode(" @_test@-xn--mastodn-f1a.de"),
|
new MfmTextNode(" @_test@-xn--mastodn-f1a.de")
|
||||||
];
|
];
|
||||||
var res = Mfm.parse(input);
|
var res = Mfm.parse(input);
|
||||||
|
|
||||||
|
@ -180,7 +181,7 @@ public class MfmTests
|
||||||
new MfmHashtagNode("test"),
|
new MfmHashtagNode("test"),
|
||||||
new MfmTextNode("'s "),
|
new MfmTextNode("'s "),
|
||||||
new MfmHashtagNode("t-e_s-t"),
|
new MfmHashtagNode("t-e_s-t"),
|
||||||
new MfmTextNode(". test"),
|
new MfmTextNode(". test")
|
||||||
];
|
];
|
||||||
var res = Mfm.parse(input);
|
var res = Mfm.parse(input);
|
||||||
|
|
||||||
|
@ -226,30 +227,13 @@ public class MfmTests
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class MfmNodeEquality : IEqualityComparer<MfmNode>
|
|
||||||
{
|
|
||||||
public bool Equals(MfmNode? x, MfmNode? y)
|
|
||||||
{
|
|
||||||
if (x == null && y == null) return true;
|
|
||||||
if (x == null && y != null) return false;
|
|
||||||
if (x != null && y == null) return false;
|
|
||||||
|
|
||||||
return MfmNodeEqual(x!, y!);
|
|
||||||
}
|
|
||||||
|
|
||||||
public int GetHashCode(MfmNode obj)
|
|
||||||
{
|
|
||||||
return obj.GetHashCode();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static bool MfmNodeEqual(MfmNode a, MfmNode b)
|
private static bool MfmNodeEqual(MfmNode a, MfmNode b)
|
||||||
{
|
{
|
||||||
if (a.GetType() != b.GetType()) return false;
|
if (a.GetType() != b.GetType()) return false;
|
||||||
|
|
||||||
if (!a.Children.IsEmpty || !b.Children.IsEmpty)
|
if (!a.Children.IsEmpty || !b.Children.IsEmpty)
|
||||||
{
|
{
|
||||||
if (!a.Children.IsEmpty && b.Children.IsEmpty || a.Children.IsEmpty && !b.Children.IsEmpty)
|
if ((!a.Children.IsEmpty && b.Children.IsEmpty) || (a.Children.IsEmpty && !b.Children.IsEmpty))
|
||||||
return false;
|
return false;
|
||||||
if (!a.Children.SequenceEqual(b.Children, new MfmNodeEquality()))
|
if (!a.Children.SequenceEqual(b.Children, new MfmNodeEquality()))
|
||||||
return false;
|
return false;
|
||||||
|
@ -338,4 +322,21 @@ public class MfmTests
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private class MfmNodeEquality : IEqualityComparer<MfmNode>
|
||||||
|
{
|
||||||
|
public bool Equals(MfmNode? x, MfmNode? y)
|
||||||
|
{
|
||||||
|
if (x == null && y == null) return true;
|
||||||
|
if (x == null && y != null) return false;
|
||||||
|
if (x != null && y == null) return false;
|
||||||
|
|
||||||
|
return MfmNodeEqual(x!, y!);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int GetHashCode(MfmNode obj)
|
||||||
|
{
|
||||||
|
return obj.GetHashCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
Loading…
Add table
Reference in a new issue