Skip to content

Commit

Permalink
Merge branch 'gui-cs:develop' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
tig authored Sep 18, 2022
2 parents 469a67a + 0a94831 commit af0ee1c
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 3 deletions.
4 changes: 1 addition & 3 deletions NStack/strings/ustring.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2230,9 +2230,7 @@ public ustring Replace (ustring oldValue, ustring newValue, int maxReplacements
/// <returns></returns>
public static bool IsNullOrEmpty (ustring value)
{
if (value == null)
return true;
if (value.Length == 0)
if (value?.IsEmpty != false)
return true;
return false;
}
Expand Down
66 changes: 66 additions & 0 deletions NStackTests/ustringTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -821,5 +821,71 @@ public void IsNullOrEmpty_Accept_Null_Ustring_Arg ()
Assert.False (string.IsNullOrEmpty (ustr.ToString ()));
Assert.False (ustring.IsNullOrEmpty (ustr));
}

[Test]
public void Operator_Equal_Ustring_Versus_String ()
{
ustring? ustr = null;
string? str = null;
Assert.True (ustr == str);
Assert.True (str == ustr);
Assert.True (ustr == null);
Assert.True (str == null);
Assert.False (ustr == "");
Assert.False (str == "");

ustr = "";
str = "";
Assert.True (ustr == str);
Assert.True (str == ustr);
Assert.False (ustr == null);
Assert.False (str == null);
Assert.True (ustr == "");
Assert.True (str == "");

ustr = " ";
str = " ";
Assert.True (ustr == str);
Assert.True (str == ustr);
Assert.False (ustr == null);
Assert.False (str == null);
Assert.False (ustr == "");
Assert.False (str == "");
Assert.True (ustr == " ");
Assert.True (str == " ");
}

[Test]
public void Operator_Not_Equal_Ustring_Versus_String ()
{
ustring? ustr = null;
string? str = null;
Assert.False (ustr != str);
Assert.False (str != ustr);
Assert.False (ustr != null);
Assert.False (str != null);
Assert.True (ustr != "");
Assert.True (str != "");

ustr = "";
str = "";
Assert.False (ustr != str);
Assert.False (str != ustr);
Assert.True (ustr != null);
Assert.True (str != null);
Assert.False (ustr != "");
Assert.False (str != "");

ustr = " ";
str = " ";
Assert.False (ustr != str);
Assert.False (str != ustr);
Assert.True (ustr != null);
Assert.True (str != null);
Assert.True (ustr != "");
Assert.True (str != "");
Assert.False (ustr != " ");
Assert.False (str != " ");
}
}
}

0 comments on commit af0ee1c

Please sign in to comment.