# WARNING - Generated by {fusen} from dev/flat_chars_structure.Rmd: do not edit by hand

test_that("Valid outputs are consistent", {
  
  library(magrittr)
  input <- c("ABC123", "DE4F56", "789GHI", "ABC123")
  
  # Default values of unique and named_output: 
  unique_named <- chars_structure(input_vector = input, unique = TRUE, named_output = TRUE)
  
  # unique is set to default value TRUE and named_output is set to FALSE: 
  unique_nonamed <- chars_structure(input_vector = input, unique = TRUE, named_output = FALSE)
  
  # unique is set to FALSE and named_output to FALSE: 
  nounique_nonamed <- chars_structure(input_vector = input, unique = FALSE, named_output = FALSE)
  
  # unique is set to FALSE and named_output to defalut value TRUE: 
  nounique_named <- chars_structure(input_vector = input, unique = FALSE, named_output = TRUE)
  
  expect_identical(
    object = unique_named, 
    expected = c(ABC123 = "3A, 3D", 
                 DE4F56 = "2A, 1D, 1A, 2D", 
                 `789GHI` = "3D, 3A"))
  
  expect_identical(
    object = unique_nonamed, 
    expected = c("3A, 3D", "2A, 1D, 1A, 2D", "3D, 3A"))

  expect_identical(
    object = nounique_nonamed, 
    expected = c("3A, 3D", "2A, 1D, 1A, 2D", "3D, 3A", "3A, 3D"))
    
  expect_identical(
    object = nounique_named, 
    expected = c(ABC123 = "3A, 3D", 
                 DE4F56 = "2A, 1D, 1A, 2D", 
                 `789GHI` = "3D, 3A", 
                 ABC123 = "3A, 3D"))
})

test_that("Errors are consistent", {
  
  expect_error(
    object = chars_structure(input_vector = c(1, 2, 3)),
    regexp = "input_vector must be a character vector")
})
