Skip to content

Commit

Permalink
add test, update NEWS
Browse files Browse the repository at this point in the history
  • Loading branch information
Enchufa2 committed Feb 13, 2025
1 parent 46e5fdf commit a8cf96f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

* Add support for `brew` path discovery in macOS; #384

* Several performance improvements; #387 addressing #386
* Several performance improvements; #387, #388 addressing #386

# version 0.8-5

Expand Down
15 changes: 9 additions & 6 deletions tests/testthat/test_misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,15 @@ test_that("We can't concatenate units if they have different units", {
test_that("We can concatenate units if their units can be converted", {
x <- 1:4 * as_units("m")
y <- 5:8 * as_units("km")
z <- c(x, y)
z <- c(x, y, x, y)

expect_equal(length(z), length(x) + length(y))
expect_equal(length(z), 2 * (length(x) + length(y)))
expect_equal(as.character(units(z)), "m")
expect_equal(x, z[1:4])
expect_equal(set_units(y, units(as_units("m")), mode = "standard"), z[1:4 + 4])
expect_equal(x, z[1:4 + 8])
y <- set_units(y, units(as_units("m")), mode = "standard")
expect_equal(y, z[1:4 + 4])
expect_equal(y, z[1:4 + 12])
})

test_that("We can use diff on a units object", {
Expand Down Expand Up @@ -161,7 +164,7 @@ test_that("duplicated-related methods work as expected", {
test_that("bind methods work properly", {
a <- set_units(1:10, m)
b <- set_units((1:10) * 0.001, km)

x <- rbind(x=a, y=a)
y <- rbind(x=a, y=b)
expect_equal(as.numeric(x), as.numeric(y))
Expand All @@ -172,7 +175,7 @@ test_that("bind methods work properly", {
expect_equal(as.numeric(x), as.numeric(y) * 1000)
expect_equal(rownames(x), c("a", "a", "a"))
expect_equal(rownames(y), c("b", "b", "b"))

x <- cbind(x=a, y=a)
y <- cbind(x=a, y=b)
expect_equal(as.numeric(x), as.numeric(y))
Expand All @@ -183,7 +186,7 @@ test_that("bind methods work properly", {
expect_equal(as.numeric(x), as.numeric(y) * 1000)
expect_equal(colnames(x), c("a", "a", "a"))
expect_equal(colnames(y), c("b", "b", "b"))

z <- cbind(
rbind(a, b),
rbind(x = a, y = b))
Expand Down

0 comments on commit a8cf96f

Please sign in to comment.