Running 'aggregate.R' [1s]
  Comparing 'aggregate.Rout' to 'aggregate.Rout.save' ... OK
  Running 'cast.R' [2s]
  Running 'crs.R' [1s]
  Comparing 'crs.Rout' to 'crs.Rout.save' ... OK
  Running 'dist.R' [1s]
  Comparing 'dist.Rout' to 'dist.Rout.save' ... OK
  Running 'dplyr.R' [4s]
  Comparing 'dplyr.Rout' to 'dplyr.Rout.save' ... OK
  Running 'empty.R' [1s]
  Comparing 'empty.Rout' to 'empty.Rout.save' ... OK
  Running 'full.R' [2s]
  Comparing 'full.Rout' to 'full.Rout.save' ... OK
  Running 'gdal_geom.R' [2s]
  Comparing 'gdal_geom.Rout' to 'gdal_geom.Rout.save' ... OK
  Running 'geos.R' [25s]
  Comparing 'geos.Rout' to 'geos.Rout.save' ... OK
  Running 'graticule.R' [4s]
  Comparing 'graticule.Rout' to 'graticule.Rout.save' ... OK
  Running 'grid.R' [2s]
  Comparing 'grid.Rout' to 'grid.Rout.save' ... OK
  Running 'maps.R' [2s]
  Comparing 'maps.Rout' to 'maps.Rout.save' ... OK
  Running 'plot.R' [8s]
  Comparing 'plot.Rout' to 'plot.Rout.save' ... OK
  Running 'read.R' [3s]
  Comparing 'read.Rout' to 'read.Rout.save' ... OK
  Running 'roundtrip.R' [2s]
  Comparing 'roundtrip.Rout' to 'roundtrip.Rout.save' ... OK
  Running 's2.R' [2s]
  Comparing 's2.Rout' to 's2.Rout.save' ... OK
  Running 'sample.R' [1s]
  Comparing 'sample.Rout' to 'sample.Rout.save' ... OK
  Running 'sfc.R' [14s]
  Comparing 'sfc.Rout' to 'sfc.Rout.save' ... OK
  Running 'sfg.R' [1s]
  Comparing 'sfg.Rout' to 'sfg.Rout.save' ... OK
  Running 'spatstat.R' [4s]
  Comparing 'spatstat.Rout' to 'spatstat.Rout.save' ... OK
  Running 'stars.R' [3s]
  Comparing 'stars.Rout' to 'stars.Rout.save' ... OK
  Running 'test-by-element.R' [1s]
  Comparing 'test-by-element.Rout' to 'test-by-element.Rout.save' ... OK
  Running 'testthat.R' [27s]
  Running 'units.R' [1s]
  Comparing 'units.Rout' to 'units.Rout.save' ... OK
  Running 'wkb.R' [1s]
  Comparing 'wkb.Rout' to 'wkb.Rout.save' ... OK
