tests/testthat/test-basic.R

test_that("allele_to_binary returns the expected nested list structure", {
  # 1. Locate the packaged test data files
  data_path <- system.file("extdata", "data.txt", package = "ALSBinary")
  repeat_path <- system.file("extdata", "repeat_length.txt", package = "ALSBinary")
  
  expect_true(data_path != "", info = "data.txt missing from extdata")
  expect_true(repeat_path != "", info = "repeat_length.txt missing from extdata")
  
  # 2. Load and set up data
  my_data <- read.delim(data_path, header = FALSE)
  colnames(my_data) <- c("Marker", "Genotype", "Allele_1", "Allele_2")
  
  repeat_info <- read.delim(repeat_path, header = FALSE)
  colnames(repeat_info) <- c("RepeatLength")
  
  # 3. Run the binary conversion
  results <- allele_to_binary(my_data, repeat_info)
  
  # 4. Corrected Assertions
  expect_type(results, "list")
  
  # FIX: Accept both names that your function returns
  expect_named(results, c("binary", "structure")) 
  
  expect_type(results$binary, "list") 
  
  # Test the first marker's matrix inside the list
  first_marker_matrix <- results$binary[[1]]
  expect_true(is.matrix(first_marker_matrix))
  expect_true(all(first_marker_matrix %in% c(0, 1, NA)))
})

test_that("als_binary returns a shiny app object", {
  app <- als_binary()
  expect_s3_class(app, "shiny.appobj")
})

Try the ALSBinary package in your browser

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

ALSBinary documentation built on Aug. 9, 2026, 5:06 p.m.