Skip to content

Commit

Permalink
Merge pull request #106 from bzz/test/empty-content
Browse files Browse the repository at this point in the history
Add failing test for empty file content
  • Loading branch information
abeaumont authored Sep 22, 2017
2 parents a6faaaf + 9a36e8f commit 3d63a63
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion java/src/main/java/tech/sourced/enry/GoUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ static String[] toJavaStringArray(GoSlice slice) {
static GoSlice.ByValue toGoByteSlice(byte[] bytes) {
int length = 0;
Pointer ptr = null;
if (bytes != null) {
if (bytes != null && bytes.length > 0) {
length = bytes.length;
ptr = ptrFromBytes(bytes);
}
Expand Down
6 changes: 6 additions & 0 deletions java/src/test/java/tech/sourced/enry/EnryTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public void getLanguageWithNullContent() {
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
public void getLanguageWithNullFilename() {
byte[] content = "#!/usr/bin/env python".getBytes();
Expand Down

0 comments on commit 3d63a63

Please sign in to comment.