Merge pull request #61 from peters/master

bugfix: handle single/multiple ASCII characters
This commit is contained in:
Paul Betts
2014-09-25 00:11:18 -07:00
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]