Tests an image file with ImageMagick ('RTestTest_image')

test_returnValue_image(result, reference, xmlTestSpec, add.desc = NULL)

Arguments

result

(object) The result object to be tested.

reference

(object) The reference object.

xmlTestSpec

(XMLNode) The XML definition of type 'RTestTest_variable'.

add.desc

(character) Additional description added to the XML definition.

See also

Examples

# Cleaning up tryCatch(unloadNamespace("RTest")) tryCatch(unloadNamespace("testthat")) library(RTest)
#> Loading required package: testthat
#> #> Attaching package: ‘testthat’
#> The following objects are masked from ‘package:magrittr’: #> #> equals, is_less_than, not
# create some definition of tests data <- '<test_image desc="Compare a value" diff-type="relative" compare-type="equal" tolerance="0"/>' xmlTestSpec <- XML::xmlRoot(XML::xmlParse(data,asText=TRUE)) location <- find.package("RTest") # Create a test with equal images result <- paste0(location,"/images/Roche_Logo.png") reference <- paste0(location,"/images/Roche_Logo.png") test_returnValue_image(result,reference,xmlTestSpec) # Create a test with images that are not equal reference <- paste0(location,"/images/Roche_Logo_defect.png") tryCatch( test_returnValue_image(result,reference,xmlTestSpec), error=function(e){ if(!grepl("not equal to",e)){ stop("image omparison defect, please check code") } })