<commit_before>//
// Blackfriday Markdown Processor
// Available at http://github.com/russross/blackfriday
//
// Copyright © 2011 <NAME> <<EMAIL>>.
// Distributed under the Simplified BSD License.
// See README.md for details.
//

//
// Markdown 1.0.3 reference tests
//

package blackfriday

import (
	"io/ioutil"
	"path/filepath"
	"testing"
)

func runMarkdownReference(input string, flag int) string {
	renderer := HtmlRenderer(0, "", "")
	return string(Markdown([]byte(input), renderer, flag))
}

func doTestsReference(t *testing.T, files []string, flag int) {
	// catch and report panics
	var candidate string
	defer func() {
		if err := recover(); err != nil {
			t.Errorf("\npanic while processing [%#v]\n", candidate)
		}
	}()

	for _, basename := range files {
		filename := filepath.Join("upskirtref", basename+".text")
		inputBytes, err := ioutil.ReadFile(filename)
		if err != nil {
			t.Errorf("Couldn't open '%s', error: %v\n", filename, err)
			continue
		}
		input := string(inputBytes)

		filename = filepath.Join("upskirtref", basename+".html")
		expectedBytes, err := ioutil.ReadFile(filename)
		if err != nil {
			t.Errorf("Couldn't open '%s', error: %v\n", filename, err)
			continue
		}
		expected := string(expectedBytes)

		// fmt.Fprintf(os.Stderr, "processing %s ...", filename)
		actual := string(runMarkdownReference(input, flag))
		if actual != expected {
			t.Errorf("\n    [%#v]\nExpected[%#v]\nActual  [%#v]",
				basename+".text", expected, actual)
		}
		// fmt.Fprintf(os.Stderr, " ok\n")

		// now test every prefix of every input to check for
		// bounds checking
		if !testing.Short() {
			start, max := 0, len(input)
			for end := start + 1; end <= max; end++ {
				candidate = input[start:end]
				// fmt.Fprintf(os.Stderr, "  %s %d:%d/%d\n", filename, start, end, max)
				_ = runMarkdownReference(candidate, flag)
			}
		}
	}
}

func TestReference(t *testing.T) {
	files := []string{
		"Amps and angle encoding",<commit_msg>changed upskirtref to display the input given when running it's tests<commit_after>//
// Blackfriday Markdown Processor
// Available at http://github.com/russross/blackfriday
//
// Copyright © 2011 <NAME> <<EMAIL>>.
// Distributed under the Simplified BSD License.
// See README.md for details.
//

//
// Markdown 1.0.3 reference tests
//

package blackfriday

import (
	"io/ioutil"
	"path/filepath"
	"testing"
)

func runMarkdownReference(input string, flag int) string {
	renderer := HtmlRenderer(0, "", "")
	return string(Markdown([]byte(input), renderer, flag))
}

func doTestsReference(t *testing.T, files []string, flag int) {
	// catch and report panics
	var candidate string
	defer func() {
		if err := recover(); err != nil {
			t.Errorf("\npanic while processing [%#v]\n", candidate)
		}
	}()

	for _, basename := range files {
		filename := filepath.Join("upskirtref", basename+".text")
		inputBytes, err := ioutil.ReadFile(filename)
		if err != nil {
			t.Errorf("Couldn't open '%s', error: %v\n", filename, err)
			continue
		}
		input := string(inputBytes)

		filename = filepath.Join("upskirtref", basename+".html")
		expectedBytes, err := ioutil.ReadFile(filename)
		if err != nil {
			t.Errorf("Couldn't open '%s', error: %v\n", filename, err)
			continue
		}
		expected := string(expectedBytes)

		// fmt.Fprintf(os.Stderr, "processing %s ...", filename)
		actual := string(runMarkdownReference(input, flag))
		if actual != expected {
			t.Errorf("\n    [%#v]\nInput [%#v]\nExpected [%#v]\nActual [%#v]",
				basename+".text", expected, actual)
		}
		// fmt.Fprintf(os.Stderr, " ok\n")

		// now test every prefix of every input to check for
		// bounds checking
		if !testing.Short() {
			start, max := 0, len(input)
			for end := start + 1; end <= max; end++ {
				candidate = input[start:end]
				// fmt.Fprintf(os.Stderr, "  %s %d:%d/%d\n", filename, start, end, max)
				_ = runMarkdownReference(candidate, flag)
			}
		}
	}
}

func TestReference(t *testing.T) {
	files := []string{
		"Amps and angle encoding",
{'fraction_non_alphanumeric': 0.16854213553388347, 'fraction_numerical': 0.005001250312578144, 'mean_word_length': 3.5300113250283127, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '1831281', 'n_tokens_mistral': 1514, 'n_tokens_neox': 1382, 'n_words': 361}