|
65 | 65 | """ |
66 | 66 |
|
67 | 67 | @test_throws ErrorException @test_reference "references/string1.txt" "intentionally wrong to check that this message prints" |
68 | | - @test_throws ErrorException @test_reference "references/wrong.txt" "intentional error to check that this message prints" |
69 | 68 | @test_throws ErrorException @test_reference "references/string5.txt" """ |
70 | 69 | This is an incorrect |
71 | 70 | multiline string that does not end with a new line.""" |
|
77 | 76 |
|
78 | 77 | @testset "images as txt using ImageInTerminal" begin |
79 | 78 | #@test_throws MethodError @test_reference "references/fail.txt" rand(2,2) |
80 | | - @test_throws ErrorException @test_reference "references/camera_new.txt" camera size=(5,10) |
| 79 | + |
81 | 80 | @test_reference "references/camera.txt" camera size=(5,10) |
82 | 81 | @test_reference "references/lena.txt" lena |
83 | 82 | end |
@@ -111,16 +110,38 @@ end |
111 | 110 | @testset "images as PNG" begin |
112 | 111 | @test_reference "references/camera.png" imresize(camera, (64,64)) |
113 | 112 | @test_reference "references/camera.png" imresize(camera, (64,64)) by=psnr_equality(25) |
114 | | - @test_throws Exception @test_reference "references/wrongfilename.png" imresize(camera, (64,64)) |
115 | 113 | @test_throws ErrorException @test_reference "references/camera.png" imresize(lena, (64,64)) |
116 | 114 | @test_throws Exception @test_reference "references/camera.png" camera # unequal size |
117 | 115 | end |
118 | 116 |
|
119 | 117 | using DataFrames, CSVFiles |
120 | 118 | @testset "DataFrame as CSV" begin |
121 | 119 | @test_reference "references/dataframe.csv" DataFrame(v1=[1,2,3], v2=["a","b","c"]) |
122 | | - @test_throws ErrorException @test_reference "references/wrongfilename.csv" DataFrame(v1=[1,2,3], v2=["a","b","c"]) |
123 | 120 | @test_throws ErrorException @test_reference "references/dataframe.csv" DataFrame(v1=[1,2,3], v2=["c","b","c"]) |
| 121 | + |
124 | 122 | end |
125 | 123 |
|
| 124 | +@testset "Create new $ext" for (ext, val) in ( |
| 125 | + (".csv", DataFrame(v1=[1,2,3], v2=["c","b","c"])), |
| 126 | + (".png", imresize(camera, (64,64))), |
| 127 | + (".txt", "Lorem ipsum dolor sit amet, labore et dolore magna aliqua."), |
| 128 | +) |
| 129 | + newfilename = "references/newfilename.$ext" |
| 130 | + @assert !isfile(newfilename) |
| 131 | + @test_reference newfilename val # this should create it |
| 132 | + @test isfile(newfilename) # Was created |
| 133 | + @test_reference newfilename val # Matches expected content |
| 134 | + rm(newfilename, force=true) |
126 | 135 | end |
| 136 | + |
| 137 | +@testset "Create new image as txt" begin |
| 138 | + # This is a sperate testset as need to use the `size` argument to ``@test_reference` |
| 139 | + newfilename = "references/new_camera.txt" |
| 140 | + @assert !isfile(newfilename) |
| 141 | + @test_reference newfilename camera size=(5,10) # this should create it |
| 142 | + @test isfile(newfilename) # Was created |
| 143 | + @test_reference newfilename camera size=(5,10) # Matches expected content |
| 144 | + rm(newfilename, force=true) |
| 145 | +end |
| 146 | + |
| 147 | +end # top level testset |
0 commit comments