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");
  }
}

@@ -28,16 +28,74 @@
 .util;%0A%0A
+import static org.assertj.core.api.Assertions.assertThat;%0A
 import s
@@ -688,11 +688,200 @@
 9%22);%0A  %7D
+%0A%0A  @Test%0A  public void itHandlesNullStrings() %7B%0A    LengthLimitingStringBuilder sb = new LengthLimitingStringBuilder(10);%0A    sb.append(null);%0A    assertThat(sb.length()).isEqualTo(0);%0A  %7D
 %0A%7D%0A

Add test for append(null) to LengthLimitingStringBuilder