<commit_before>package parth

import (
	"fmt"
	"reflect"
	"testing"
)

func TestBhvrSegment(t *testing.T) {
	path := "/junk/4/key/true/other/3.3/"
	key := ""

	t.Run("bool", applyToBoolTFunc(path, key, pti(3), true))
	t.Run("float32", applyToFloat32TFunc(path, key, pti(5), 3.3))
	t.Run("float64", applyToFloat64TFunc(path, key, pti(5), 3.3))
	t.Run("int", applyToIntTFunc(path, key, pti(1), 4))
	t.Run("int16", applyToInt16TFunc(path, key, pti(1), 4))
	t.Run("int32", applyToInt32TFunc(path, key, pti(1), 4))
	t.Run("int64", applyToInt64TFunc(path, key, pti(1), 4))
	t.Run("int8", applyToInt8TFunc(path, key, pti(1), 4))
	t.Run("string", applyToStringTFunc(path, key, pti(0), "junk"))
	t.Run("uint", applyToUintTFunc(path, key, pti(-1), 3))
	t.Run("uint16", applyToUint16TFunc(path, key, pti(-1), 3))
	t.Run("uint32", applyToUint32TFunc(path, key, pti(-1), 3))
	t.Run("uint64", applyToUint64TFunc(path, key, pti(-1), 3))
	t.Run("uint8", applyToUint8TFunc(path, key, pti(-1), 3))
	t.Run("unmarsaler", applyToUnmarshalerTFunc(path, key, pti(2), []byte("key")))

	t.Run("badType", func(t *testing.T) {
		var x uintptr
		err := Segment(path, 3, &x)
		exp(t, t.Name(), err)
	})
}

func TestBhvrSequent(t *testing.T) {
	path := "/junk/4/key/true/other/3.3/"
	var i *int

	t.Run("bool", applyToBoolTFunc(path, "key", i, true))
	t.Run("float32", applyToFloat32TFunc(path, "other", i, 3.3))
	t.Run("float64", applyToFloat64TFunc(path, "other", i, 3.3))
	t.Run("int", applyToIntTFunc(path, "junk", i, 4))
	t.Run("int16", applyToInt16TFunc(path, "junk", i, 4))
	t.Run("int32", applyToInt32TFunc(path, "junk", i, 4))
	t.Run("int64", applyToInt64TFunc(path, "junk", i, 4))
	t.Run("int8", applyToInt8TFunc(path, "junk", i, 4))
	t.Run("string", applyToStringTFunc(path, "key", i, "true"))
	t.Run("uint", applyToUintTFunc(path, "junk", i, 4))
	t.Run("uint16", applyToUint16TFunc(path, "junk", i, 4))
	t.Run("uint32", applyToUint32TFunc(path, "junk", i, 4))
	t.Run("uint64", applyToUint64TFunc(path, "junk", i, 4))
	t.Run("uint8", applyToUint8TFunc(path, "junk", i, 4))
	t.Run("unmarsaler", applyToUnmarshalerTFunc(path, "key", i, []byte("true")))

	t.Run("badType", func(t *testing.T) {
		var x uintptr
		err := Sequent(path, "key", &x)
		exp(t, t.Name(), err)
	})
}

