#+test package main import "core:testing" // --- generate_summary --- @(test) test_summary_short :: proc(t: ^testing.T) { result := generate_summary("

Hello world

") testing.expect_value(t, result, "

Hello world

") } @(test) test_summary_word_limit :: proc(t: ^testing.T) { result := generate_summary("

one two three four five

", max_words = 3) testing.expect_value(t, result, "

one two three") } @(test) test_summary_empty :: proc(t: ^testing.T) { result := generate_summary("") testing.expect_value(t, result, "") } @(test) test_summary_no_words :: proc(t: ^testing.T) { result := generate_summary("

") testing.expect_value(t, result, "

") } @(test) test_summary_tags_not_counted :: proc(t: ^testing.T) { html := `
if x
` result := generate_summary(html, max_words = 1) testing.expect_value(t, result, `
if`)
}

// --- generate_description ---

@(test)
test_description_simple :: proc(t: ^testing.T) {
	result := generate_description("

Hello world

") testing.expect_value(t, result, "Hello world") } @(test) test_description_entities :: proc(t: ^testing.T) { result := generate_description("

Cats & dogs <3

") testing.expect_value(t, result, "Cats & dogs <3") } @(test) test_description_nested_tags :: proc(t: ^testing.T) { result := generate_description("

Bold text

") testing.expect_value(t, result, "Bold text") } @(test) test_description_block_boundary :: proc(t: ^testing.T) { result := generate_description("

First

Second

") testing.expect_value(t, result, "First Second") } @(test) test_description_whitespace_collapse :: proc(t: ^testing.T) { result := generate_description("

Multiple spaces

") testing.expect_value(t, result, "Multiple spaces") } @(test) test_description_empty :: proc(t: ^testing.T) { result := generate_description("") testing.expect_value(t, result, "") } @(test) test_description_plain_text :: proc(t: ^testing.T) { result := generate_description("Just plain text") testing.expect_value(t, result, "Just plain text") } @(test) test_description_highlighted_code :: proc(t: ^testing.T) { result := generate_description( `
if x
`, ) testing.expect_value(t, result, "if x") } @(test) test_description_list_items :: proc(t: ^testing.T) { result := generate_description("
  • One
  • Two
") testing.expect_value(t, result, "One Two") } @(test) test_description_headings :: proc(t: ^testing.T) { result := generate_description("

Title

Body

") testing.expect_value(t, result, "Title Body") } @(test) test_description_blockquote :: proc(t: ^testing.T) { result := generate_description("
Quote
") testing.expect_value(t, result, "Quote") }