package mosaic import ( "image" "image/png" "os" "reflect" "testing" ) func TestRender(t *testing.T) { t.Skip("Skip failing test for now, the provided image seems to be corrupt.") raw, err := loadImage("./fixtures/charm-wish.png") if err != nil { t.Errorf("unexpected error: %v", err) os.Exit(1) } // Create options mosaic := New().Width(80).Height(40) result := mosaic.Render(raw) // TODO: Use a smaller image, it is almost impossible seeing the diff by now expected := `              ▄███▄                                    █████▀             ▄▄▄                   ▀████▀           ▄████▀                ▄▄▄▄     ▄▄▄▄      ▀████▀               ▄████▄  ▄███████▄▄   ▀▀▀▀▄▄▄▄         ▄▄▄██████▄███████████▄      ▀██▀       ▄███████████████████████▄               ▄███████████████████████████████▄       ▄██████████████████████████████████▄ ▄██████████████████████████████████████▄ ▀█████▀███████ ████████████████████████▀  ▀███▀▄███████ ███████████████████████▀    ▀███▄████████████████████████████▀▀       ▀██████████████████████████████▀          █████████████████████████████▀           ████████████████████████████▀ ▄███▄      ████████████████████▀▀▀█▀▀▀   ▀███▀      ████████████████████           ▀▀▀       █████▀▀    ▀▀███████                     ▀▀▀            ▀▀██▀                 ` if !reflect.DeepEqual(result, expected) { a := os.WriteFile("/tmp/dat1", []byte(result), 0o644) t.Log(a) t.Errorf("Result and expected does not match = %v, want %v", result, expected) } // used for quick testing // t.Log(result) } func loadImage(path string) (image.Image, error) { f, err := os.Open(path) if err != nil { return nil, err } return png.Decode(f) }