<commit_before>package metafile

import (
	"bytes"
	"testing"
)

func TestEncode(t *testing.T) {
	var buf bytes.Buffer
	n, err := Encode(&buf, "abc")
	if err != nil {
		t.Errorf("Error encoding: %s", err)
	}

	if n != len(MediaWarning)+4 {
		t.Errorf("wrong number of written bytes")
	}

	header := make([]byte, len(MediaWarning))
	buf.Read(header)

	if head := string(header); head != string(MediaWarning) {
		t.Errorf("Media warning not read:\n", head)
	}

	shabytes := make([]byte, 3)
	buf.Read(shabytes)

	if sha := string(shabytes); sha != "abc" {
		t.Errorf("Invalid sha: %#v", sha)
	}
}

func TestDecode(t *testing.T) {
	buf := bytes.NewBufferString("# git-media\nabc\n")
	if sha, _ := Decode(buf); sha != "abc" {
		t.Errorf("Invalid SHA: %#v", sha)
	}
}

func TestDecodeExternal(t *testing.T) {
	buf := bytes.NewBufferString("# external\nabc\n")
	if sha, _ := Decode(buf); sha != "abc" {
		t.Errorf("Invalid SHA: %#v", sha)
	}<commit_msg>Missing formatting directive in error message<commit_after>package metafile

import (
	"bytes"
	"testing"
)

func TestEncode(t *testing.T) {
	var buf bytes.Buffer
	n, err := Encode(&buf, "abc")
	if err != nil {
		t.Errorf("Error encoding: %s", err)
	}

	if n != len(MediaWarning)+4 {
		t.Errorf("wrong number of written bytes")
	}

	header := make([]byte, len(MediaWarning))
	buf.Read(header)

	if head := string(header); head != string(MediaWarning) {
		t.Errorf("Media warning not read: %s\n", head)
	}

	shabytes := make([]byte, 3)
	buf.Read(shabytes)

	if sha := string(shabytes); sha != "abc" {
		t.Errorf("Invalid sha: %#v", sha)
	}
}

func TestDecode(t *testing.T) {
	buf := bytes.NewBufferString("# git-media\nabc\n")
	if sha, _ := Decode(buf); sha != "abc" {
		t.Errorf("Invalid SHA: %#v", sha)
	}
}

func TestDecodeExternal(t *testing.T) {
	buf := bytes.NewBufferString("# external\nabc\n")
	if sha, _ := Decode(buf); sha != "abc" {
		t.Errorf("Invalid SHA: %#v", sha)
	}
{'fraction_non_alphanumeric': 0.19148936170212766, 'fraction_numerical': 0.0020757654385054488, 'mean_word_length': 4.114058355437666, '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': '3069008', 'n_tokens_mistral': 765, 'n_tokens_neox': 737, 'n_words': 180}