2017-07-26 07:14:43 +00:00
|
|
|
package zerolog
|
|
|
|
|
|
|
|
import (
|
2018-04-03 21:07:18 +00:00
|
|
|
"net"
|
2017-07-26 07:14:43 +00:00
|
|
|
"testing"
|
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestArray(t *testing.T) {
|
|
|
|
a := Arr().
|
|
|
|
Bool(true).
|
|
|
|
Int(1).
|
|
|
|
Int8(2).
|
|
|
|
Int16(3).
|
|
|
|
Int32(4).
|
|
|
|
Int64(5).
|
|
|
|
Uint(6).
|
|
|
|
Uint8(7).
|
|
|
|
Uint16(8).
|
|
|
|
Uint32(9).
|
|
|
|
Uint64(10).
|
2018-04-13 07:13:41 +00:00
|
|
|
Float32(11.98122).
|
|
|
|
Float64(12.987654321).
|
2017-07-26 07:14:43 +00:00
|
|
|
Str("a").
|
2018-03-15 17:29:26 +00:00
|
|
|
Bytes([]byte("b")).
|
|
|
|
Hex([]byte{0x1f}).
|
2017-07-26 07:14:43 +00:00
|
|
|
Time(time.Time{}).
|
2018-04-03 21:07:18 +00:00
|
|
|
IPAddr(net.IP{192, 168, 0, 10}).
|
2017-07-26 07:14:43 +00:00
|
|
|
Dur(0)
|
2018-04-13 07:13:41 +00:00
|
|
|
want := `[true,1,2,3,4,5,6,7,8,9,10,11.98122,12.987654321,"a","b","1f","0001-01-01T00:00:00Z","192.168.0.10",0]`
|
2018-03-28 18:49:41 +00:00
|
|
|
if got := decodeObjectToStr(a.write([]byte{})); got != want {
|
2017-07-26 07:14:43 +00:00
|
|
|
t.Errorf("Array.write()\ngot: %s\nwant: %s", got, want)
|
|
|
|
}
|
|
|
|
}
|