bugfix: handle single/multiple ASCII characters

This commit is contained in:
Peter Rekdal Sunde
2014-09-25 08:54:51 +02:00
parent 7dd2ec3b6a
commit 00f02d32e5
2 changed files with 7 additions and 1 deletions

View File

@@ -30,7 +30,7 @@ namespace Squirrel
{
byte[] output = { };
if (content == null || content.Length < 2)
if (content == null)
{
goto done;
}

View File

@@ -28,6 +28,9 @@ namespace Squirrel.Tests.Core
var utf16LeHelloWorld = combine(utf16Le, Encoding.UTF8.GetBytes("hello world"));
var utf8HelloWorld = combine(utf8, Encoding.UTF8.GetBytes("hello world"));
var asciiMultipleChars = Encoding.ASCII.GetBytes("hello world");
var asciiSingleChar = Encoding.ASCII.GetBytes("A");
var emptyString = string.Empty;
string nullString = null;
byte[] nullByteArray = {};
@@ -46,6 +49,9 @@ namespace Squirrel.Tests.Core
Assert.Equal("hello world", Utility.RemoveByteOrderMarkerIfPresent(utf16BeHelloWorld));
Assert.Equal("hello world", Utility.RemoveByteOrderMarkerIfPresent(utf16LeHelloWorld));
Assert.Equal("hello world", Utility.RemoveByteOrderMarkerIfPresent(utf8HelloWorld));
Assert.Equal("hello world", Utility.RemoveByteOrderMarkerIfPresent(asciiMultipleChars));
Assert.Equal("A", Utility.RemoveByteOrderMarkerIfPresent(asciiSingleChar));
}
[Fact]