package compute
import (
"testing"
)
func TestFormatCtx(t *testing.T) {
ctx := &FormatCtx{}
ctx.Write("test")
if ctx.String() != "test" {
t.Errorf("expected 'test', got '%s'", ctx.String())
}
ctx.Writef("test %d", 1)
if ctx.String() != "testtest 1" {
t.Errorf("expected 'testtest 1', got '%s'", ctx.String())
}
ctx.Writefln("test %d", 2)
if ctx.String() != "testtest 1test 2\n" {
t.Errorf("expected 'testtest 1test 2\n', got '%s'", ctx.String())
}
ctx.Writeln("test", 3)
if ctx.String() != "testtest 1test 2\ntest 3\n" {
t.Errorf("expected 'testtest 1test 2\ntest 3\n', got '%s'", ctx.String())
}
}
func TestPadding(t *testing.T) {
p := &Padding{}
p.AddPad()
if p.pad != defaultIndent {
t.Errorf("expected %d, got %d", defaultIndent, p.pad)
}
p.RestorePad()
if p.pad != 0 {
t.Errorf("expected 0, got %d", p.pad)
}
}