Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 != " ");
}
}
}