{{if .IsG2 -}}
//go:build g2

{{end -}}
package {{.PackageName}}

import (
	"github.com/stretchr/testify/assert"
	"testing"
)

func Test{{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}AffineZero(t *testing.T) {
	var fieldZero = {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}Base{{end}}Field{}

	var affineZero {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}Affine
	assert.Equal(t, affineZero.X, fieldZero)
	assert.Equal(t, affineZero.Y, fieldZero)

	x := generateRandomLimb(int({{if .IsG2}}G2_{{end}}BASE_LIMBS))
	y := generateRandomLimb(int({{if .IsG2}}G2_{{end}}BASE_LIMBS))
	var affine {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}Affine
	affine.FromLimbs(x, y)

	affine.Zero()
	assert.Equal(t, affine.X, fieldZero)
	assert.Equal(t, affine.Y, fieldZero)
}

func Test{{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}AffineFromLimbs(t *testing.T) {
	randLimbs := generateRandomLimb(int({{if .IsG2}}G2_{{end}}BASE_LIMBS))
	randLimbs2 := generateRandomLimb(int({{if .IsG2}}G2_{{end}}BASE_LIMBS))

	var affine {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}Affine
	affine.FromLimbs(randLimbs, randLimbs2)

	assert.ElementsMatch(t, randLimbs, affine.X.GetLimbs())
	assert.ElementsMatch(t, randLimbs2, affine.Y.GetLimbs())
}

func Test{{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}AffineToProjective(t *testing.T) {
	randLimbs := generateRandomLimb(int({{if .IsG2}}G2_{{end}}BASE_LIMBS))
	randLimbs2 := generateRandomLimb(int({{if .IsG2}}G2_{{end}}BASE_LIMBS))
	var fieldOne {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}Base{{end}}Field
	fieldOne.One()

	var expected {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}Projective
	expected.FromLimbs(randLimbs, randLimbs2, fieldOne.limbs[:])

	var affine {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}Affine
	affine.FromLimbs(randLimbs, randLimbs2)

	projectivePoint := affine.ToProjective()
	assert.Equal(t, expected, projectivePoint)
}

func Test{{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}ProjectiveZero(t *testing.T) {
	var projectiveZero {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}Projective
	projectiveZero.Zero()
	var fieldZero = {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}Base{{end}}Field{}
	var fieldOne {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}Base{{end}}Field
	fieldOne.One()

	assert.Equal(t, projectiveZero.X, fieldZero)
	assert.Equal(t, projectiveZero.Y, fieldOne)
	assert.Equal(t, projectiveZero.Z, fieldZero)

	randLimbs := generateRandomLimb(int({{if .IsG2}}G2_{{end}}BASE_LIMBS))
	var projective {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}Projective
	projective.FromLimbs(randLimbs, randLimbs, randLimbs)

	projective.Zero()
	assert.Equal(t, projective.X, fieldZero)
	assert.Equal(t, projective.Y, fieldOne)
	assert.Equal(t, projective.Z, fieldZero)
}

func Test{{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}ProjectiveFromLimbs(t *testing.T) {
	randLimbs := generateRandomLimb(int({{if .IsG2}}G2_{{end}}BASE_LIMBS))
	randLimbs2 := generateRandomLimb(int({{if .IsG2}}G2_{{end}}BASE_LIMBS))
	randLimbs3 := generateRandomLimb(int({{if .IsG2}}G2_{{end}}BASE_LIMBS))

	var projective {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}Projective
	projective.FromLimbs(randLimbs, randLimbs2, randLimbs3)

	assert.ElementsMatch(t, randLimbs, projective.X.GetLimbs())
	assert.ElementsMatch(t, randLimbs2, projective.Y.GetLimbs())
	assert.ElementsMatch(t, randLimbs3, projective.Z.GetLimbs())
}

func Test{{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}ProjectiveFromAffine(t *testing.T) {
	randLimbs := generateRandomLimb(int({{if .IsG2}}G2_{{end}}BASE_LIMBS))
	randLimbs2 := generateRandomLimb(int({{if .IsG2}}G2_{{end}}BASE_LIMBS))
	var fieldOne {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}Base{{end}}Field
	fieldOne.One()

	var expected {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}Projective
	expected.FromLimbs(randLimbs, randLimbs2, fieldOne.limbs[:])

	var affine {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}Affine
	affine.FromLimbs(randLimbs, randLimbs2)

	var projectivePoint {{if .IsMock}}Mock{{else}}{{if .IsG2}}G2{{end}}{{end}}Projective
	projectivePoint.FromAffine(affine)
	assert.Equal(t, expected, projectivePoint)
}