func TestBhvrSpan(t *testing.T) {
	path := "/zero/one/two/three/four"

	tests := []struct {
		name string
		path string
		i, j int
		want string
		ck   checkFunc
	}{
		{"5 segs: +1,+3", path, 1, 3, "/one/two", unx},
		{"5 segs: +1,-2", path, 1, -2, "/one/two", unx},
		{"5 segs: +1,00", path, 1, 0, "/one/two/three/four", unx},
		{"5 segs: -3,-1", path, -3, -1, "/two/three", unx},
		{"5 segs: -3,00", path, -3, 0, "/two/three/four", unx},
		{"5 segs: -9,00", path, -9, 0, "", exp},
		{"5 segs: 00,+9", path, 0, 9, "", exp},
	}

	for _, tt := range tests {
		got, err := Span(tt.path, tt.i, tt.j)
		if tt.ck(t, tt.name, err) {
			continue
		}

		if got != tt.want {
			t.Errorf(gwxFmt, tt.name, got, tt.want)<commit_msg>Add span test without first slash.<commit_after>package parth

import (
	"fmt"
	"reflect"
	"testing"
)

func TestBhvrSegment(t *testing.T) {
	path := "/junk/4/key/true/other/3.3/"
	key := ""

	t.Run("bool", applyToBoolTFunc(path, key, pti(3), true))
	t.Run("float32", applyToFloat32TFunc(path, key, pti(5), 3.3))
	t.Run("float64", applyToFloat64TFunc(path, key, pti(5), 3.3))
	t.Run("int", applyToIntTFunc(path, key, pti(1), 4))
	t.Run("int16", applyToInt16TFunc(path, key, pti(1), 4))
	t.Run("int32", applyToInt32TFunc(path, key, pti(1), 4))
	t.Run("int64", applyToInt64TFunc(path, key, pti(1), 4))
	t.Run("int8", applyToInt8TFunc(path, key, pti(1), 4))
	t.Run("string", applyToStringTFunc(path, key, pti(0), "junk"))
	t.Run("uint", applyToUintTFunc(path, key, pti(-1), 3))
	t.Run("uint16", applyToUint16TFunc(path, key, pti(-1), 3))
	t.Run("uint32", applyToUint32TFunc(path, key, pti(-1), 3))
	t.Run("uint64", applyToUint64TFunc(path, key, pti(-1), 3))
	t.Run("uint8", applyToUint8TFunc(path, key, pti(-1), 3))
	t.Run("unmarsaler", applyToUnmarshalerTFunc(path, key, pti(2), []byte("key")))

	t.Run("badType", func(t *testing.T) {
		var x uintptr
		err := Segment(path, 3, &x)
		exp(t, t.Name(), err)
	})
}

func TestBhvrSequent(t *testing.T) {
	path := "/junk/4/key/true/other/3.3/"
	var i *int

	t.Run("bool", applyToBoolTFunc(path, "key", i, true))
	t.Run("float32", applyToFloat32TFunc(path, "other", i, 3.3))
	t.Run("float64", applyToFloat64TFunc(path, "other", i, 3.3))
	t.Run("int", applyToIntTFunc(path, "junk", i, 4))
	t.Run("int16", applyToInt16TFunc(path, "junk", i, 4))
	t.Run("int32", applyToInt32TFunc(path, "junk", i, 4))
	t.Run("int64", applyToInt64TFunc(path, "junk", i, 4))
	t.Run("int8", applyToInt8TFunc(path, "junk", i, 4))
	t.Run("string", applyToStringTFunc(path, "key", i, "true"))
	t.Run("uint", applyToUintTFunc(path, "junk", i, 4))
	t.Run("uint16", applyToUint16TFunc(path, "junk", i, 4))
	t.Run("uint32", applyToUint32TFunc(path, "junk", i, 4))
	t.Run("uint64", applyToUint64TFunc(path, "junk", i, 4))
	t.Run("uint8", applyToUint8TFunc(path, "junk", i, 4))
	t.Run("unmarsaler", applyToUnmarshalerTFunc(path, "key", i, []byte("true")))

	t.Run("badType", func(t *testing.T) {
		var x uintptr
		err := Sequent(path, "key", &x)
		exp(t, t.Name(), err)
	})
}

func TestBhvrSpan(t *testing.T) {
	path := "/zero/one/two/three/four"

	tests := []struct {
		name string
		path string
		i, j int
		want string
		ck   checkFunc
	}{
		{"5 segs: +1,+3", path, 1, 3, "/one/two", unx},
		{"5 segs: +1,-2", path, 1, -2, "/one/two", unx},
		{"5 segs: +1,00", path, 1, 0, "/one/two/three/four", unx},
		{"5 segs: -3,-1", path, -3, -1, "/two/three", unx},
		{"5 segs: -3,00", path, -3, 0, "/two/three/four", unx},
		{"5 segs: -9,00", path, -9, 0, "", exp},
		{"5 segs: 00,+9", path, 0, 9, "", exp},
		{"3 no /: 00,+9", "zero/one/two", 0, 2, "zero/one", unx},
	}

	for _, tt := range tests {
		got, err := Span(tt.path, tt.i, tt.j)
		if tt.ck(t, tt.name, err) {
			continue
		}

		if got != tt.want {
			t.Errorf(gwxFmt, tt.name, got, tt.want)
{'fraction_non_alphanumeric': 0.23726563796250208, 'fraction_numerical': 0.05442176870748299, 'mean_word_length': 4.5711645101663585, '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': '3044011', 'n_tokens_mistral': 2965, 'n_tokens_neox': 2738, 'n_words': 590}