Esempio n. 1
0
func testFile(basename string) bool {
	fn := filepath.Join(testFilesDir, basename+".text")
	src, err := ioutil.ReadFile(fn)
	if err != nil {
		fmt.Printf("Couldn't open '%s', error: %v\n", fn, err)
		return false
	}
	//fmt.Printf("Testing: %s\n", fn)
	fn = filepath.Join(testFilesDir, basename+"_upskirt_ref.html")
	ref, err := ioutil.ReadFile(fn)
	if err != nil {
		fmt.Printf("Couldn't open '%s', error: %v\n", fn, err)
		return false
	}
	totalTested++
	html := clean(string(markup.MarkdownToHtml(src, 0, 0)))
	htmlref := clean(string(ref))
	if html != htmlref {
		fmt.Printf("Fail: '%s'\n", basename)
		failed++

		fmt.Printf("exp %d:\n", len(htmlref))
		pprint(htmlref)
		fmt.Printf("\n")

		fmt.Printf("got %d:\n", len(html))
		pprint(html)
		fmt.Printf("\n\n")
		return false
	}
	//fmt.Printf("Ok: '%s'\n", basename)
	return true
}
Esempio n. 2
0
func testCrashFile(basename string) {
	fn := filepath.Join(testFilesDir, basename+".text")
	src, err := ioutil.ReadFile(fn)
	if err != nil {
		fmt.Printf("Couldn't open '%s', error: %v\n", fn, err)
		return
	}
	//fmt.Printf("Testing: %s\n", fn)
	html := clean(string(markup.MarkdownToHtml(src, 0, 0)))
	//fmt.Printf("got %d:\n", len(html))
	pprint(html)
}
Esempio n. 3
0
func main() {
	// this is the largest 27k file that I have
	fn := filepath.Join("testfiles", "Markdown Documentation - Syntax.text")
	d, err := ioutil.ReadFile(fn)
	if err != nil {
		fmt.Printf("Couldn't open '%s', error: %v\n", fn, err)
		os.Exit(1)
	}

	var start, end, dur, minDur int64

	minDur = 1e9
	for j := 0; j < ITER2; j++ {
		start = time.Nanoseconds()
		for i := 0; i < ITER; i++ {
			markup.MarkdownToHtml(d, 0, 0)
		}
		end = time.Nanoseconds()
		dur = (end - start) / 10e6
		if dur < minDur {
			minDur = dur
		}
	}
	fmt.Printf("Converting, no extensions : %v ms\n", minDur)

	minDur = 1e9
	for j := 0; j < ITER2; j++ {
		start = time.Nanoseconds()
		for i := 0; i < ITER; i++ {
			markup.MarkdownToHtml(d, 0, 0xff)
		}
		end = time.Nanoseconds()
		dur = (end - start) / 10e6
		if dur < minDur {
			minDur = dur
		}
	}
	fmt.Printf("Converting, all extensions: %v ms\n", minDur)

}
Esempio n. 4
0
func testStr(s string) {
	html := markup.MarkdownToHtml([]byte(s), 0, 0)
	pprint(s)
	pprint(string(html))
}