<commit_before>package pnet

import (
	"bytes"
	"encoding/base64"
	"testing"
)

func bufWithBase(base string, windows bool) *bytes.Buffer {

	b := &bytes.Buffer{}
	b.Write(pathPSKv1)
	if windows {
		b.WriteString("\r")
	}
	b.WriteString("\n")
	b.WriteString(base)
	if windows {
		b.WriteString("\r")
	}
	b.WriteString("\n")
	return b
}

func TestDecodeHex(t *testing.T) {
	testDecodeHex(t, true)
	testDecodeHex(t, false)
}
<commit_msg>Add bad encoding test case<commit_after>package pnet

import (
	"bytes"
	"encoding/base64"
	"testing"
)

func bufWithBase(base string, windows bool) *bytes.Buffer {

	b := &bytes.Buffer{}
	b.Write(pathPSKv1)
	if windows {
		b.WriteString("\r")
	}
	b.WriteString("\n")
	b.WriteString(base)
	if windows {
		b.WriteString("\r")
	}
	b.WriteString("\n")
	return b
}

func TestDecodeHex(t *testing.T) {
	testDecodeHex(t, true)
	testDecodeHex(t, false)
}

func TestDecodeBad(t *testing.T) {
	testDecodeBad(t, true)
	testDecodeBad(t, false)
}
func testDecodeBad(t *testing.T, windows bool) {
	b := bufWithBase("/verybadbase/", windows)
	b.WriteString("Have fun decoding that key")

	_, err := decodeV1PSK(b)
	if err == nil {
		t.Fatal("expected 'unknown encoding' got nil")
	}
}

{'fraction_non_alphanumeric': 0.1583747927031509, 'fraction_numerical': 0.005804311774461028, 'mean_word_length': 4.388392857142857, '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': '5801031', 'n_tokens_mistral': 492, 'n_tokens_neox': 479, 'n_words': 100}