<commit_before>package luddite

import "testing"

var errorMessages = map[int]string{
	EcodeUnsupportedMediaType: "Error string override",
	EcodeServiceBase:          "Hello world: %s",
}

func TestNewError(t *testing.T) {
	// Test custom error string lookups
	e := NewError(errorMessages, EcodeServiceBase, "foo") // should resolve to errorMessages
	if e != nil {
		if e.Code != EcodeServiceBase {
			t.Error("error code not set")
		}
		if e.Message != "Hello world: foo" {
			t.Error("error message not set")
		}
	}

	// Test common error string lookups
	e = NewError(errorMessages, EcodeInternal) // should resolve to commonErrorMessages
	if e != nil {
		if e.Code != EcodeInternal {
			t.Error("error code not set")
		}
		if e.Message != commonErrorMessages[EcodeInternal] {
			t.Error("error message not set")
		}
	}

	e = NewError(nil, EcodeInternal) // should resolve to errorMessages
	if e != nil {
		if e.Code != EcodeInternal {
			t.Error("error code not set")
		}
		if e.Message != commonErrorMessages[EcodeInternal] {
			t.Error("error message not set")
		}
	}

	e = NewError(errorMessages, EcodeUnsupportedMediaType) // should resolve to errorMessages
	if e != nil {
		if e.Code != EcodeUnsupportedMediaType {
			t.Error("error code not set")
		}
		if e.Message != errorMessages[EcodeUnsupportedMediaType] {
			t.Error("error message not set")
		}
	}

	// Test failsafe
	e = NewError(errorMessages, EcodeServiceBase+1) // should resolve to commonErrorMessages
	if e != nil {
		if e.Code != EcodeServiceBase+1 {
			t.Error("error code not set")
		}
		if e.Message != commonErrorMessages[EcodeUnknown] {
			t.Error("error message not set")
		}
	}
}<commit_msg>Check for corner cases in unit tests.<commit_after>package luddite

import "testing"

var errorMessages = map[int]string{
	EcodeUnsupportedMediaType: "Error string override",
	EcodeServiceBase:          "Hello world: %s",
}

func TestNewError(t *testing.T) {
	// Test custom error string lookups
	e := NewError(errorMessages, EcodeServiceBase, "foo") // should resolve to errorMessages
	if e != nil {
		if e.Code != EcodeServiceBase {
			t.Error("error code not set")
		}
		if e.Message != "Hello world: foo" {
			t.Error("error message not set")
		}
	} else {
		t.Error("no error returned")
	}

	// Test common error string lookups
	e = NewError(errorMessages, EcodeInternal) // should resolve to commonErrorMessages
	if e != nil {
		if e.Code != EcodeInternal {
			t.Error("error code not set")
		}
		if e.Message != commonErrorMessages[EcodeInternal] {
			t.Error("error message not set")
		}
	} else {
		t.Error("no error returned")
	}

	e = NewError(nil, EcodeInternal) // should resolve to errorMessages
	if e != nil {
		if e.Code != EcodeInternal {
			t.Error("error code not set")
		}
		if e.Message != commonErrorMessages[EcodeInternal] {
			t.Error("error message not set")
		}
	} else {
		t.Error("no error returned")
	}

	e = NewError(errorMessages, EcodeUnsupportedMediaType) // should resolve to errorMessages
	if e != nil {
		if e.Code != EcodeUnsupportedMediaType {
			t.Error("error code not set")
		}
		if e.Message != errorMessages[EcodeUnsupportedMediaType] {
			t.Error("error message not set")
		}
	} else {
		t.Error("no error returned")
	}

	// Test failsafe
	e = NewError(errorMessages, EcodeServiceBase+1) // should resolve to commonErrorMessages
	if e != nil {
		if e.Code != EcodeServiceBase+1 {
			t.Error("error code not set")
		}
		if e.Message != commonErrorMessages[EcodeUnknown] {
			t.Error("error message not set")
		}
	} else {
		t.Error("no error returned")
	}
}
{'fraction_non_alphanumeric': 0.12153458415009802, 'fraction_numerical': 0.0011201344161299357, 'mean_word_length': 3.626943005181347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5724130', 'n_tokens_mistral': 1265, 'n_tokens_neox': 1176, 'n_words': 332}