Learn R Programming

RTest (version 1.2.6)

test_returnValue_variable: Tests a Standard R 'variable' ('RTestTest_vector_variable')

Description

Tests a Standard R 'variable' ('RTestTest_vector_variable')

Usage

test_returnValue_variable(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)

data <- '<test_variable desc="Compare a value"
          diff-type="absolute" compare-type="equal" tolerance="1E-3"/>'
xmlTestSpec <- XML::xmlRoot(XML::xmlParse(data,asText=TRUE))

test_returnValue_variable(5,5,xmlTestSpec)

test_returnValue_variable(5.0001,5,xmlTestSpec)

# Compare variable with a stricter tolerance

data <- '<test_variable desc="Compare a value"
          diff-type="relative" compare-type="equal" tolerance="1E-6"/>'
xmlTestSpec <- XML::xmlRoot(XML::xmlParse(data,asText=TRUE))

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

tryCatch(
    test_returnValue_variable(5.0001,5,xmlTestSpec),error=function(e){
      stopifnot(grepl("5.0001 not equal to 5.",e))
    })

# }

Run the code above in your browser using DataLab