Merge pull request #106 from bzz/test/empty-content

Add failing test for empty file content
This commit is contained in:
Alfredo Beaumont 2017-09-22 18:31:44 +02:00 committed by GitHub
commit 3d63a636bb
2 changed files with 7 additions and 1 deletions

View File

@ -58,7 +58,7 @@ class GoUtils {
static GoSlice.ByValue toGoByteSlice(byte[] bytes) { static GoSlice.ByValue toGoByteSlice(byte[] bytes) {
int length = 0; int length = 0;
Pointer ptr = null; Pointer ptr = null;
if (bytes != null) { if (bytes != null && bytes.length > 0) {
length = bytes.length; length = bytes.length;
ptr = ptrFromBytes(bytes); ptr = ptrFromBytes(bytes);
} }

View File

@ -23,6 +23,12 @@ public class EnryTest {
assertEquals("Python", Enry.getLanguage("foo.py", null)); assertEquals("Python", Enry.getLanguage("foo.py", null));
} }
@Test
public void getLanguageWithEmptyContent() {
assertEquals("Go", Enry.getLanguage("baz.go", "".getBytes()));
assertEquals("Go", Enry.getLanguage("baz.go", null));
}
@Test @Test
public void getLanguageWithNullFilename() { public void getLanguageWithNullFilename() {
byte[] content = "#!/usr/bin/env python".getBytes(); byte[] content = "#!/usr/bin/env python".getBytes();