github.com/signintech/pdft@v0.5.0/minigopdf/buff_write_test.go (about) 1 package gopdf 2 3 import ( 4 "bytes" 5 "testing" 6 ) 7 8 func TestWriteUInt32(t *testing.T) { 9 var buff bytes.Buffer 10 err := WriteUInt32(&buff, 65536) 11 if err != nil { 12 t.Errorf("%s", err.Error()) 13 } 14 15 b := buff.Bytes() 16 if b[0] != 0 || b[1] != 1 || b[2] != 0 || b[3] != 0 { 17 t.Errorf("WriteUInt64 fail") 18 } 19 } 20 21 /* 22 func TestFloat(t *testing.T){ 23 a := float64(1170.08) 24 b := float64(1013.08) 25 c := float64(54673.00) 26 d := float64(131588.00) 27 e := float64(54236.52) 28 sum := a + b + c + d + e 29 if sum != 242680.68 { 30 t.Errorf("!242680.68") 31 } 32 }*/ 33 34 func TestEncodeUTF8(t *testing.T) { 35 str := "Boonchai Manasirisuk" 36 buff := encodeUtf8(str) 37 if buff != "0042006F006F006E00630068006100690020004D0061006E0061007300690072006900730075006B" { 38 t.Error("not match") 39 } 40 } 41 42 /* 43 func TestInfoDate(t *testing.T) { 44 str := infodate(time.Now()) 45 fmt.Printf("%s\n", str) 46 }*/