1
0
mirror of https://github.com/oliverbooth/X10D synced 2024-11-23 00:18:47 +00:00

(#42) Throw exceptions on invalid string arguments

This commit is contained in:
Oliver Booth 2021-07-19 11:39:08 +01:00
parent 92d60a6db8
commit 61c122c9ea
No known key found for this signature in database
GPG Key ID: A4AC17007530E9B4

View File

@ -190,6 +190,11 @@ namespace X10D
/// </returns>
public static bool IsLower(this string value)
{
if (value is null)
{
throw new ArgumentNullException(nameof(value));
}
for (var index = 0; index < value.Length; index++)
{
if (!char.IsLetter(value[index]))
@ -216,6 +221,11 @@ namespace X10D
/// </returns>
public static bool IsUpper(this string value)
{
if (value is null)
{
throw new ArgumentNullException(nameof(value));
}
for (var index = 0; index < value.Length; index++)
{
if (!char.IsLetter(value[index]))
@ -315,6 +325,11 @@ namespace X10D
throw new ArgumentNullException(nameof(value));
}
if (count < 0)
{
throw new ArgumentOutOfRangeException(nameof(count), ExceptionMessages.CountMustBeGreaterThanOrEqualTo0);
}
var builder = new StringBuilder(value.Length * count);
for (var i = 0; i < count; i++)
@ -337,7 +352,7 @@ namespace X10D
throw new ArgumentNullException(nameof(value));
}
if (value.Length == 1)
if (value.Length < 2)
{
return value;
}