tests/testthat/test-get_currency_symbol.R

path <- system.file("testdata", "three4", "scenario_0", package = "mm.reoptimise")

# pounds  -> \u00A3
scenario <- create_scenario(path)

# dollars -> \u0024
scenario2 <- scenario
scenario2$curves_full <- scenario2$curves_full %>%
      dplyr::mutate(alloc.unit_currency = "dollars")

# anything else -> ""
scenario3 <- scenario
scenario3$curves_full <- scenario3$curves_full %>%
      dplyr::mutate(alloc.unit_currency = "not_a_currency")

test_that("function returns expected character", {
      expect_equal("\u00A3", get_currency_symbol(scenario))
      expect_equal("\u0024", get_currency_symbol(scenario2))
      expect_equal("", get_currency_symbol(scenario3))
})
cath-parkinson/mm.reoptimise documentation built on May 12, 2022, 3:34 p.m.