<commit_before>package embd

import "testing"

func TestPinMapLookup(t *testing.T) {
	var tests = []struct {
		key interface{}
		cap int
		id  string
	}{
		{"10", CapAnalog, "P1_1"},
		{10, CapAnalog, "P1_1"},
		{"10", CapNormal, "P1_2"},
		{"P1_2", CapNormal, "P1_2"},
		{"P1_2", CapAnalog, "P1_2"},
		{"GPIO10", CapNormal, "P1_2"},
	}
	var pinMap = PinMap{
		&PinDesc{ID: "P1_1", Aliases: []string{"AN1", "10"}, Caps: CapAnalog},
		&PinDesc{ID: "P1_2", Aliases: []string{"10", "GPIO10"}, Caps: CapNormal},
	}
	for _, test := range tests {
		pd, found := pinMap.Lookup(test.key, test.cap)
		if !found {
			t.Errorf("Could not find a descriptor for %q", test.key)
			continue
		}
		if pd.ID != test.id {
			var capStr string
			switch test.cap {
			case CapNormal:
				capStr = "CapNormal"
			case CapAnalog:
				capStr = "CapAnalog"
			default:
				t.Fatalf("Unknown cap %v", test.cap)
			}
			t.Errorf("Looking up %q with %v: got %v, want %v", test.key, capStr, pd.ID, test.id)
		}
	}
}
<commit_msg>gpio: test -ve case when looking up pins<commit_after>package embd

import "testing"

func TestPinMapLookup(t *testing.T) {
	var tests = []struct {
		key interface{}
		cap int
		id  string

		found bool
	}{
		{"10", CapAnalog, "P1_1", true},
		{10, CapAnalog, "P1_1", true},
		{"10", CapNormal, "P1_2", true},
		{"P1_2", CapNormal, "P1_2", true},
		{"P1_2", CapAnalog, "P1_2", true},
		{"GPIO10", CapNormal, "P1_2", true},
		{key: "NOTTHERE", found: false},
	}
	var pinMap = PinMap{
		&PinDesc{ID: "P1_1", Aliases: []string{"AN1", "10"}, Caps: CapAnalog},
		&PinDesc{ID: "P1_2", Aliases: []string{"10", "GPIO10"}, Caps: CapNormal},
	}
	for _, test := range tests {
		pd, found := pinMap.Lookup(test.key, test.cap)
		if found != test.found {
			t.Errorf("Outcome mismatch for %v: got found = %v, expected found = %v", test.key, found, test.found)
			continue
		}
		if !found {
			continue
		}
		if pd.ID != test.id {
			var capStr string
			switch test.cap {
			case CapNormal:
				capStr = "CapNormal"
			case CapAnalog:
				capStr = "CapAnalog"
			default:
				t.Fatalf("Unknown cap %v", test.cap)
			}
			t.Errorf("Looking up %q with %v: got %v, want %v", test.key, capStr, pd.ID, test.id)
		}
	}
}

{'fraction_non_alphanumeric': 0.1807447774750227, 'fraction_numerical': 0.03178928247048138, 'mean_word_length': 3.4685598377281948, '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': '3979668', 'n_tokens_mistral': 1010, 'n_tokens_neox': 900, 'n_words': 236}