package main
import (
"strings"
"testing"
)
// returns a minified version of the input HTML string
func TestMinifyHTML(t *testing.T) {
input := "
TestHello, World!
"
expected := "TestHello, World!
"
result := minifyHTML(input)
if result != expected {
t.Errorf("Expected minified HTML: %s, but got: %s", expected, result)
}
}
func TestMinifyCSS(t *testing.T) {
cssString := `
body {
background-color: red;
color: blue;
}
`
expected := "body{background-color:red;color:blue}"
result := minifyCSS(cssString)
if result != expected {
t.Errorf("Expected minified CSS string to be %s, but got %s", expected, result)
}
}
// Displays error messages if there are any parse errors
func TestErrorMessages(t *testing.T) {
// Initialize test data
h := HTMLData{}
parseResult := []ParseResult{
{IsError: true, Msg: "Error 1"},
{IsError: true, Msg: "Error 2"},
}
// Invoke function under test
result := fullHTML(h, parseResult)
// Assert that the result contains the error messages
if !strings.Contains(result, "Error 1") || !strings.Contains(result, "Error 2") {
t.Errorf("Expected error messages, but got: %s", result)
}
}