use codebook::queries::LanguageType;
use super::utils::{assert_spelling, assert_spelling_at};
#[test]
fn test_latex_comments() {
let sample_text = r#"
% This is a coment with a typo
% Another commnet with wrng spelling
\documentclass{article}
"#;
assert_spelling(
LanguageType::Latex,
sample_text,
&["coment", "commnet", "wrng"],
&["documentclass", "article"],
);
}
#[test]
fn test_latex_text_content() {
let sample_text = r#"
\section{Introducton}
This is an exampl of text with speling errors.
"#;
assert_spelling(
LanguageType::Latex,
sample_text,
&["Introducton", "exampl", "speling"],
&[],
);
}
#[test]
fn test_latex_sections_and_text() {
let sample_text = r#"
\section{Methology}
The methology section describs the approach.
\subsection{Bakground}
In this secion we discuss importnt concepts.
"#;
assert_spelling(
LanguageType::Latex,
sample_text,
&[
"Bakground",
"Methology",
"describs",
"importnt",
"methology",
"secion",
],
&[],
);
}
#[test]
fn test_latex_itemize() {
let sample_text = r#"
\begin{itemize}
\item First itm with algoritm
\item Second itm about formulas
\end{itemize}
"#;
assert_spelling_at(
LanguageType::Latex,
sample_text,
&[("algoritm", &[0]), ("itm", &[0, 2])],
);
}
#[test]
fn test_latex_mixed_content() {
let sample_text = r#"
% Comment: calcuate the result
\section{Resuts}
The resuts show our aproach is efective.
\begin{equation}
E = mc^2 \label{eq:enrgy}
\end{equation}
As shown in Equation~\ref{eq:enrgy}, the relatioship is clear.
"#;
assert_spelling_at(
LanguageType::Latex,
sample_text,
&[
("Resuts", &[0]),
("aproach", &[0]),
("calcuate", &[0]),
("efective", &[0]),
("enrgy", &[0, 1]),
("relatioship", &[0]),
("resuts", &[0]),
],
);
}
#[test]
fn test_latex_comprehensive() {
let sample_text = r#"
\documentclass{article}
% This coment has typos: wrng and speling
\title{A Sampel Document}
\begin{document}
\section{Introducton}
This docment demonstrates the spel checker.
\subsection{Analyss}
The analyss reveals paterns in the data.
\end{document}
"#;
assert_spelling_at(
LanguageType::Latex,
sample_text,
&[
("Analyss", &[0]),
("Introducton", &[0]),
("Sampel", &[0]),
("analyss", &[0]),
("coment", &[0]),
("docment", &[0]),
("paterns", &[0]),
("spel", &[1]),
("speling", &[0]),
("wrng", &[0]),
],
);
}