package benchlab

import (
	"strings"
	"testing"
)

func TestBuild(t *testing.T) {
	for _, parts := range [][]string{nil, {""}, {"a", "中", "42"}, {"a", "b", "c"}} {
		if got, want := Build(parts), strings.Join(parts, ""); got != want {
			t.Fatalf("got %q want %q", got, want)
		}
	}
}
func BenchmarkBuild(b *testing.B) {
	parts := make([]string, 128)
	for i := range parts {
		parts[i] = "go中"
	}
	b.ReportAllocs()
	b.SetBytes(int64(len(parts) * len(parts[0])))
	for b.Loop() {
		_ = Build(parts)
	}
}
func square(x uint64) uint64 { return x * x }
func BenchmarkElided(b *testing.B) {
	for i := 0; i < b.N; i++ {
		_ = square(uint64(i))
	}
}
func BenchmarkKept(b *testing.B) {
	x := uint64(17)
	for b.Loop() {
		x = square(x + 1)
	}
}
