Skip to content

Commit

Permalink
last test...
Browse files Browse the repository at this point in the history
  • Loading branch information
SymbolixAU committed Jan 19, 2020
1 parent 8150e00 commit 07cfb20
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
1 change: 0 additions & 1 deletion cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

* updates v0.0.2 to v0.1.0
* three new functions and a bug fix

## Test environments

Expand Down
19 changes: 16 additions & 3 deletions tests/testthat/test-df.R
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,16 @@ test_that("sfg objectse convereted to data.frames", {
, m = c(1)
)

mp <- sfg_multipolygon( df2, x = "x", y = "y", z = "z", polygon_id = "polygon_id", linestring_id = "line_id" )

mpz <- sfg_multipolygon(
df2, x = "x", y = "y", z = "z"
, polygon_id = "polygon_id", linestring_id = "line_id"
)

mpzm <- sfg_multipolygon(
df2, x = "x", y = "y", z = "z", m = "m"
, polygon_id = "polygon_id", linestring_id = "line_id"
)

df_pt <- sfheaders::sfg_to_df( pt )
expect_equal( df_pt$x, 1 )
Expand All @@ -122,10 +131,14 @@ test_that("sfg objectse convereted to data.frames", {
expect_equal( df_p$x, m[,1] )
expect_equal( df_p$y, m[,2] )

df_mp <- sfheaders::sfg_to_df( mp )
df_mp <- sfheaders::sfg_to_df( mpz )
expect_equal( df_mp$x, df2$x )
expect_equal( df_mp$y, df2$y )

df_mpzm <- sfheaders::sfg_to_df( mpzm )
expect_equal( df_mpzm$z, df2$z )
expect_equal( df_mpzm$m, df2$m )

expect_true( inherits( df_pt, "data.frame") )
expect_true( inherits( df_mpt, "data.frame") )
expect_true( inherits( df_ls, "data.frame") )
Expand All @@ -146,7 +159,7 @@ test_that("sfg objectse convereted to data.frames", {
, linestring_id = "linestring_id"
)

expect_equal( mp, res )
expect_equal( mpz, res )

})

Expand Down
10 changes: 10 additions & 0 deletions tests/testthat/test-sfc_point.R
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,16 @@ test_that("after refactoring issue14 I haven't lost anything",{
expect_equal( attr( res, "class" ), c("sfc_POINT", "sfc") )
expect_true( is_point( res ) )

m <- matrix(c(1.1,2), ncol = 2)
res <- sfc_point( m[0,], x = 1, y = 2 )
expect_equal( attr( res, "class" ), c("sfc_POINT", "sfc") )
expect_true( is_point( res ) )

m <- matrix(as.integer( c(1,2) ), ncol = 2)
res <- sfc_point( m[0,], x = 1, y = 2)
expect_equal( attr( res, "class" ), c("sfc_POINT", "sfc") )
expect_true( is_point( res ) )

})

test_that("vectorised version works",{
Expand Down

0 comments on commit 07cfb20

Please sign in to comment.