tests/testthat/test_ISOBaseInteger.R

# test_ISOBaseInteger.R
# Author: Emmanuel Blondel <emmanuel.blondel1@gmail.com>
#
# Description: Unit tests for ISOBaseInteger.R
#=======================
require(geometa, quietly = TRUE)
require(testthat)

context("ISOBaseInteger")

test_that("encoding",{
  #encoding
  md <- ISOBaseInteger$new(value = 19L)
  expect_is(md, "ISOBaseInteger")
  xml <- md$encode()
  expect_is(xml, "XMLInternalNode")
  
  #decoding
  md2 <- ISOBaseInteger$new(xml = xml)
  xml2 <- md2$encode()
  
  expect_true(ISOAbstractObject$compare(md, md2))
  
})

test_that("encoding with coercing",{
  
  #encoding
  md <- ISOBaseInteger$new(value = "19")
  expect_is(md, "ISOBaseInteger")
  xml <- md$encode()
  expect_is(xml, "XMLInternalNode")
  
  #decoding
  md2 <- ISOBaseInteger$new(xml = xml)
  xml2 <- md2$encode()
  
  expect_true(ISOAbstractObject$compare(md, md2))
  
})

Try the geometa package in your browser

Any scripts or data that you put into this service are public.

geometa documentation built on May 29, 2024, 10:31 a.m.