Exemplo n.º 1
0
  @Test
  public void testDeepNestedStyles() {
    OutputFormatter formatter = new OutputFormatter(true);

    assertEquals(
        "\033[37;41merror\033[0m\033[32minfo\033[0m\033[33mcomment\033[0m\033[37;41merror\033[0m",
        formatter.format("<error>error<info>info<comment>comment</info>error</error>"));
  }
Exemplo n.º 2
0
  @Test
  public void testNestedStyles() {
    OutputFormatter formatter = new OutputFormatter(true);

    assertEquals(
        "\033[37;41msome \033[0m\033[32msome info\033[0m\033[37;41m error\033[0m",
        formatter.format("<error>some <info>some info</info> error</error>"));
  }
Exemplo n.º 3
0
  @Test
  public void testInlineStyle() {
    OutputFormatter formatter = new OutputFormatter(true);

    assertEquals("\033[34;41msome text\033[0m", formatter.format("<fg=blue;bg=red>some text</>"));
    assertEquals(
        "\033[34;41msome text\033[0m",
        formatter.format("<fg=blue;bg=red>some text</fg=blue;bg=red>"));
  }
Exemplo n.º 4
0
  @Test
  public void testRedefineStyle() {
    OutputFormatter formatter = new OutputFormatter(true);

    OutputFormatterStyle style = new OutputFormatterStyle("blue", "white");
    formatter.setStyle("info", style);

    assertEquals(
        "\033[34;47msome custom msg\033[0m", formatter.format("<info>some custom msg</info>"));
  }
Exemplo n.º 5
0
  @Test
  public void testContentWithLineBreaks() {
    OutputFormatter formatter = new OutputFormatter(true);

    assertEquals("\033[32m\nsome text\n\033[0m", formatter.format("<info>\nsome text\n</info>"));
    assertEquals("\033[32m\nsome text\n\033[0m", formatter.format("<info>\nsome text\n</info>"));
    assertEquals("\033[32m\nsome text\n\033[0m", formatter.format("<info>\nsome text\n</info>"));
    assertEquals(
        "\033[32m\nsome text\nmore text\n\033[0m",
        formatter.format("<info>\nsome text\nmore text\n</info>"));
  }
Exemplo n.º 6
0
  @Test
  public void testNewStyle() {
    OutputFormatter formatter = new OutputFormatter(true);

    OutputFormatterStyle style = new OutputFormatterStyle("blue", "white");
    formatter.setStyle("test", style);

    assertEquals(style, formatter.getStyle("test"));
    assertNotSame(style, formatter.getStyle("info"));

    assertEquals(
        "\033[34;47msome custom msg\033[0m", formatter.format("<test>some custom msg</test>"));
  }
Exemplo n.º 7
0
  @Test
  public void testBundledStyles() {
    OutputFormatter formatter = new OutputFormatter(true);

    assertTrue(formatter.hasStyle("error"));
    assertTrue(formatter.hasStyle("info"));
    assertTrue(formatter.hasStyle("comment"));
    assertTrue(formatter.hasStyle("question"));

    assertEquals("\033[37;41msome error\033[0m", formatter.format("<error>some error</error>"));
    assertEquals("\033[32msome info\033[0m", formatter.format("<info>some info</info>"));
    assertEquals(
        "\033[33msome comment\033[0m", formatter.format("<comment>some comment</comment>"));
    assertEquals(
        "\033[30;46msome question\033[0m", formatter.format("<question>some question</question>"));
  }
Exemplo n.º 8
0
 @Test
 public void testEmptyTag() {
   OutputFormatter formatter = new OutputFormatter(true);
   assertEquals("foo<>bar", formatter.format("foo<>bar"));
 }