/*
 * @author Ranides Atterwim <ranides@gmail.com>
 * @copyright Ranides Atterwim
 * @license WTFPL
 * @url http://ranides.net/projects/assira
 */
package net.ranides.assira.text.format;

import static org.junit.Assert.*;
import org.junit.Test;

/**
 *
 * @author Ranides Atterwim <ranides@gmail.com>
 */
public class AnsiBuilderTest {
    
    public AnsiBuilderTest() {
    }

    @Test
    public void testAppend() {
        AnsiBuilder builder = new AnsiBuilder();
        
        AnsiCharSequence v1 = new AnsiString("Hello");
        v1.setAttr(0, v1.length(), AnsiStrings.attr("5 15 7 +b"));
        builder.append(v1);
        
        builder.append(1, ' ', AnsiStrings.attr("6 16 8 +u"));
        builder.append("world", AnsiStrings.attr("7 17 9 +s"));
        builder.append("........................................", AnsiStrings.attr("1 1 1"));
        builder.append("END", AnsiStrings.attr("1 1 1"));
        
        AnsiCharSequence exp = new AnsiString("Hello world........................................END");
        exp.setAttr(0, 5, AnsiStrings.attr("5 15 7 +b"));
        exp.setAttr(5, 6, AnsiStrings.attr("6 16 8 +u"));
        exp.setAttr(6, 11, AnsiStrings.attr("7 17 9 +s"));
        exp.setAttr(11, exp.length(), AnsiStrings.attr("1 1 1"));
        
        AnsiGenerator.dump(builder.result());
        AnsiGenerator.dump(exp);
        
        assertEquals(exp, builder.result());
    }
    
}
