<commit_before>package main

import (
	"reflect"
	"testing"
)

func TestMove(t *testing.T) {
	s := []rune("aaaaa bbbbb ccccc")
	tests := []struct {
		input int
		want  int
	}{
		{0, 0},
		{1, 1},
		{10, 10},
		{len(s), len(s)},
		{-1, 0},
		{len(s) + 1, len(s)},
	}
	for _, test := range tests {
		e := &basicEditor{buf: s}
		e.move(test.input)
		if e.pos != test.want {
			t.Errorf("move(%v): got %v, want %v", test.input, e.pos, test.want)
		}
	}
}

func TestInsert(t *testing.T) {
	tests := []struct {
		initial basicEditor
		input   []rune
		at      int
		want    basicEditor
	}{
		{
			initial: basicEditor{buf: []rune(""), pos: 0},
			input:   []rune("aaa"),
			at:      0,
			want:    basicEditor{buf: []rune("aaa"), pos: 3},
		},
		{
			initial: basicEditor{buf: []rune("AAA"), pos: 2},
			input:   []rune("aaa"),
			at:      -1,
			want:    basicEditor{buf: []rune("aaaAAA"), pos: 5},
		},
		{
			initial: basicEditor{buf: []rune("AAA"), pos: 1},
			input:   []rune("aaa"),
			at:      2,
			want:    basicEditor{buf: []rune("AAaaaA"), pos: 1},
		},
		{
			initial: basicEditor{buf: []rune("AAA"), pos: 3},
			input:   []rune("aaa"),
			at:      10,
			want:    basicEditor{buf: []rune("AAAaaa"), pos: 6},
		},
		{
			initial: basicEditor{buf: []rune("ABC"), pos: 0},
			input:   []rune("defg"),
			at:      0,
			want:    basicEditor{buf: []rune("defgABC"), pos: 3},
		},
	}
	for _, test := range tests {
		test.initial.insert(test.input, test.at)
		if !reflect.DeepEqual(test.initial, test.want) {
			t.Errorf("insert(%v, %v): got %v, want %v", test.input, test.at, test.initial, test.want)
		}
	}
}

func TestDelete(t *testing.T) {
	tests := []struct {
		initial basicEditor
		from    int
		to      int
		want    basicEditor<commit_msg>Fix test<commit_after>package main

import (
	"reflect"
	"testing"
)

func TestMove(t *testing.T) {
	s := []rune("aaaaa bbbbb ccccc")
	tests := []struct {
		input int
		want  int
	}{
		{0, 0},
		{1, 1},
		{10, 10},
		{len(s), len(s)},
		{-1, 0},
		{len(s) + 1, len(s)},
	}
	for _, test := range tests {
		e := &basicEditor{buf: s}
		e.move(test.input)
		if e.pos != test.want {
			t.Errorf("move(%v): got %v, want %v", test.input, e.pos, test.want)
		}
	}
}

func TestInsert(t *testing.T) {
	tests := []struct {
		initial basicEditor
		input   []rune
		at      int
		want    basicEditor
	}{
		{
			initial: basicEditor{buf: []rune(""), pos: 0},
			input:   []rune("aaa"),
			at:      0,
			want:    basicEditor{buf: []rune("aaa"), pos: 3},
		},
		{
			initial: basicEditor{buf: []rune("AAA"), pos: 2},
			input:   []rune("aaa"),
			at:      -1,
			want:    basicEditor{buf: []rune("aaaAAA"), pos: 5},
		},
		{
			initial: basicEditor{buf: []rune("AAA"), pos: 1},
			input:   []rune("aaa"),
			at:      2,
			want:    basicEditor{buf: []rune("AAaaaA"), pos: 1},
		},
		{
			initial: basicEditor{buf: []rune("AAA"), pos: 3},
			input:   []rune("aaa"),
			at:      10,
			want:    basicEditor{buf: []rune("AAAaaa"), pos: 6},
		},
		{
			initial: basicEditor{buf: []rune("ABC"), pos: 1},
			input:   []rune("defg"),
			at:      1,
			want:    basicEditor{buf: []rune("AdefgBC"), pos: 5},
		},
	}
	for _, test := range tests {
		test.initial.insert(test.input, test.at)
		if !reflect.DeepEqual(test.initial, test.want) {
			t.Errorf("insert(%v, %v): got %v, want %v", test.input, test.at, test.initial, test.want)
		}
	}
}

func TestDelete(t *testing.T) {
	tests := []struct {
		initial basicEditor
		from    int
		to      int
		want    basicEditor
{'fraction_non_alphanumeric': 0.21140074477227155, 'fraction_numerical': 0.015468347178458894, 'mean_word_length': 2.8373626373626375, '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': '2981111', 'n_tokens_mistral': 1642, 'n_tokens_neox': 1422, 'n_words': 330}