~dricottone/image2ascii

d721f2b43dc2d14843dab6b5001accccc779675e — qeesung 6 years ago 16344aa
add convert examples
1 files changed, 18 insertions(+), 3 deletions(-)

M convert/convert_test.go
M convert/convert_test.go => convert/convert_test.go +18 -3
@@ 1,6 1,7 @@
package convert

import (
	"fmt"
	"github.com/stretchr/testify/assert"
	"reflect"
	"testing"


@@ 93,7 94,6 @@ func TestImageFile2ASCIIString(t *testing.T) {
	}
}


// BenchmarkBigImage2ASCIIMatrix benchmark convert big image to ascii
func BenchmarkBigImage2ASCIIMatrix(b *testing.B) {
	convertOptions := DefaultOptions


@@ 102,7 102,7 @@ func BenchmarkBigImage2ASCIIMatrix(b *testing.B) {
	convertOptions.ExpectedWidth = 200
	convertOptions.ExpectedHeight = 200

	for i:=0; i< b.N; i++ {
	for i := 0; i < b.N; i++ {
		_ = ImageFile2ASCIIMatrix("testdata/cat_2000x1500.jpg", &convertOptions)
	}
}


@@ 115,7 115,22 @@ func BenchmarkSmallImage2ASCIIMatrix(b *testing.B) {
	convertOptions.ExpectedWidth = 200
	convertOptions.ExpectedHeight = 200

	for i:=0; i< b.N; i++ {
	for i := 0; i < b.N; i++ {
		_ = ImageFile2ASCIIMatrix("testdata/husky_200x200.jpg", &convertOptions)
	}
}

// ExampleImage2ASCIIMatrix is example
func ExampleImage2ASCISString() {
	imageFilename := "testdata/3x3_white.png"
	convertOptions := DefaultOptions
	convertOptions.FitScreen = false
	convertOptions.Colored = false
	asciiString := ImageFile2ASCIIString(imageFilename, &convertOptions)
	fmt.Println(asciiString)
	/* Output:
@@@
@@@
@@@
	 */
}