<commit_before>package passhash

import (
	"errors"
	"testing"
)

func TestPasswordPoliciesNotMetDuplicateErrors(t *testing.T) {
	err := PasswordPoliciesNotMet{UnMetPasswordPolicies: []PasswordPolicyError{
		PasswordPolicyError{AtLeastNRunes{}, errors.New("Dummy error 1")},
		PasswordPolicyError{AtLeastNRunes{}, errors.New("Dummy error 2")},
	}}
	expectedError := "Password policies not met due to: Dummy error 1, Dummy error 2"
	if err.Error() != expectedError {
		t.Errorf("PasswordPoliciesNotMet.Error() did not properly handle duplicate PasswordPolicyErrors. %s != %s", err.Error(), expectedError)
	}
}

func TestAtLeastNRunesTooShort(t *testing.T) {
	pp := AtLeastNRunes{N: 5}
	if err := pp.PasswordAcceptable("<PASSWORD>"); err == nil {
		t.Errorf("Password that's too short was accepted")
	}
}

func TestAtLeastNRunesExact(t *testing.T) {
	pp := AtLeastNRunes{N: 5}
	if err := pp.PasswordAcceptable("<PASSWORD>"); err != nil {
		t.Errorf("Password that's exactly long enough was rejected")
	}
}

func TestAtLeastNRunesEnough(t *testing.T) {
	pp := AtLeastNRunes{N: 5}
	if err := pp.PasswordAcceptable("<PASSWORD>"); err != nil {
		t.Errorf("Password that's long enough was rejected")
	}
}

func TestNotCommonPasswordNaiveAccepted(t *testing.T) {
	pp := NotCommonPasswordNaive{CommonPasswords: map[string]bool{
		"foo": true,
		"bar": true,
	}}
	if err := pp.PasswordAcceptable("<PASSWORD>"); err != nil {
		t.Errorf("Password that's not common was rejected")
	}
}

func TestNotCommonPasswordNaiveRejected(t *testing.T) {
	pp := NotCommonPasswordNaive{CommonPasswords: map[string]bool{
		"foo": true,
		"bar": true,
	}}
	if err := pp.PasswordAcceptable("foo"); err == nil {
		t.Errorf("Password that's common was accepted")
	}
}
<commit_msg>Ran "gofmt -s -w *.go"<commit_after>package passhash

import (
	"errors"
	"testing"
)

func TestPasswordPoliciesNotMetDuplicateErrors(t *testing.T) {
	err := PasswordPoliciesNotMet{UnMetPasswordPolicies: []PasswordPolicyError{
		{AtLeastNRunes{}, errors.New("Dummy error 1")},
		{AtLeastNRunes{}, errors.New("Dummy error 2")},
	}}
	expectedError := "Password policies not met due to: Dummy error 1, Dummy error 2"
	if err.Error() != expectedError {
		t.Errorf("PasswordPoliciesNotMet.Error() did not properly handle duplicate PasswordPolicyErrors. %s != %s", err.Error(), expectedError)
	}
}

func TestAtLeastNRunesTooShort(t *testing.T) {
	pp := AtLeastNRunes{N: 5}
	if err := pp.PasswordAcceptable("<PASSWORD>"); err == nil {
		t.Errorf("Password that's too short was accepted")
	}
}

func TestAtLeastNRunesExact(t *testing.T) {
	pp := AtLeastNRunes{N: 5}
	if err := pp.PasswordAcceptable("<PASSWORD>"); err != nil {
		t.Errorf("Password that's exactly long enough was rejected")
	}
}

func TestAtLeastNRunesEnough(t *testing.T) {
	pp := AtLeastNRunes{N: 5}
	if err := pp.PasswordAcceptable("123456"); err != nil {
		t.Errorf("Password that's long enough was rejected")
	}
}

func TestNotCommonPasswordNaiveAccepted(t *testing.T) {
	pp := NotCommonPasswordNaive{CommonPasswords: map[string]bool{
		"foo": true,
		"bar": true,
	}}
	if err := pp.PasswordAcceptable("<PASSWORD>"); err != nil {
		t.Errorf("Password that's not common was rejected")
	}
}

func TestNotCommonPasswordNaiveRejected(t *testing.T) {
	pp := NotCommonPasswordNaive{CommonPasswords: map[string]bool{
		"foo": true,
		"bar": true,
	}}
	if err := pp.PasswordAcceptable("foo"); err == nil {
		t.Errorf("Password that's common was accepted")
	}
}

{'fraction_non_alphanumeric': 0.14776334776334776, 'fraction_numerical': 0.005772005772005772, 'mean_word_length': 5.442379182156134, 'pattern_counts': {'":': 8, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6507397', 'n_tokens_mistral': 1261, 'n_tokens_neox': 1193, 'n_words': 282}