tests/testthat/test-againstDotC.R

context("test-againstDotC")

test_that("int", {
    cc <- .C("TEST_times2_int",  a = 2L, r = integer(1),
             PACKAGE = "dotCall64")
    dc <- .C64("TEST_times2_int", c("int", "int"),  a = 2L, r = integer(1),
               INTENT = c("rw", "rw"),
               PACKAGE = "dotCall64")
    expect_equal(cc, dc, label = "[values]")
    expect_equal(lapply(cc, typeof), lapply(dc, typeof),
                 label = "[types]")             
    })


test_that("double", {
    cc <- .C("TEST_times2_double",  a = 2.2, r = double(1),
             PACKAGE = "dotCall64")
    dc <- .C64("TEST_times2_double", c("double", "double"),
               a = 2.2, r = double(1),
               INTENT = c("rw", "rw"),
               PACKAGE = "dotCall64")
    expect_equal(cc, dc, label = "[values]")
    expect_equal(lapply(cc, typeof), lapply(dc, typeof),
                 label = "[types]")   
    })

## --------------------
test_that("referenced-integer", {
    input <- 2L
    cc <- .C("TEST_times2_int",  a = input, r = input,
             PACKAGE = "dotCall64")
    dc <- .C64("TEST_times2_int", c("int", "int"),
               a = input, r = input,
               INTENT = c("rw", "rw"),
               PACKAGE = "dotCall64")
    expect_equal(cc, dc, label = "[values]")
    expect_equal(lapply(cc, typeof), lapply(dc, typeof),
                 label = "[types]")   
    expect_identical(input, 2L)
})

test_that("referenced-double", {
    input <- 2.2
    cc <- .C("TEST_times2_double",  a = input, r = input,
             PACKAGE = "dotCall64")
    dc <- .C64("TEST_times2_double", c("double", "double"),
               a = input, r = input,
               INTENT = c("rw", "rw"),
               PACKAGE = "dotCall64")
    expect_equal(cc, dc, label = "[values]")
    expect_equal(lapply(cc, typeof), lapply(dc, typeof),
                 label = "[types]")   
    expect_identical(input, 2.2)
})

Try the dotCall64 package in your browser

Any scripts or data that you put into this service are public.

dotCall64 documentation built on Oct. 17, 2023, 5:07 p.m.