Skip to content

Commit

Permalink
checkpoint unit test #27 #139
Browse files Browse the repository at this point in the history
  • Loading branch information
eliotmcintire committed Jun 8, 2015
1 parent c21eb59 commit 5fccf4b
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions tests/testthat/test-checkpoint.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
test_that("testing checkpoint, passed", {

####################
set.seed(1234)
times <- list(start=0, stop=10)
parameters <- list(.globals=list(stackName="landscape"),
.checkpoint=list(interval=1, file="chkpnt.rdata"),
randomLandscapes=list(.plotInitialTime=NA),
caribouMovement=list(.plotInitialTime=NA))
modules <- list("randomLandscapes", "caribouMovement")
path <- system.file("sampleModules", package="SpaDES")
mySimFirst <- simInit(times=times, params=parameters, modules=modules, path=path)
mySimFirst <- spades(mySimFirst)

####################
set.seed(1234)
times <- list(start=0, stop=5)
mySimSecond <- simInit(times=times, params=parameters, modules=modules, path=path)
mySimSecond <- spades(mySimSecond)
rm(mySimSecond)

checkpointLoad(file="chkpnt.rdata")
simStopTime(mySimSecond) <- 10
mySimSecond <- spades(mySimSecond)

expect_true(all.equal(as(mySimFirst,"simList_"), as(mySimSecond,"simList_")))

})

0 comments on commit 5fccf4b

Please sign in to comment.