Skip to content
This repository has been archived by the owner on Jun 16, 2019. It is now read-only.

Commit

Permalink
Fixed build, added test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
afollestad committed Mar 1, 2017
1 parent fc27da7 commit c7e6cae
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/main/java/com/afollestad/ason/Util.java
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,9 @@ static boolean isList(Class<?> cls) {
}

static boolean shouldIgnore(Field field) {
return field.getName().startsWith("this$") ||
field.getAnnotation(AsonIgnore.class) != null;
return field.getName().startsWith("this$")
|| field.getName().equals("$jacocoData") // used with Jacoco testing
|| field.getAnnotation(AsonIgnore.class) != null;
}

static String fieldName(Field field) {
Expand Down
12 changes: 11 additions & 1 deletion src/test/java/com/afollestad/ason/UtilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
/**
* @author Aidan Follestad (afollestad)
*/
public class UtilTest {
@SuppressWarnings("unused") public class UtilTest {

@SuppressWarnings("unused") static class DefaultCtorClass {

Expand Down Expand Up @@ -113,4 +113,14 @@ public class UtilTest {
} catch (Throwable ignored) {
}
}

@AsonIgnore Field ignoreYes1;
Field $jacocoData;
Field ignoreNo2;

@Test public void test_should_ignore() throws Exception {
assertTrue(shouldIgnore(getClass().getDeclaredField("ignoreYes1")));
assertTrue(shouldIgnore(getClass().getDeclaredField("$jacocoData")));
assertFalse(shouldIgnore(getClass().getDeclaredField("ignoreNo2")));
}
}

0 comments on commit c7e6cae

Please sign in to comment.