From 94b7eb7c66846b77a31b9dc373739ddcb1e9e1a8 Mon Sep 17 00:00:00 2001 From: Laura Hausmann Date: Sat, 29 Jun 2024 01:09:17 +0200 Subject: [PATCH] [tests] Apply formatting rules --- Iceshrimp.Tests/Iceshrimp.Tests.csproj | 10 +++--- Iceshrimp.Tests/Parsing/MfmTests.cs | 43 +++++++++++++------------- 2 files changed, 27 insertions(+), 26 deletions(-) diff --git a/Iceshrimp.Tests/Iceshrimp.Tests.csproj b/Iceshrimp.Tests/Iceshrimp.Tests.csproj index f8b0e467..85d60b9c 100644 --- a/Iceshrimp.Tests/Iceshrimp.Tests.csproj +++ b/Iceshrimp.Tests/Iceshrimp.Tests.csproj @@ -18,12 +18,12 @@ - - - + + + - all - runtime; build; native; contentfiles; analyzers; buildtransitive + all + runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Iceshrimp.Tests/Parsing/MfmTests.cs b/Iceshrimp.Tests/Parsing/MfmTests.cs index f860ad6b..0e315ebe 100644 --- a/Iceshrimp.Tests/Parsing/MfmTests.cs +++ b/Iceshrimp.Tests/Parsing/MfmTests.cs @@ -66,7 +66,8 @@ public class MfmTests [TestMethod] 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 expected = [ new MfmTextNode("test "), @@ -81,7 +82,7 @@ public class MfmTests new MfmMentionNode("test_@ins-tance.tld", "test_", "ins-tance.tld"), new MfmTextNode(" "), 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); @@ -180,7 +181,7 @@ public class MfmTests new MfmHashtagNode("test"), new MfmTextNode("'s "), new MfmHashtagNode("t-e_s-t"), - new MfmTextNode(". test"), + new MfmTextNode(". test") ]; var res = Mfm.parse(input); @@ -226,30 +227,13 @@ public class MfmTests } } - private class MfmNodeEquality : IEqualityComparer - { - 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) { if (a.GetType() != b.GetType()) return false; 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; if (!a.Children.SequenceEqual(b.Children, new MfmNodeEquality())) return false; @@ -338,4 +322,21 @@ public class MfmTests return true; } + + private class MfmNodeEquality : IEqualityComparer + { + 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(); + } + } } \ No newline at end of file