tests/testthat/test-medal.R

library(testthat)

test_that("medal works", {

  expect_equal(
    medal(1),
    emoji_name[["1st_place_medal"]]
  )

  expect_equal(
    medal(1:3),
    unname(emoji_name[c("1st_place_medal", "2nd_place_medal", "3rd_place_medal")])
  )

  expect_equal(
    medal(c("1st", "2nd", "3rd")),
    unname(emoji_name[c("1st_place_medal", "2nd_place_medal", "3rd_place_medal")])
  )

  expect_equal(
    medal(c("gold", "silver", "bronze")),
    unname(emoji_name[c("1st_place_medal", "2nd_place_medal", "3rd_place_medal")])
  )

  expect_equal(
    medal(c("gold", "nothing")),
    c(emoji_name[["1st_place_medal"]], NA)
  )
})

Try the emoji package in your browser

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

emoji documentation built on Oct. 30, 2024, 9:28 a.m.