<commit_before>package prob_test

import (
	"math/big"
	"testing"

	"github.com/brnstz/prob"
)

type test struct {
	n      int64
	k      int64
	result string
}

func TestReplaceOrdered(t *testing.T) {
	// tests is a list to run with the expectation that
	// prob.ReplaceOrdered(n, k) == result (where n and k are converted to
	// big.Int values and the result is tested as a base10 string)
	tests := []test{
		{5, 4, "625"},
		{10, 2, "100"},
		{0, 21, "0"},
	}

	// Go through each test
	for _, test := range tests {

		// Get the result as a base10 string
		actual := prob.ReplaceOrdered(
			big.NewInt(test.n), big.NewInt(test.k),
		).Text(10)

		// Check result matches or signal fatal error
		if actual != test.result {
			t.Fatalf("expected prob.ReplaceOrdered(%d, %d) == %v but got %v",
				test.n, test.k, test.result, actual,
			)
		}
	}
}

func TestNoReplaceOrdered(t *testing.T) {
	// tests is a list to run with the expectation that
	// prob.NoReplaceOrdered(n, k) == result (where n and k are converted to
	// big.Int values and the result is tested as a base10 string)
	tests := []test{
		{100, 3, "970200"},
		{5, 6, "0"},
	}

	// Go through each test
	for _, test := range tests {

		// Get the result as a base10 string
		actual := prob.NoReplaceOrdered(
			big.NewInt(test.n), big.NewInt(test.k),
		).Text(10)

		// Check result matches or signal fatal error
		if actual != test.result {
			t.Fatalf("expected prob.NoReplaceOrdered(%d, %d) == %v but got %v",
				test.n, test.k, test.result, actual,
			)
		}
	}
}

func TestNoReplaceUnordered(t *testing.T) {
<commit_msg>generic-ize running tests for similar functions<commit_after>package prob_test

import (
	"math/big"
	"testing"

	"github.com/brnstz/prob"
)

type test struct {
	n      int64
	k      int64
	result string
}

type Tester func(n, k *big.Int) *big.Int

func runTests(t *testing.T, tests []test, tester Tester, name string) {
	for _, test := range tests {
		// Get the result as a base10 string
		actual := tester(
			big.NewInt(test.n), big.NewInt(test.k),
		).Text(10)

		// Check result matches or signal fatal error
		if actual != test.result {
			t.Fatalf("expected %s(%d, %d) == %v but got %v",
				name, test.n, test.k, test.result, actual,
			)
		}
	}
}

func TestReplaceOrdered(t *testing.T) {
	// tests is a list to run with the expectation that
	// prob.ReplaceOrdered(n, k) == result (where n and k are converted to
	// big.Int values and the result is tested as a base10 string)
	tests := []test{
		{5, 4, "625"},
		{10, 2, "100"},
		{0, 21, "0"},
	}

	runTests(t, tests, prob.ReplaceOrdered, "prob.ReplaceOrdered")
}

func TestNoReplaceOrdered(t *testing.T) {
	// tests is a list to run with the expectation that
	// prob.NoReplaceOrdered(n, k) == result (where n and k are converted to
	// big.Int values and the result is tested as a base10 string)
	tests := []test{
		{100, 3, "970200"},
		{5, 6, "0"},
	}

	runTests(t, tests, prob.NoReplaceOrdered, "prob.NoReplaceOrdered")
}

func TestNoReplaceUnordered(t *testing.T) {

{'fraction_non_alphanumeric': 0.14158121071782998, 'fraction_numerical': 0.027786966589480648, 'mean_word_length': 3.1710344827586208, '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': '6760982', 'n_tokens_mistral': 1207, 'n_tokens_neox': 1093, 'n_words': 358}