Learn R Programming

RTest (version 1.2.6)

test_returnValue_image: Tests an image file with ImageMagick ('RTestTest_image')

Description

Tests an image file with ImageMagick ('RTestTest_image')

Usage

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

XMLNode-class

Examples

Run this code
# NOT RUN {
# Cleaning up

tryCatch(unloadNamespace("RTest"))
tryCatch(unloadNamespace("testthat"))
library(RTest)

# 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")
     }
   })

# }

Run the code above in your browser using DataLab