#!/bin/sh
# debian/tests/functional
set -e

cat > test-input.tex <<'EOF'
\documentclass{article}
\begin{document}
\section{Introduction}
This is a \textbf{bold} statement and some \emph{emphasized} text.
Here is a \cite{somekey} reference and a \ref{somefig} link.
\end{document}
EOF

untex test-input.tex > test-output.txt

if grep -q '\\' test-output.txt; then
    echo "FAIL: Output still contains LaTeX commands."
    cat test-output.txt
    exit 1
fi

if ! grep -q 'bold' test-output.txt; then
    echo "FAIL, 'bold' removed."
    exit 1
fi
if ! grep -q 'emphasized' test-output.txt; then
    echo "FAIL, 'emphasized' removed."
    exit 1
fi

echo "PASS"
