package com.hubspot.jinjava.util;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import com.hubspot.jinjava.interpret.OutputTooBigException;
import org.junit.Test;

public class LengthLimitingStringBuilderTest {

  @Test
  public void itLimitsStringLength() {
    LengthLimitingStringBuilder sb = new LengthLimitingStringBuilder(10);
    sb.append("0123456789");
    assertThatThrownBy(() -> sb.append("1")).isInstanceOf(OutputTooBigException.class);
  }

  @Test
  public void itDoesNotLimitWithZeroLength() {
    LengthLimitingStringBuilder sb = new LengthLimitingStringBuilder(0);
    sb.append("0123456789");
  }

  @Test
  public void itHandlesNullStrings() {
    LengthLimitingStringBuilder sb = new LengthLimitingStringBuilder(10);
    sb.append(null);
    assertThat(sb.length()).isEqualTo(0);
  }
}

package com.hubspot.jinjava.util;

import static org.assertj.core.api.Assertions.assertThatThrownBy;

import com.hubspot.jinjava.interpret.OutputTooBigException;
import org.junit.Test;

public class LengthLimitingStringBuilderTest {

  @Test
  public void itLimitsStringLength() {
    LengthLimitingStringBuilder sb = new LengthLimitingStringBuilder(10);
    sb.append("0123456789");
    assertThatThrownBy(() -> sb.append("1")).isInstanceOf(OutputTooBigException.class);
  }

  @Test
  public void itDoesNotLimitWithZeroLength() {
    LengthLimitingStringBuilder sb = new LengthLimitingStringBuilder(0);
    sb.append("0123456789");
  }
}

--- 
+++ 
@@ -1,5 +1,6 @@
 package com.hubspot.jinjava.util;
 
+import static org.assertj.core.api.Assertions.assertThat;
 import static org.assertj.core.api.Assertions.assertThatThrownBy;
 
 import com.hubspot.jinjava.interpret.OutputTooBigException;
@@ -19,4 +20,11 @@
     LengthLimitingStringBuilder sb = new LengthLimitingStringBuilder(0);
     sb.append("0123456789");
   }
+
+  @Test
+  public void itHandlesNullStrings() {
+    LengthLimitingStringBuilder sb = new LengthLimitingStringBuilder(10);
+    sb.append(null);
+    assertThat(sb.length()).isEqualTo(0);
+  }
 }
Add test for append(null) to LengthLimitingStringBuilder
