tests/testthat/test_get_type.R

library(polmineR)
use("polmineR")
use(pkg = "RcppCWB", corpus = "REUTERS")
testthat::context("get_type")

test_that(
  "get_type_specialized",
  {
    expect_equal(get_type("GERMAPARLMINI"), "plpr")
    expect_equal(get_type(partition("GERMAPARLMINI", date = "2009-10-28")), "plpr")
    expect_equal(get_type(partition_bundle("GERMAPARLMINI", s_attribute = "date")), "plpr")
    expect_equal(get_type(corpus("GERMAPARLMINI")), "plpr")
    expect_equal(get_type(subset("GERMAPARLMINI", date = "2009-11-11")), "plpr")
  }
)

test_that(
  "get_type_default",
  {
    expect_equal(is.null(get_type("REUTERS")), TRUE)
    expect_equal(is.null(get_type(partition("REUTERS", places = "kuwait"))), TRUE)
    expect_equal(is.null(get_type(partition_bundle("REUTERS", s_attribute = "places"))), TRUE)
    expect_equal(is.null(get_type(corpus("REUTERS"))), TRUE)
    expect_equal(
      is.null(corpus("REUTERS") %>% split(s_attribute = "id") %>% get_type()),
      TRUE
    )
  }
)

Try the polmineR package in your browser

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

polmineR documentation built on Nov. 2, 2023, 5:52 p.m.