package com.hubspot.jinjava.util;

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

import org.junit.Test;

import com.hubspot.jinjava.interpret.OutputTooBigException;

public class LengthLimitingStringBuilderTest {

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

@@ -487,10 +487,190 @@
 s);%0A  %7D%0A
+%0A  @Test%0A  public void itDoesNotLimitWithZeroLength() throws Exception %7B%0A    LengthLimitingStringBuilder sb = new LengthLimitingStringBuilder(0);%0A    sb.append(%220123456789%22);%0A  %7D%0A%0A
 %7D%0A

add test for 0 length