package sdb

import (
	"testing"
)

func TestEncode(t *testing.T) {
	type dbCode struct {
		Name string `json:"name,none"`
		Age  int64  `json:"age"`
	}
	var dc dbCode
	dc.Name = "1111"
	t.Log(Encode(dc))
}

func TestEncodes(t *testing.T) {
	type dbCode struct {
		Name string `json:"name"`
		Age  int64  `json:"age,none"`
	}
	rows := make([]dbCode, 0)
	rows = append(rows, dbCode{
		Name: "111",
		Age:  111,
	})
	rows = append(rows, dbCode{
		Name: "222",
		Age:  222,
	})
	t.Log(Encodes(rows))
}

func BenchmarkEncode(b *testing.B) {
	type dbCode struct {
		Name string `json:"name,omitempty"`
		A    int64  `json:"age"`
		B    string `json:"a"`
		C    int64  `json:"b"`
		D    int64  `json:"c"`
		E    int64  `json:"d"`
		F    int64  `json:"e"`
	}
	var dc dbCode
	dc.Name = "1111"
	for i := 0; i < b.N; i++ {
		_, _ = Encode(dc)
	}
}
