mirror of
https://github.com/agdamsbo/stRoke.git
synced 2024-11-25 06:01:54 +01:00
Modified tests to avoid expected GHA test fail with sprintf()
This commit is contained in:
parent
aed6ef02b0
commit
163e970865
@ -1,26 +1,27 @@
|
|||||||
# library(testthat)
|
library(testthat)
|
||||||
test_that("chunks_of_n returns correct", {
|
test_that("chunks_of_n returns correct", {
|
||||||
expect_length(chunks_of_n(seq_len(100), 7),15)
|
expect_length(chunks_of_n(seq_len(100), 7),15)
|
||||||
|
|
||||||
expect_equal(lengths(chunks_of_n(seq_len(30), 7, even = TRUE),
|
expect_equal(lengths(chunks_of_n(seq_len(30), 7, even = TRUE),
|
||||||
use.names = FALSE), c(6, 6, 6, 6, 6))
|
use.names = FALSE), c(6, 6, 6, 6, 6))
|
||||||
|
|
||||||
ds <- data.frame(nm = paste0("Sub",
|
# This is the example from the function, but I believe it fails in GitHub testing
|
||||||
sprintf("%03s", rownames(stRoke::talos))),
|
# ds <- data.frame(nm = paste0("Sub",
|
||||||
|
# sprintf("%03s", rownames(stRoke::talos))),
|
||||||
|
# stRoke::talos)
|
||||||
|
|
||||||
|
ds <- data.frame(nm = paste0("Sub",rownames(stRoke::talos)),
|
||||||
stRoke::talos)
|
stRoke::talos)
|
||||||
|
|
||||||
is.list(ds)
|
|
||||||
|
|
||||||
class(list(ds))
|
|
||||||
|
|
||||||
expect_equal(head(names(chunks_of_n(ds, 7,
|
expect_equal(head(names(chunks_of_n(ds, 7,
|
||||||
pattern = "Sub[0-9]{3}", label = "grp")),
|
pattern = "Sub([0-9]+)", label = "grp")),
|
||||||
1),"grp-Sub038-Sub011")
|
1),"grp-Sub38-Sub11")
|
||||||
|
|
||||||
expect_equal(
|
expect_equal(
|
||||||
ds[order(ds$nm),] |> chunks_of_n(7, pattern = "Sub[0-9]{3}", label =
|
ds[order(as.numeric(rownames(stRoke::talos))), ] |>
|
||||||
"grp") |> head(1) |> names(),
|
chunks_of_n(7, pattern = "Sub([0-9]+)", label = "grp") |>
|
||||||
"grp-Sub001-Sub020"
|
head(1) |> names(),
|
||||||
|
"grp-Sub1-Sub20"
|
||||||
)
|
)
|
||||||
|
|
||||||
## Errors
|
## Errors
|
||||||
@ -35,22 +36,27 @@ test_that("n_chunks returns correct", {
|
|||||||
expect_equal(lengths(n_chunks(seq_len(30), 7, even = TRUE),
|
expect_equal(lengths(n_chunks(seq_len(30), 7, even = TRUE),
|
||||||
use.names = FALSE), rep(5,6))
|
use.names = FALSE), rep(5,6))
|
||||||
|
|
||||||
ds <- data.frame(nm = paste0("Sub",
|
# This is the example from the function, but I believe it fails in GitHub testing
|
||||||
sprintf("%03s", rownames(stRoke::talos))),
|
# ds <- data.frame(nm = paste0("Sub",
|
||||||
|
# sprintf("%03s", rownames(stRoke::talos))),
|
||||||
|
# stRoke::talos)
|
||||||
|
|
||||||
|
ds <- data.frame(nm = paste0("Sub",rownames(stRoke::talos)),
|
||||||
stRoke::talos)
|
stRoke::talos)
|
||||||
|
|
||||||
expect_equal(head(names(n_chunks(ds, 7,
|
expect_equal(head(names(n_chunks(ds, 7,
|
||||||
pattern = "Sub[0-9]{3}", label = "grp")),
|
pattern = "Sub([0-9]+)", label = "grp")),
|
||||||
1),"grp-Sub038-Sub603")
|
1),"grp-Sub38-Sub603")
|
||||||
|
|
||||||
expect_equal(
|
expect_equal(
|
||||||
ds[order(ds$nm),] |> n_chunks(7, pattern = "Sub[0-9]{3}", label =
|
ds[order(as.numeric(rownames(stRoke::talos))), ] |>
|
||||||
"grp") |> head(1) |> names(),
|
n_chunks(7, pattern = "Sub([0-9]+)", label = "grp") |>
|
||||||
"grp-Sub001-Sub072"
|
head(1) |> names(),
|
||||||
|
"grp-Sub1-Sub72"
|
||||||
)
|
)
|
||||||
|
|
||||||
## Errors
|
## Errors
|
||||||
expect_error(n_chunks(list(ds), 7, pattern = "Sub[0-9]{3}", label = "grp"))
|
expect_error(n_chunks(list(ds), 7, pattern = "Sub([0-9]+)", label = "grp"))
|
||||||
|
|
||||||
|
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user