<commit_before>package indexing

import (
  "bytes"
  "testing"
)

var testWrites = []struct {
  docs []Document
  out string
}{
  {[]Document{},
    // Header | End of Docs
    "searchme\x00\x00"}, // terminator + doc terminator
  {[]Document{{"path", "content"}},
    // Header | Doc paths + Terminator | term + terminator + doc id (0)
    "searchme\x00path\x00\x00content\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"},
}

func TestWrite(t *testing.T) {
  for _, testCase := range testWrites {
    i := NewIndex()
    buf := new(bytes.Buffer)
    for _, doc := range testCase.docs {
      i.Add(doc)
    }
    i.Write(buf)

    result := string(buf.Bytes())
    if testCase.out != result {
      t.Fatalf("Expected: %q Actual %q", testCase.out, result)
    }
  }
}

<commit_msg>Add test number to assertion<commit_after>package indexing

import (
  "bytes"
  "testing"
)

var testWrites = []struct {
  docs []Document
  out string
}{
  {[]Document{},
    // Header | End of Docs
    "searchme\x00\x00"}, // terminator + doc terminator
  {[]Document{{"path", "content"}},
    // Header | Doc paths + Terminator | term + terminator + doc id (0)
    "searchme\x00path\x00\x00content\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00"},
}

func TestWrite(t *testing.T) {
  for testNum, testCase := range testWrites {
    i := NewIndex()
    buf := new(bytes.Buffer)
    for _, doc := range testCase.docs {
      i.Add(doc)
    }
    i.Write(buf)

    result := string(buf.Bytes())
    if testCase.out != result {
      t.Fatalf("%d. Expected: %q Actual %q", testNum, testCase.out, result)
    }
  }
}


{'fraction_non_alphanumeric': 0.16582597730138715, 'fraction_numerical': 0.03909205548549811, 'mean_word_length': 2.8149038461538463, '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': '2605244', 'n_tokens_mistral': 628, 'n_tokens_neox': 591, 'n_words': 129}