Skip to content

Commit

Permalink
add (non-published) tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinushey committed Dec 2, 2015
1 parent b56ee99 commit 9b59017
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 0 deletions.
1 change: 1 addition & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
^.*\.Rproj$
^\.Rproj\.user$
^\.travis\.yml$
^tests/
README.md
1 change: 1 addition & 0 deletions DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ Maintainer: JJ Allaire <[email protected]>
License: MIT + file LICENSE
Roxygen: list(wrap = FALSE)
RoxygenNote: 5.0.1
Suggests: testthat
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(rstudioapi)

test_check("rstudioapi")
53 changes: 53 additions & 0 deletions tests/testthat/test-document-apis.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
context("Document API")

# -- Scratch Space -- #
#
#
#
#
#
# -- Scratch Space -- #

test_that("various APIs for interacting with an RStudio document work", {

scratchRanges <- Map(c, Map(c, 4:8, 1), Map(c, 4:8, Inf))

# Insert text at position
insertText(makePosition(4, Inf), " Hello")
insertText(list(
makePosition(5, Inf),
makePosition(6, Inf)
), " Hello")

insertText(list(
makePosition(7, Inf),
makePosition(8, Inf)
), c(" First", " Second"))

# Clean up
insertText(scratchRanges, "#")

# Insert text at range
insertText(c(4, 1, 4, Inf), "# Howdy")
insertText(makeRange(start = c(5, 1), end = c(5, Inf)), "# Hello There")

# Clean up
insertText(scratchRanges, "#")

# Insert text at bottom of document
insertText(Inf, "# Hello!\n")
insertText(c(Inf, 1), "# Hello!\n")

# Comment out the first 5 lines
pos <- Map(c, 4:8, 1)
insertText(pos, "# ")

# Uncomment the first 5 lines
rng <- Map(c, Map(c, 4:8, 1), Map(c, 4:8, 3))
insertText(rng, "")

})

# -- Scratch Space -- #
# Hello!
# Hello!

0 comments on commit 9b59017

Please sign in to comment.