Skip to content

Commit

Permalink
Refactor unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pfoerster committed May 22, 2019
1 parent 28e0b56 commit 3232833
Show file tree
Hide file tree
Showing 30 changed files with 84 additions and 193 deletions.
13 changes: 4 additions & 9 deletions src/completion/bibtex/entry_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ impl BibtexEntryTypeCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand All @@ -59,8 +58,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.bib", "@"),],
main_file: "foo.bib",
position: Position::new(0, 1),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.len() > 0, true);
Expand All @@ -74,8 +72,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.bib", "@article{foo,}"),],
main_file: "foo.bib",
position: Position::new(0, 11),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.len() == 0, true);
Expand All @@ -89,8 +86,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.bib", "foo"),],
main_file: "foo.bib",
position: Position::new(0, 2),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.len() == 0, true);
Expand All @@ -104,8 +100,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "@"),],
main_file: "foo.tex",
position: Position::new(0, 1),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.len() == 0, true);
Expand Down
16 changes: 5 additions & 11 deletions src/completion/bibtex/field_name.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ impl BibtexFieldNameCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand All @@ -58,8 +57,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.bib", "@article{foo,\nbar}"),],
main_file: "foo.bib",
position: Position::new(1, 1),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.len() > 0, true);
Expand All @@ -76,8 +74,7 @@ mod tests {
),],
main_file: "foo.bib",
position: Position::new(0, 27),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.len() > 0, true);
Expand All @@ -91,8 +88,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.bib", "@article{foo, \n}"),],
main_file: "foo.bib",
position: Position::new(1, 0),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.len() > 0, true);
Expand All @@ -106,8 +102,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.bib", "@article{foo,\nbar = {baz}}"),],
main_file: "foo.bib",
position: Position::new(1, 7),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.len() == 0, true);
Expand All @@ -121,8 +116,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.bib", "@article{foo,}"),],
main_file: "foo.bib",
position: Position::new(0, 3),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.len() == 0, true);
Expand Down
13 changes: 4 additions & 9 deletions src/completion/bibtex/kernel_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ impl BibtexKernelCommandCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand All @@ -48,8 +47,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.bib", "@article{foo, bar=\n\\}")],
main_file: "foo.bib",
position: Position::new(1, 1),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.len() > 0, true);
Expand All @@ -63,8 +61,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.bib", "@article{foo, bar=\n\\}")],
main_file: "foo.bib",
position: Position::new(1, 0),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.len() == 0, true);
Expand All @@ -78,8 +75,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.bib", "@article{foo, bar=\n}")],
main_file: "foo.bib",
position: Position::new(1, 0),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.len() == 0, true);
Expand All @@ -93,8 +89,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\")],
main_file: "foo.tex",
position: Position::new(0, 1),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.len() == 0, true);
Expand Down
7 changes: 2 additions & 5 deletions src/completion/latex/argument_symbol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ impl LatexArgumentSymbolCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand All @@ -48,8 +47,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\mathbb{}")],
main_file: "foo.tex",
position: Position::new(0, 8),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(true, items.len() > 0);
Expand All @@ -63,8 +61,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\mathbb{}")],
main_file: "foo.tex",
position: Position::new(0, 9),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(true, items.len() == 0);
Expand Down
7 changes: 2 additions & 5 deletions src/completion/latex/citation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ impl LatexCitationCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand All @@ -50,8 +49,7 @@ mod tests {
],
main_file: "foo.tex",
position: Position::new(1, 6),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.len(), 1);
Expand All @@ -70,8 +68,7 @@ mod tests {
],
main_file: "foo.tex",
position: Position::new(1, 7),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items, Vec::new());
Expand Down
7 changes: 2 additions & 5 deletions src/completion/latex/color.rs
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,6 @@ const COLOR_NAMES: &[&str] = &[
#[cfg(test)]
mod tests {
use super::*;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand All @@ -137,8 +136,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\color{}")],
main_file: "foo.tex",
position: Position::new(0, 7),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(true, items.iter().any(|item| item.label == "black"));
Expand All @@ -152,8 +150,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\color{}")],
main_file: "foo.tex",
position: Position::new(0, 8),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items, Vec::new());
Expand Down
10 changes: 3 additions & 7 deletions src/completion/latex/color_model.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ const MODEL_NAMES: &[&str] = &["gray", "rgb", "RGB", "HTML", "cmyk"];
#[cfg(test)]
mod tests {
use super::*;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand All @@ -64,8 +63,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\definecolor{name}{}")],
main_file: "foo.tex",
position: Position::new(0, 19),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items, LatexColorModelCompletionProvider::generate_items());
Expand All @@ -79,8 +77,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\definecolor{name}{}")],
main_file: "foo.tex",
position: Position::new(0, 18),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items, Vec::new());
Expand All @@ -94,8 +91,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\definecolorset{}")],
main_file: "foo.tex",
position: Position::new(0, 16),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items, LatexColorModelCompletionProvider::generate_items());
Expand Down
10 changes: 3 additions & 7 deletions src/completion/latex/kernel_command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ impl LatexKernelCommandCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand All @@ -35,8 +34,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\use")],
main_file: "foo.tex",
position: Position::new(0, 4),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.iter().any(|item| item.label == "usepackage"), true);
Expand All @@ -50,8 +48,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\use")],
main_file: "foo.tex",
position: Position::new(0, 0),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items, Vec::new());
Expand All @@ -65,8 +62,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "{%\\use}")],
main_file: "foo.tex",
position: Position::new(0, 4),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items, Vec::new());
Expand Down
19 changes: 6 additions & 13 deletions src/completion/latex/kernel_environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ impl LatexKernelEnvironmentCompletionProvider {
#[cfg(test)]
mod tests {
use super::*;
use crate::data::completion::LatexComponentDatabase;
use crate::feature::FeatureSpec;
use crate::test_feature;
use lsp_types::Position;
Expand All @@ -37,8 +36,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\begin{}")],
main_file: "foo.tex",
position: Position::new(0, 7),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.iter().any(|item| item.label == "document"), true);
Expand All @@ -52,8 +50,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\end{foo}")],
main_file: "foo.tex",
position: Position::new(0, 6),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items.iter().any(|item| item.label == "document"), true);
Expand All @@ -67,8 +64,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\begin{}")],
main_file: "foo.tex",
position: Position::new(0, 6),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items, Vec::new());
Expand All @@ -82,8 +78,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\end{}")],
main_file: "foo.tex",
position: Position::new(0, 6),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items, Vec::new());
Expand All @@ -97,8 +92,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\foo{bar}")],
main_file: "foo.tex",
position: Position::new(0, 6),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items, Vec::new());
Expand All @@ -112,8 +106,7 @@ mod tests {
files: vec![FeatureSpec::file("foo.tex", "\\begin{foo}{bar}")],
main_file: "foo.tex",
position: Position::new(0, 14),
new_name: "",
component_database: LatexComponentDatabase::default(),
..FeatureSpec::default()
}
);
assert_eq!(items, Vec::new());
Expand Down
Loading

0 comments on commit 3232833

Please sign in to comment.