Skip to content

Commit

Permalink
scaffold, tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mdsumner committed Sep 2, 2016
1 parent dbd299c commit d78f109
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 4 deletions.
3 changes: 2 additions & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,5 @@ Imports:
RoxygenNote: 5.0.1
URL: https://github.com/mdsumner/spex
BugReports: https://github.com/mdsumner/spex/issues
Suggests: covr
Suggests: covr,
testthat
1 change: 0 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@ importFrom(raster,crs)
importFrom(raster,extent)
importFrom(sp,SpatialPolygonsDataFrame)
importFrom(stats,setNames)
importMethodsFrom(raster,as)
3 changes: 1 addition & 2 deletions R/spex.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#' @param ... arguments for methods
#' @param crs a projection string
#' @importFrom methods as
#' @importMethodsFrom raster as
#' @importFrom raster crs<- crs extent
#' @importFrom sp SpatialPolygonsDataFrame
#' @importFrom stats setNames
Expand Down Expand Up @@ -79,5 +78,5 @@ spex.default <- function(x, byid = FALSE, .id, ...) {
spex.Extent <- function(x, crs, ...) {
p <- as(extent(x), 'SpatialPolygons')
crs(p) <- crs
p
spex(p, ...)
}
4 changes: 4 additions & 0 deletions tests/testthat.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
library(testthat)
library(spex)

test_check("spex")
7 changes: 7 additions & 0 deletions tests/testthat/test-spex-any.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
context("spex-any")
library(testthat)
test_that("it's polygons with crs", {
expect_that(spex(lux), is_a("SpatialPolygonsDataFrame"))
expect_that(sp::is.projected(spex(lux)), is_false())
expect_that(names(spex(lux, .id = "thing")), equals("thing"))
})
10 changes: 10 additions & 0 deletions tests/testthat/test-spex-extent.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
context("spex-extent")

test_that("extent and crs works", {
expect_that(spex(raster::extent(lux), raster::crs(lux)), is_a("SpatialPolygonsDataFrame"))
})


test_that("by id is not implemented", {
expect_that(spex(lux, byid = TRUE), throws_error("implemented"))
})

0 comments on commit d78f109

Please sign in to comment.