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

Description Usage Arguments Author(s) See Also Examples

View source: R/utils.test.R

Description

Tests an image file with ImageMagick ('RTestTest_image')

Usage

1
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.

Author(s)

Sebastian Wolf sebastian.wolf.sw1@roche.com

See Also

XMLNode-class

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# 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")
     }
   })

RTest documentation built on Dec. 4, 2019, 5:07 p.m.