Expected `any(grepl("^## Title 2$", output))` to be TRUE.
Differences:
`actual`:   FALSE
`expected`: TRUE

test_that("rtoqmd_addin exists and is a function", {
test_that("rtoqmd_addin has correct documentation", {
test_that("rtoqmd function has code_fold parameter", {
# Check function signature includes code_fold
test_that("rtoqmd generates YAML with code-fold option", {
rtoqmd(temp_r, temp_qmd, code_fold = TRUE)
rtoqmd(temp_r, temp_qmd, code_fold = FALSE)
test_that("rtoqmd default parameters are correct", {
test_that("rtoqmd handles RStudio code sections correctly", {
test_that("rtoqmd preserves inline comments in code blocks", {
# Inline comment should be in the code block
expect_true(any(grepl("# Select a column", output)))

"rtoqmd function has code_fold parameter"
"rtoqmd generates YAML with code-fold option"
"rtoqmd handles RStudio code sections correctly"
"rtoqmd preserves inline comments in code blocks"

rtoqmd handles RStudio code sections correctly

Expected `any(grepl("^### Title 3$", output))` to be TRUE.
Differences:
`actual`:   FALSE
`expected`: TRUE

Expected `any(grepl("^#### Title 4$", output))` to be TRUE.
Differences:
`actual`:   FALSE
`expected`: TRUE

Expected `any(output == "## Section with hash")` to be TRUE.
Differences:
`actual`:   FALSE
`expected`: TRUE

test_that("rtoqmd converts basic R script to Quarto markdown", {
rtoqmd(temp_r, temp_qmd, title = "Test", author = "Tester")
expect_true(any(grepl("This is a comment", output)))
# Check code block and YAML execute options
test_that("rtoqmd handles multiple header levels", {
test_that("rtoqmd groups consecutive code lines", {
# Should have one code block containing all three lines
expect_true(any(grepl("z <- x \\+ y", output)))
test_that("rtoqmd converts roxygen comments to callouts", {
# Roxygen comments should be converted to callout-note
expect_true(any(grepl("This is a regular comment", output)))
test_that("rtoqmd uses default output filename when not provided", {
expected_qmd <- sub("\\.R$", ".qmd", temp_r)
test_that("rtoqmd throws error for non-existent input file", {
test_that("rtoqmd handles empty lines correctly", {
# Should group code despite empty lines between
test_that("rtoqmd separates code blocks by comments", {
test_that("rtoqmd customizes YAML header", {
test_that("rtoqmd handles markdown tables in comments", {
rtoqmd(temp_r, temp_qmd, render = FALSE)
# Find consecutive comment lines (table should be together)
# Look for the table example line and check following lines
table_intro_line <- grep("Table example:", output)[1]
# The next few lines should be the table without empty lines between them
expect_true(grepl("\\| fruit", output[table_intro_line + 1]))
expect_true(grepl("\\| apple", output[table_intro_line + 3]))
test_that("rtoqmd number_sections parameter works correctly", {
# Test with number_sections = TRUE (default)
rtoqmd(temp_r, temp_qmd, render = FALSE, number_sections = FALSE)
test_that("rtoqmd extracts metadata from comments - French version", {
"# Description : Analyser les données iris",
expect_true(any(grepl('title: "Analyse des iris"', output)))
expect_true(any(grepl('description: "Analyser les données iris"', output)))
# Check metadata lines are not in the body of the document
body_start <- grep("^---$", output)[2] + 1
test_that("rtoqmd extracts metadata from comments - English version", {
expect_true(any(grepl('description: "Analyze iris dataset"', output)))
# Check metadata lines are not in the body
test_that("rtoqmd uses function parameters when no metadata in script", {
test_that("rtoqmd metadata overrides function parameters", {
# Metadata should override function parameters
test_that("rtoqmd converts callout-note with title", {
expect_true(any(grepl('^::: \\{\\.callout-note title="This is a note"\\}$', output)))
expect_true(any(grepl("This is the content of the note", output)))
expect_true(any(grepl("It can have multiple lines", output)))
test_that("rtoqmd converts callout-tip without title", {
expect_true(any(grepl("Here is a useful tip", output)))
test_that("rtoqmd converts callout-warning with title", {
"# callout-warning - Important Warning",
expect_true(any(grepl('^::: \\{\\.callout-warning title="Important Warning"\\}$', output)))
expect_true(any(grepl("Be careful with this operation", output)))
test_that("rtoqmd converts callout-caution with title", {
"# callout-caution - Proceed with Caution",
expect_true(any(grepl('^::: \\{\\.callout-caution title="Proceed with Caution"\\}$', output)))
expect_true(any(grepl("This may cause unexpected results", output)))
test_that("rtoqmd converts callout-important without title", {
expect_true(any(grepl("This is very important information", output)))
expect_true(any(grepl("Do not ignore this", output)))
test_that("rtoqmd handles multiple callouts in same file", {
expect_true(any(grepl('^::: \\{\\.callout-note title="First Note"\\}$', output)))
expect_true(any(grepl("Content of first note", output)))
expect_true(any(grepl('^::: \\{\\.callout-tip title="Second Tip"\\}$', output)))
expect_true(any(grepl("Content of second tip", output)))
test_that("rtoqmd handles multi-line description", {
"# Description : This is a long description",
"#   that continues on the second line",
# Check that description is present and concatenated
expect_true(grepl("This is a long description", desc_line))
expect_true(grepl("that continues on the second line", desc_line))
expect_true(grepl("and even on a third line", desc_line))
# Check that description lines are not in the body
body_start <- which(grepl("^---$", output))[2] + 1
expect_false(any(grepl("This is a long description", body)))
test_that("rtoqmd removes trailing symbols from section titles", {
# Create R script with various trailing symbols
rtoqmd(temp_r, output_file = temp_qmd, title = "Test", author = "Test Author")
# Check that titles don't contain trailing symbols
expect_true(any(output == "## Section with hash"))
expect_true(any(output == "## Section with many hashes"))
expect_true(any(output == "### Section with equals"))
expect_true(any(output == "### Section with many equals"))
expect_true(any(output == "#### Section with dashes"))
expect_true(any(output == "#### Section with many dashes"))
expect_true(any(output == "## Mixed symbols with hash"))
expect_true(any(output == "### Mixed symbols with equals"))
expect_true(any(output == "#### Mixed symbols with dashes"))
# Verify that no trailing symbols remain in titles
title_lines <- grep("^#{2,4}\\s+", output, value = TRUE)