Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Zeugma440 committed Sep 13, 2023
2 parents bd03a0b + e4bc26e commit fe3c1a9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
4 changes: 3 additions & 1 deletion ATL.unit-test/Misc/LyricsSortTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,15 @@ public class LyricsSortTest
private LyricsInfo.LyricsPhrase lyrics1 = new(1000, "AAA");
private LyricsInfo.LyricsPhrase lyrics1b = new(1000, "AAA");
private LyricsInfo.LyricsPhrase lyrics2 = new(2000, "ZZZ");

private LyricsInfo.LyricsPhrase lyrics3 = null;

[TestMethod]
public void LyricsSort_Equality()
{
Assert.IsTrue(lyrics1 != lyrics2);
Assert.IsTrue(lyrics1 != null);
Assert.IsTrue(lyrics1 == lyrics1b);
Assert.IsTrue(lyrics3 == null);
Assert.IsTrue(lyrics1 >= lyrics1b);
Assert.IsTrue(lyrics1 <= lyrics1b);
Assert.IsTrue(lyrics1 == new LyricsInfo.LyricsPhrase(lyrics1));
Expand Down
18 changes: 16 additions & 2 deletions ATL/Entities/LyricsInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,15 +154,29 @@ public override bool Equals(object obj)
/// <param name="a">The first LyricsPhrase object</param>
/// <param name="b">The second LyricsPhrase object</param>
/// <returns>True if a == b, else false</returns>
public static bool operator ==(LyricsPhrase a, LyricsPhrase b) => !ReferenceEquals(a, null) && a.Equals(b);
public static bool operator ==(LyricsPhrase a, LyricsPhrase b)
{
if (ReferenceEquals(a, null) && ReferenceEquals(b, null))
{
return true;
}
return !ReferenceEquals(a, null) && a.Equals(b);
}

/// <summary>
/// Compares two LyricsPhrase objects by not-equals
/// </summary>
/// <param name="a">The first LyricsPhrase object</param>
/// <param name="b">The second LyricsPhrase object</param>
/// <returns>True if a != b, else false</returns>
public static bool operator !=(LyricsPhrase a, LyricsPhrase b) => !ReferenceEquals(a, null) && !a.Equals(b);
public static bool operator !=(LyricsPhrase a, LyricsPhrase b)
{
if ((!ReferenceEquals(a, null) && ReferenceEquals(b, null)) || (ReferenceEquals(a, null) && !ReferenceEquals(b, null)))
{
return true;
}
return !ReferenceEquals(a, null) && !a.Equals(b);
}

/// <summary>
/// Compares two LyricsPhrase objects by inferior
Expand Down

0 comments on commit fe3c1a9

Please sign in to comment.