Running the tests in 'tests/cast.R' failed.
Complete output:
  > suppressPackageStartupMessages(library(sf))
  > library(testthat)
  > # "vertical" conversions:
  > # column 1:
  > mp = st_sfc(st_multipoint(matrix(0:3,,2)), st_multipoint(matrix(10:15,,2)))
  > (ls = st_cast(mp, "LINESTRING"))
  Geometry set for 2 features 
  Geometry type: LINESTRING
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 2 xmax: 12 ymax: 15
  CRS:           NA
  LINESTRING (0 2, 1 3)
  LINESTRING (10 13, 11 14, 12 15)
  > st_cast(ls, "MULTIPOINT")
  Geometry set for 2 features 
  Geometry type: MULTIPOINT
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 2 xmax: 12 ymax: 15
  CRS:           NA
  MULTIPOINT ((0 2), (1 3))
  MULTIPOINT ((10 13), (11 14), (12 15))
  > 
  > # column 2:
  > mls = st_sfc(st_multilinestring(list(rbind(c(0,0), c(10,0), c(10,10), c(0,10)), 
  + 	rbind(c(5,5),c(5,6), c(6,6), c(6,5)))), 
  + 	st_multilinestring(list(rbind(c(0,0), c(1,0), c(1,1), c(0,1)))))
  > (pol = st_cast(mls, "POLYGON"))
  Geometry set for 2 features 
  Geometry type: POLYGON
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 0 xmax: 10 ymax: 10
  CRS:           NA
  POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (5 5, 5...
  POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))
  > st_cast(pol, "MULTILINESTRING")
  Geometry set for 2 features 
  Geometry type: MULTILINESTRING
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 0 xmax: 10 ymax: 10
  CRS:           NA
  MULTILINESTRING ((0 0, 10 0, 10 10, 0 10, 0 0),...
  MULTILINESTRING ((0 0, 1 0, 1 1, 0 1, 0 0))
  > 
  > # "horizontal" conversions:
  > 
  > (pt = st_cast(mp, "POINT"))
  Geometry set for 5 features 
  Geometry type: POINT
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 2 xmax: 12 ymax: 15
  CRS:           NA
  POINT (0 2)
  POINT (1 3)
  POINT (10 13)
  POINT (11 14)
  POINT (12 15)
  > (i = attr(pt, "ids"))
  [1] 2 3
  > (xx = st_cast(pt, "MULTIPOINT", rep(seq_along(i), i)))
  Geometry set for 5 features 
  Geometry type: MULTIPOINT
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 2 xmax: 12 ymax: 15
  CRS:           NA
  MULTIPOINT ((0 2))
  MULTIPOINT ((1 3))
  MULTIPOINT ((10 13))
  MULTIPOINT ((11 14))
  MULTIPOINT ((12 15))
  > try(yy <- st_cast(pt, "LINESTRING", rep(seq_along(i), i)))
  > 
  > #(zz = st_cast(yy, "MULTILINESTRING"))
  > #(zz = st_cast(yy, "POLYGON"))
  > 
  > st_cast(mls, "LINESTRING")
  Geometry set for 3 features 
  Geometry type: LINESTRING
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 0 xmax: 10 ymax: 10
  CRS:           NA
  LINESTRING (0 0, 10 0, 10 10, 0 10)
  LINESTRING (5 5, 5 6, 6 6, 6 5)
  LINESTRING (0 0, 1 0, 1 1, 0 1)
  > 
  > (g = st_sfc(c(mls, ls)))
  Geometry set for 4 features 
  Geometry type: GEOMETRY
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 0 xmax: 12 ymax: 15
  CRS:           NA
  MULTILINESTRING ((0 0, 10 0, 10 10, 0 10), (5 5...
  MULTILINESTRING ((0 0, 1 0, 1 1, 0 1))
  LINESTRING (0 2, 1 3)
  LINESTRING (10 13, 11 14, 12 15)
  > st_cast(g, "MULTILINESTRING")
  Geometry set for 4 features 
  Geometry type: MULTILINESTRING
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 0 xmax: 12 ymax: 15
  CRS:           NA
  MULTILINESTRING ((0 0, 10 0, 10 10, 0 10), (5 5...
  MULTILINESTRING ((0 0, 1 0, 1 1, 0 1))
  MULTILINESTRING ((0 2, 1 3))
  MULTILINESTRING ((10 13, 11 14, 12 15))
  > expect_warning(st_cast(g, "LINESTRING"))
  > st_cast(st_cast(g, "MULTILINESTRING"), "LINESTRING") # will not loose
  Geometry set for 5 features 
  Geometry type: LINESTRING
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 0 xmax: 12 ymax: 15
  CRS:           NA
  LINESTRING (0 0, 10 0, 10 10, 0 10)
  LINESTRING (5 5, 5 6, 6 6, 6 5)
  LINESTRING (0 0, 1 0, 1 1, 0 1)
  LINESTRING (0 2, 1 3)
  LINESTRING (10 13, 11 14, 12 15)
  > 
  > gc = st_sfc(st_geometrycollection(
  +   list(
  +     st_multilinestring(list(rbind(c(0,0), c(10,0), c(10,10), c(0,10)), 
  + 	rbind(c(5,5),c(5,6), c(6,6), c(6,5)))), 
  + 	st_multilinestring(list(rbind(c(0,0), c(1,0), c(1,1), c(0,1)))),
  + 	st_point(0:1)
  +   )))
  > try(st_cast(mls, "POINT"))
  Geometry set for 12 features 
  Geometry type: POINT
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 0 xmax: 10 ymax: 10
  CRS:           NA
  First 5 geometries:
  POINT (0 0)
  POINT (10 0)
  POINT (10 10)
  POINT (0 10)
  POINT (5 5)
  > try(st_cast(mls, "MULTIPOINT"))
  Geometry set for 3 features 
  Geometry type: MULTIPOINT
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 0 xmax: 10 ymax: 10
  CRS:           NA
  MULTIPOINT ((0 0), (10 0), (10 10), (0 10))
  MULTIPOINT ((5 5), (5 6), (6 6), (6 5))
  MULTIPOINT ((0 0), (1 0), (1 1), (0 1))
  > 
  > outer = matrix(c(0,0,10,0,10,10,0,10,0,0),ncol=2, byrow=TRUE)
  > hole1 = matrix(c(1,1,1,2,2,2,2,1,1,1),ncol=2, byrow=TRUE)
  > hole2 = matrix(c(5,5,5,6,6,6,6,5,5,5),ncol=2, byrow=TRUE)
  > pol1 = list(outer, hole1, hole2)
  > pol2 = list(outer + 12, hole1 + 12)
  > pol3 = list(outer + 24)
  > mp = list(pol1,pol2,pol3)
  > mp1 = st_multipolygon(mp)
  > s = st_sfc(mp1)
  > x = st_cast(s, "MULTIPOINT")
  > x = st_cast(s, "POINT")
  > expect_warning(st_cast(mp1, "LINESTRING"))
  > expect_warning(st_cast(mp1, "POINT"))
  > mls = mls[[1]]
  > class(mls)
  [1] "XY"              "MULTILINESTRING" "sfg"            
  > #expect_error(st_cast(mls, "POLYGON"))
  > st_cast(mls, "POLYGON")
  POLYGON ((0 0, 10 0, 10 10, 0 10, 0 0), (5 5, 5 6, 6 6, 6 5, 5 5))
  > 
  > expect_warning(st_cast(mls, "POINT"))
  > p1 = st_polygon(pol1)
  > expect_warning(st_cast(p1, "POINT"))
  > ls = ls[[1]]
  > class(ls)
  [1] "XY"         "LINESTRING" "sfg"       
  > expect_warning(st_cast(ls, "POINT"))
  > 
  > mls = st_cast(p1, "MULTILINESTRING")
  > p2 = st_cast(mls, "POLYGON")
  > 
  > # st_is:
  > st_is(st_point(0:1), "POINT")
  [1] TRUE
  > sfc = st_sfc(st_point(0:1), st_linestring(matrix(1:6,,2)))
  > st_is(sfc, "POINT")
  [1]  TRUE FALSE
  > st_is(sfc, "POLYGON")
  [1] FALSE FALSE
  > st_is(sfc, "LINESTRING")
  [1] FALSE  TRUE
  > st_is(st_sf(a = 1:2, sfc), "LINESTRING")
  [1] FALSE  TRUE
  > st_is(sfc, c("POINT", "LINESTRING"))
  [1] TRUE TRUE
  > 
  > #1194:
  > wkt <- "MULTICURVE (COMPOUNDCURVE (LINESTRING (-83.62333 35.55244, -83.62328 35.55232, -83.62323 35.55223, -83.62319 35.55216, -83.62312 35.55209, -83.6231 35.55207), CIRCULARSTRING (-83.6231 35.55207, -83.62307 35.55205, -83.62302 35.55204), LINESTRING (-83.62302 35.55204, -83.62299 35.55203, -83.62289 35.55198, -83.62281 35.55189, -83.62271 35.55182)))"
  > g <- st_as_sfc(wkt)
  > g <- st_sf(demo = "test", geom = g, crs = 4326)
  > m = st_cast(g, "MULTILINESTRING")
  > identical(m$geom[[1]], st_cast(g$geom[[1]], "MULTILINESTRING"))
  [1] TRUE
  > 
  > st_cast(st_sfc(st_geometrycollection(), st_multipolygon()), 'MULTIPOLYGON') #1961
  Geometry set for 2 features  (with 2 geometries empty)
  Geometry type: MULTIPOLYGON
  Dimension:     XY
  Bounding box:  xmin: NA ymin: NA xmax: NA ymax: NA
  CRS:           NA
  MULTIPOLYGON EMPTY
  MULTIPOLYGON EMPTY
  > st_cast(st_sfc(st_geometrycollection(), st_multipolygon(), st_point(0:1)), 'POINT') #1961
  Geometry set for 3 features  (with 2 geometries empty)
  Geometry type: POINT
  Dimension:     XY
  Bounding box:  xmin: 0 ymin: 1 xmax: 0 ymax: 1
  CRS:           NA
  POINT EMPTY
  POINT EMPTY
  POINT (0 1)
  > 
  > proc.time()
     user  system elapsed 
     1.71    0.25    1.92