// Copyright (c) 2020 The Decred developers
// Use of this source code is governed by an ISC
// license that can be found in the LICENSE file.

package schnorr

import (
	"testing"
)

// TestErrorKindStringer tests the stringized output for the ErrorKind type.
func TestErrorKindStringer(t *testing.T) {
	tests := []struct {
		in   ErrorKind
		want string
	}{
		{ErrSigTooShort, "ErrSigTooShort"},
		{ErrSigTooLong, "ErrSigTooLong"},
		{ErrSigRTooBig, "ErrSigRTooBig"},
		{ErrSigSTooBig, "ErrSigSTooBig"},
		{ErrSigA1TooBig, "ErrSigA1TooBig"},
		{ErrSigA2TooBig, "ErrSigA2TooBig"},
		{ErrSigZTooBig, "ErrSigZTooBig"},
		{ErrPrivateKeyZero, "ErrPrivateKeyZero"},
		{ErrNotOnCurve, "ErrNotOnCurve"},
		{ErrRInfinity, "ErrRInfinity"},
		{ErrIncorrectR, "ErrIncorrectR"},
	}

	for i, test := range tests {
		result := test.in.Error()
		if result != test.want {
			t.Errorf("#%d: got: %s want: %s", i, result, test.want)
			continue
		}
	}
}

// TestError tests the error output for the Error type.
func TestError(t *testing.T) {
	tests := []struct {
		in   Error
		want string
	}{{
		Error{Description: "some error"},
		"some error",
	}, {
		Error{Description: "human-readable error"},
		"human-readable error",
	}}

	for i, test := range tests {
		result := test.in.Error()
		if result != test.want {
			t.Errorf("#%d: got: %s want: %s", i, result, test.want)
			continue
		}
	}
}
