package passwordhash

import "testing"

func TestHashVerifyAndCost(t *testing.T) {
	hash, err := Hash("correct horse battery staple")
	if err != nil {
		t.Fatal(err)
	}
	if !Verify("correct horse battery staple", hash) || Verify("wrong", hash) {
		t.Fatal("password verification did not preserve exact semantics")
	}
	if err := ValidateCost(hash); err != nil {
		t.Fatal(err)
	}
	if err := ValidateCost("not-a-hash"); err == nil {
		t.Fatal("malformed hash passed cost validation")
	}
}
