tests/testthat/test-roxytest-tests-helpers.R

# Generated by roxytest: Do not edit by hand!

# File R/helpers.R: @tests

test_that("Function identify_section() @ L53", {
  expect_equal(identify_section(GEDCOM_HEADER(), 0, "HEAD", ""), 1:7)
  expect_equal(identify_section(GEDCOM_HEADER(), 1, "GEDC", "", first_only = TRUE), 2:5)
  expect_equal(identify_section(GEDCOM_HEADER(), 2, "FORM", "LINEAGE-LINKED"), 4:5)
  expect_equal(identify_section(GEDCOM_HEADER(), 3, "VERS", "5.5.5"), 5)
})


test_that("Function remove_section() @ L114", {
  expect_snapshot_value(remove_section(GEDCOM_HEADER(), 0, "HEAD", ""), "json2")
  expect_snapshot_value(remove_section(GEDCOM_HEADER(), 1, "GEDC", ""), "json2")
  expect_snapshot_value(remove_section(GEDCOM_HEADER(), 2, "FORM", "LINEAGE-LINKED"), "json2")
  expect_snapshot_value(remove_section(GEDCOM_HEADER(), 3, "VERS", "5.5.5"), "json2")
  expect_identical(remove_section(GEDCOM_HEADER(), 1, "GEDC1", ""), GEDCOM_HEADER())
})


test_that("Function set_class_to_tidyged() @ L150", {
  expect_identical(class(set_class_to_tidyged(tibble::tibble())),
                   c("tidyged", "tbl_df", "tbl", "data.frame"))
})


test_that("Function assign_xref_indi() @ L208", {
  expect_equal(assign_xref_indi(tibble::tibble(record = "@I6@")), "@I1@")
  expect_equal(assign_xref_famg(tibble::tibble(record = "@N6@")), "@F1@")
  expect_equal(assign_xref_note(tibble::tibble(record = "@N2@"), quantity = 2), c("@N1@", "@N3@"))
  expect_equal(assign_xref_repo(tibble::tibble(record = "@N6@")), "@R1@")
  expect_equal(assign_xref_sour(tibble::tibble(record = "@S1@")), "@S2@")
  expect_equal(assign_xref_media(tibble::tibble(record = "@S1@")), "@M1@")
  expect_equal(assign_xref_subm(ref = 2), "@U2@")
})


test_that("Function find_insertion_point() @ L250", {
  expect_equal(find_insertion_point(GEDCOM_HEADER(), "HD", 2, "VERS"), 4)
  expect_equal(find_insertion_point(GEDCOM_HEADER(), "HD", 3, "VERS"), 6)
  expect_equal(find_insertion_point(GEDCOM_HEADER(), "HD", 1, "CHAR"), 7)
})


test_that("Function gedcom_value() @ L290", {
  expect_equal(gedcom_value(GEDCOM_HEADER(), "HD", "FORM", 2), "LINEAGE-LINKED")
  expect_equal(gedcom_value(GEDCOM_HEADER(), "HD", "TEST", 1), "")
  expect_equal(gedcom_value(GEDCOM_HEADER(), "HD", "VERS", 2), "5.5.5")
  expect_equal(gedcom_value(GEDCOM_HEADER(), "HD", "VERS", 3), "5.5.5")
  expect_equal(gedcom_value(GEDCOM_HEADER(), "@I1@", "VERS", 3), "")
  expect_equal(gedcom_value(GEDCOM_HEADER(), "HD", "VERS", 3, "FORM"), "5.5.5")
})


test_that("Function construct_full_name() @ L342", {
  expect_error(construct_full_name(surname_prefix = "de la"))
  expect_equal(construct_full_name(given = "Joe"), "Joe")
  expect_equal(construct_full_name(prefix = "Professor", given = "Joe"), "Professor Joe")
  expect_equal(construct_full_name(given = "Joe,Adam"), "Joe Adam")
  expect_equal(construct_full_name(given = "Joey,Joe, Joe"), "Joey Joe Joe")
  expect_equal(construct_full_name(surname = "Bloggs"), "/Bloggs/")
  expect_equal(construct_full_name(suffix = "Jr."), "Jr.")
  expect_equal(construct_full_name(suffix = "Jr.,Esq."), "Jr. Esq.")
  expect_equal(construct_full_name(given = "Joe,Adam",
                                   surname_prefix = "de la", surname = "Bloggs",
                                   suffix = "Jr., Esq."),
               "Joe Adam de la /Bloggs/ Jr. Esq.")
})
jl5000/tidyged.internals documentation built on Aug. 21, 2022, 8:32 p.m.