tests/testthat/test_as.R

test_that("as coercion works as expected", {
  as_subtitle(
    c(
      "WEBVTT",
      "X-TIMESTAMP-MAP=MPEGTS:181083,LOCAL:00:00:00.000",
      "",
      "3",
      "00:00:21.199 --> 00:00:22.333",
      ">> FEMALE SPEAKER:",
      "Don't stay up too late.",
      "",
      ""
    ),
    format = "webvtt"
  ) -> st

  expect_equal(
    st[["Text_content"]],
    ">> FEMALE SPEAKER: Don't stay up too late."
  )
})

Try the subtools package in your browser

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

subtools documentation built on March 24, 2026, 5:07 p.m.