Skip to content

Commit 257af0d

Browse files
committed
Update tests pre a big vmath change.
1 parent 666d420 commit 257af0d

File tree

8 files changed

+46
-29
lines changed

8 files changed

+46
-29
lines changed

examples/all.nim

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import
2+
text,
3+
text_spans,
4+
square,
5+
line,
6+
rounded_rectangle,
7+
heart,
8+
masking,
9+
gradient,
10+
image_tiled,
11+
shadow,
12+
blur,
13+
tiger

examples/text.png

-1.71 KB
Loading

tests/all.nim

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,6 @@ import
1212
test_ppm,
1313
test_qoi,
1414
test_svg,
15-
../examples/text,
16-
../examples/text_spans,
17-
../examples/square,
18-
../examples/line,
19-
../examples/rounded_rectangle,
20-
../examples/heart,
21-
../examples/masking,
22-
../examples/gradient,
23-
../examples/image_tiled,
24-
../examples/shadow,
25-
../examples/blur,
26-
../examples/tiger
15+
xrays
16+
17+
writeReport()

tests/contexts/rotate_simple.png

1.08 KB
Loading

tests/test_contexts.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ block:
220220
ctx.rotate(45 * PI / 180)
221221
ctx.fillRect(60, 0, 100, 30)
222222

223-
ctx.image.xray("tests/contexts/resetTransform_1.png")
223+
ctx.image.xray("tests/contexts/rotate_simple.png")
224224

225225
block:
226226
let ctx = newContext(newImage(300, 150))

tests/test_gif.nim

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,6 @@ block:
2727
doAssert image.width == dimensions.width
2828
doAssert image.height == dimensions.height
2929

30-
block:
31-
let
32-
path = "tests/fileformats/gif/sunflower.gif"
33-
image = readImage(path)
34-
dimensions = decodeGifDimensions(readFile(path))
35-
image.xray("tests/fileformats/gif/sunflower.png")
36-
doAssert image.width == dimensions.width
37-
doAssert image.height == dimensions.height
38-
3930
block:
4031
let img4 = readImage("tests/fileformats/gif/newtons_cradle.gif")
4132
img4.xray("tests/fileformats/gif/newtons_cradle.png")

tests/test_paths.nim

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,7 @@ block:
678678
)
679679

680680
block:
681+
# Large coordinates that are out of bounds should not raise.
681682
let image = newImage(200, 200)
682683
image.fill(rgba(255, 255, 255, 255))
683684

@@ -691,13 +692,7 @@ block:
691692

692693
let path = parsePath(pathStr)
693694

694-
doAssertRaises PixieError:
695-
image.fillPath(
696-
path,
697-
paint,
698-
mat3(),
699-
NonZero
700-
)
695+
image.fillPath(path, paint, mat3(), NonZero)
701696

702697
block:
703698
let

tests/xrays.nim

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,41 @@
11
import os, pixie, strformat, strutils
22

3+
var htmlEntries: seq[string]
4+
35
proc xray*(image: Image, masterPath: string) =
46
let
57
generatedPath = "tmp/generated/" & masterPath
68
xrayPath = "tmp/xray/" & masterPath
79
createDir(generatedPath.splitPath.head)
810
createDir(xrayPath.splitPath.head)
911
image.writeFile(generatedPath)
12+
if not fileExists(masterPath):
13+
echo &"xray {masterPath} -> new master"
14+
createDir(masterPath.splitPath.head)
15+
image.writeFile(masterPath)
16+
return
1017
let
1118
master = readImage(masterPath)
1219
(score, xRay) = diff(image, master)
1320
xRay.writeFile(xrayPath)
1421
echo &"xray {masterPath} -> {score:0.6f}"
22+
23+
let bg = if score > 1: "#fee" else: "#fff"
24+
htmlEntries.add(&"""<div style="background:{bg};border:1px solid #ccc;padding:8px;break-inside:avoid">
25+
<b>{masterPath}</b> score: {score:0.6f}
26+
<div style="display:flex;gap:8px;flex-wrap:wrap">
27+
<div><div>Master</div><img src="../{masterPath}"></div>
28+
<div><div>Generated</div><img src="../{generatedPath}"></div>
29+
<div><div>Xray</div><img src="../{xrayPath}"></div>
30+
</div></div>""")
31+
32+
proc writeReport*() =
33+
let html = """<!DOCTYPE html>
34+
<html><head><meta charset="utf-8"><title>Xray Report</title>
35+
<style>body{font-family:monospace;margin:16px}img{display:block;background:repeating-conic-gradient(#eee 0% 25%,#fff 0% 50%) 0 0/16px 16px}</style>
36+
</head><body>
37+
<h1>Xray Report</h1>
38+
""" & htmlEntries.join("\n") & "\n</body></html>"
39+
createDir("tmp")
40+
writeFile("tmp/xray_report.html", html)
41+
echo "Wrote tmp/xray_report.html"

0 commit comments

Comments
 (0)