# test_ISOSource.R # Author: Emmanuel Blondel # # Description: Unit tests for ISOSource.R #======================= require(geometa, quietly = TRUE) require(testthat) context("ISOSource") test_that("encoding",{ testthat::skip_on_cran() #encode md <- ISOSource$new() md$setDescription("description") md$setScaleDenominator(1L) rs <- ISOReferenceSystem$new() rsId <- ISOReferenceIdentifier$new(code = "4326", codeSpace = "EPSG") rs$setReferenceSystemIdentifier(rsId) md$setReferenceSystem(rs) cit <- ISOCitation$new() cit$setTitle("sometitle") cit$addAlternateTitle("somealternatetitle") #and more citation properties... d <- ISODate$new() d$setDate(ISOdate(2015,1,1)) d$setDateType("creation") cit$addDate(d) md$setCitation(cit) extent <- ISOExtent$new() bbox <- ISOGeographicBoundingBox$new(minx = -180, miny = -90, maxx = 180, maxy = 90) extent$addGeographicElement(bbox) md$addExtent(extent) xml <- md$encode() expect_is(xml, "XMLInternalNode") #decoding md2 <- ISOSource$new(xml = xml) xml2 <- md2$encode() expect_true(ISOAbstractObject$compare(md, md2)) }) test_that("encoding - i18n",{ testthat::skip_on_cran() #encode md <- ISOSource$new() md$setDescription( "description", locales = list( EN = "the description", FR = "la description", ES = "la descripción", AR = "الوصف", RU = "описание", ZH = "描述" ) ) md$setScaleDenominator(1L) rs <- ISOReferenceSystem$new() rsId <- ISOReferenceIdentifier$new(code = "4326", codeSpace = "EPSG") rs$setReferenceSystemIdentifier(rsId) md$setReferenceSystem(rs) cit <- ISOCitation$new() cit$setTitle( "sometitle", locales = list( EN = "title", FR = "titre", ES = "título", AR = "لقبان", RU = "название", ZH = "标题" ) ) d <- ISODate$new() d$setDate(ISOdate(2015,1,1)) d$setDateType("creation") cit$addDate(d) md$setCitation(cit) extent <- ISOExtent$new() bbox <- ISOGeographicBoundingBox$new(minx = -180, miny = -90, maxx = 180, maxy = 90) extent$addGeographicElement(bbox) md$addExtent(extent) xml <- md$encode() expect_is(xml, "XMLInternalNode") #decoding md2 <- ISOSource$new(xml = xml) xml2 <- md2$encode() expect_true(ISOAbstractObject$compare(md, md2)) })