From bdc8ca54853b5be9909dec75f59f76feed5b1306 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrick=20F=C3=B6rster?= Date: Sun, 2 Jun 2019 15:41:50 +0200 Subject: [PATCH] Simplify assertions in tests --- src/completion/bibtex/entry_type.rs | 8 ++++---- src/completion/bibtex/field_name.rs | 10 +++++----- src/completion/bibtex/kernel_command.rs | 8 ++++---- src/completion/latex/argument_symbol.rs | 4 ++-- src/completion/latex/citation.rs | 4 ++-- src/completion/latex/color.rs | 4 ++-- src/completion/latex/color_model.rs | 6 +++--- src/completion/latex/kernel_command.rs | 6 +++--- src/completion/latex/kernel_environment.rs | 12 ++++++------ src/completion/latex/label.rs | 2 +- src/completion/latex/pgf_library.rs | 2 +- src/completion/latex/tikz_library.rs | 2 +- src/definition/latex_citation.rs | 4 ++-- src/definition/latex_label.rs | 4 ++-- src/folding/bibtex_declaration.rs | 6 +++--- src/folding/latex_environment.rs | 2 +- src/folding/latex_section.rs | 2 +- src/highlight/latex_label.rs | 4 ++-- src/link/latex_include.rs | 4 ++-- src/reference/bibtex_entry.rs | 2 +- src/reference/latex_label.rs | 2 +- tests/completion.rs | 10 +++++----- tests/diagnostics.rs | 2 +- tests/formatting.rs | 2 +- tests/hover.rs | 6 +++--- tests/synchronization.rs | 12 ++++-------- 26 files changed, 63 insertions(+), 67 deletions(-) diff --git a/src/completion/bibtex/entry_type.rs b/src/completion/bibtex/entry_type.rs index d36b0a354..539c04a28 100644 --- a/src/completion/bibtex/entry_type.rs +++ b/src/completion/bibtex/entry_type.rs @@ -74,7 +74,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.len() > 0, true); + assert!(!items.is_empty()); } #[test] @@ -88,7 +88,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.len() == 0, true); + assert!(items.is_empty()); } #[test] @@ -102,7 +102,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.len() == 0, true); + assert!(items.is_empty()); } #[test] @@ -116,6 +116,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.len() == 0, true); + assert!(items.is_empty()); } } diff --git a/src/completion/bibtex/field_name.rs b/src/completion/bibtex/field_name.rs index f14250507..0c6c0d161 100644 --- a/src/completion/bibtex/field_name.rs +++ b/src/completion/bibtex/field_name.rs @@ -73,7 +73,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.len() > 0, true); + assert!(!items.is_empty()); } #[test] @@ -90,7 +90,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.len() > 0, true); + assert!(!items.is_empty()); } #[test] @@ -104,7 +104,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.len() > 0, true); + assert!(!items.is_empty()); } #[test] @@ -118,7 +118,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.len() == 0, true); + assert!(items.is_empty()); } #[test] @@ -132,6 +132,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.len() == 0, true); + assert!(items.is_empty()); } } diff --git a/src/completion/bibtex/kernel_command.rs b/src/completion/bibtex/kernel_command.rs index b942611b6..8af7e8950 100644 --- a/src/completion/bibtex/kernel_command.rs +++ b/src/completion/bibtex/kernel_command.rs @@ -64,7 +64,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.len() > 0, true); + assert!(!items.is_empty()); } #[test] @@ -78,7 +78,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.len() == 0, true); + assert!(items.is_empty()); } #[test] @@ -92,7 +92,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.len() == 0, true); + assert!(items.is_empty()); } #[test] @@ -106,6 +106,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.len() == 0, true); + assert!(items.is_empty()); } } diff --git a/src/completion/latex/argument_symbol.rs b/src/completion/latex/argument_symbol.rs index 60d831259..46bfeef27 100644 --- a/src/completion/latex/argument_symbol.rs +++ b/src/completion/latex/argument_symbol.rs @@ -61,7 +61,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(true, items.len() > 0); + assert!(!items.is_empty()); } #[test] @@ -75,6 +75,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(true, items.len() == 0); + assert!(items.is_empty()); } } diff --git a/src/completion/latex/citation.rs b/src/completion/latex/citation.rs index 966b8ed77..3b206c25b 100644 --- a/src/completion/latex/citation.rs +++ b/src/completion/latex/citation.rs @@ -59,7 +59,7 @@ mod tests { }, ); assert_eq!(items.len(), 1); - assert_eq!("foo", items[0].label); + assert_eq!(items[0].label, "foo"); } #[test] @@ -77,6 +77,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items, Vec::new()); + assert!(items.is_empty()); } } diff --git a/src/completion/latex/color.rs b/src/completion/latex/color.rs index 001b08a41..f78fc0016 100644 --- a/src/completion/latex/color.rs +++ b/src/completion/latex/color.rs @@ -143,7 +143,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(true, items.iter().any(|item| item.label == "black")); + assert!(items.iter().any(|item| item.label == "black")); } #[test] @@ -157,6 +157,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items, Vec::new()); + assert!(items.is_empty()); } } diff --git a/src/completion/latex/color_model.rs b/src/completion/latex/color_model.rs index 8d666af90..ffd0d7697 100644 --- a/src/completion/latex/color_model.rs +++ b/src/completion/latex/color_model.rs @@ -78,7 +78,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.len() > 0, true); + assert!(!items.is_empty()); } #[test] @@ -92,7 +92,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items, Vec::new()); + assert!(items.is_empty()); } #[test] @@ -106,6 +106,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.len() > 0, true); + assert!(!items.is_empty()); } } diff --git a/src/completion/latex/kernel_command.rs b/src/completion/latex/kernel_command.rs index 9be1c06ca..1950fece4 100644 --- a/src/completion/latex/kernel_command.rs +++ b/src/completion/latex/kernel_command.rs @@ -52,7 +52,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.iter().any(|item| item.label == "usepackage"), true); + assert!(items.iter().any(|item| item.label == "usepackage")); } #[test] @@ -66,7 +66,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items, Vec::new()); + assert!(items.is_empty()); } #[test] @@ -80,6 +80,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items, Vec::new()); + assert!(items.is_empty()); } } diff --git a/src/completion/latex/kernel_environment.rs b/src/completion/latex/kernel_environment.rs index d70efc647..8b20f3d4b 100644 --- a/src/completion/latex/kernel_environment.rs +++ b/src/completion/latex/kernel_environment.rs @@ -52,7 +52,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.iter().any(|item| item.label == "document"), true); + assert!(items.iter().any(|item| item.label == "document")); } #[test] @@ -66,7 +66,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.iter().any(|item| item.label == "document"), true); + assert!(items.iter().any(|item| item.label == "document")); } #[test] @@ -80,7 +80,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items, Vec::new()); + assert!(items.is_empty()); } #[test] @@ -94,7 +94,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items, Vec::new()); + assert!(items.is_empty()); } #[test] @@ -108,7 +108,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items, Vec::new()); + assert!(items.is_empty()); } #[test] @@ -122,6 +122,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items, Vec::new()); + assert!(items.is_empty()); } } diff --git a/src/completion/latex/label.rs b/src/completion/latex/label.rs index 41f98a2cf..db5088f81 100644 --- a/src/completion/latex/label.rs +++ b/src/completion/latex/label.rs @@ -78,6 +78,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items, Vec::new()); + assert!(items.is_empty()); } } diff --git a/src/completion/latex/pgf_library.rs b/src/completion/latex/pgf_library.rs index a153db248..87c508b12 100644 --- a/src/completion/latex/pgf_library.rs +++ b/src/completion/latex/pgf_library.rs @@ -95,6 +95,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.iter().any(|item| item.label == "arrows"), true); + assert!(items.iter().any(|item| item.label == "arrows")); } } diff --git a/src/completion/latex/tikz_library.rs b/src/completion/latex/tikz_library.rs index 38ae365b2..be59c8fe8 100644 --- a/src/completion/latex/tikz_library.rs +++ b/src/completion/latex/tikz_library.rs @@ -125,6 +125,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(items.iter().any(|item| item.label == "arrows"), true); + assert!(items.iter().any(|item| item.label == "arrows")); } } diff --git a/src/definition/latex_citation.rs b/src/definition/latex_citation.rs index 57839a94f..ba3545060 100644 --- a/src/definition/latex_citation.rs +++ b/src/definition/latex_citation.rs @@ -97,7 +97,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(locations, Vec::new()); + assert!(locations.is_empty()); } #[test] @@ -111,6 +111,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(locations, Vec::new()); + assert!(locations.is_empty()); } } diff --git a/src/definition/latex_label.rs b/src/definition/latex_label.rs index 2e9348614..f8c5a8a6f 100644 --- a/src/definition/latex_label.rs +++ b/src/definition/latex_label.rs @@ -95,7 +95,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(locations, Vec::new()); + assert!(locations.is_empty()); } #[test] @@ -109,6 +109,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(locations, Vec::new()); + assert!(locations.is_empty()); } } diff --git a/src/folding/bibtex_declaration.rs b/src/folding/bibtex_declaration.rs index 1e7aa940a..8b57fdc75 100644 --- a/src/folding/bibtex_declaration.rs +++ b/src/folding/bibtex_declaration.rs @@ -132,7 +132,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(foldings, Vec::new()); + assert!(foldings.is_empty()); } #[test] @@ -145,7 +145,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(foldings, Vec::new()); + assert!(foldings.is_empty()); } #[test] @@ -158,6 +158,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(foldings, Vec::new()); + assert!(foldings.is_empty()); } } diff --git a/src/folding/latex_environment.rs b/src/folding/latex_environment.rs index 4f3d657d6..19faabfbb 100644 --- a/src/folding/latex_environment.rs +++ b/src/folding/latex_environment.rs @@ -71,6 +71,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(foldings, Vec::new()); + assert!(foldings.is_empty()); } } diff --git a/src/folding/latex_section.rs b/src/folding/latex_section.rs index abda98868..8d0147845 100644 --- a/src/folding/latex_section.rs +++ b/src/folding/latex_section.rs @@ -100,6 +100,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(foldings, Vec::new()); + assert!(foldings.is_empty()); } } diff --git a/src/highlight/latex_label.rs b/src/highlight/latex_label.rs index f80e8818b..3529b2d58 100644 --- a/src/highlight/latex_label.rs +++ b/src/highlight/latex_label.rs @@ -85,7 +85,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(highlights, Vec::new()); + assert!(highlights.is_empty()); } #[test] @@ -99,6 +99,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(highlights, Vec::new()); + assert!(highlights.is_empty()); } } diff --git a/src/link/latex_include.rs b/src/link/latex_include.rs index bc2717d1e..cb0e59503 100644 --- a/src/link/latex_include.rs +++ b/src/link/latex_include.rs @@ -83,7 +83,7 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(links, Vec::new()); + assert!(links.is_empty()); } #[test] @@ -97,6 +97,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(links, Vec::new()); + assert!(links.is_empty()); } } diff --git a/src/reference/bibtex_entry.rs b/src/reference/bibtex_entry.rs index 73dc2ae2f..f4e4b98c9 100644 --- a/src/reference/bibtex_entry.rs +++ b/src/reference/bibtex_entry.rs @@ -85,6 +85,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(references, Vec::new()); + assert!(references.is_empty()); } } diff --git a/src/reference/latex_label.rs b/src/reference/latex_label.rs index b37c06b0a..fbc9fd752 100644 --- a/src/reference/latex_label.rs +++ b/src/reference/latex_label.rs @@ -87,6 +87,6 @@ mod tests { ..FeatureSpec::default() }, ); - assert_eq!(references, Vec::new()); + assert!(references.is_empty()); } } diff --git a/tests/completion.rs b/tests/completion.rs index 7aad3ce68..815400ce0 100644 --- a/tests/completion.rs +++ b/tests/completion.rs @@ -31,7 +31,7 @@ pub async fn run(scenario: &'static str, file: &'static str, position: Position) fn test_kernel_command() { block_on(async move { let items = run("kernel", "foo.tex", Position::new(2, 5)).await; - assert_eq!(items.iter().any(|item| item == "usepackage"), true); + assert!(items.iter().any(|item| item == "usepackage")); }); } @@ -39,7 +39,7 @@ fn test_kernel_command() { fn test_kernel_command_bibtex() { block_on(async move { let items = run("kernel", "foo.bib", Position::new(1, 17)).await; - assert_eq!(items.iter().any(|item| item == "LaTeX"), true); + assert!(items.iter().any(|item| item == "LaTeX")); }); } @@ -47,7 +47,7 @@ fn test_kernel_command_bibtex() { fn test_kernel_environment() { block_on(async move { let items = run("kernel", "foo.tex", Position::new(4, 10)).await; - assert_eq!(items.iter().any(|item| item == "document"), true); + assert!(items.iter().any(|item| item == "document")); }); } @@ -55,8 +55,8 @@ fn test_kernel_environment() { fn test_user_command() { block_on(async move { let items = run("user", "foo.tex", Position::new(2, 3)).await; - assert_eq!(items.iter().all(|item| item != "fo"), true); - assert_eq!(items.iter().any(|item| item == "foo"), true); + assert!(items.iter().all(|item| item != "fo")); + assert!(items.iter().any(|item| item == "foo")); }); } diff --git a/tests/diagnostics.rs b/tests/diagnostics.rs index 8f248fc98..0f56c760d 100644 --- a/tests/diagnostics.rs +++ b/tests/diagnostics.rs @@ -40,7 +40,7 @@ fn test_lint_latex_disabled() { scenario.server.execute_actions().await; let diagnostics_by_uri = scenario.client.diagnostics_by_uri.lock().await; let diagnostics = diagnostics_by_uri.get(&scenario.uri("foo.tex")).unwrap(); - assert_eq!(diagnostics.len(), 0); + assert!(diagnostics.is_empty()); }); } diff --git a/tests/formatting.rs b/tests/formatting.rs index ad34b55c3..0c137c909 100644 --- a/tests/formatting.rs +++ b/tests/formatting.rs @@ -57,6 +57,6 @@ fn test_bibtex_entry_infinite_line_length() { fn test_latex() { block_on(async move { let (_, edits) = run("latex", "foo.tex", None).await; - assert_eq!(edits, Vec::new()); + assert!(edits.is_empty()); }) } diff --git a/tests/hover.rs b/tests/hover.rs index f03101484..e1d06da46 100644 --- a/tests/hover.rs +++ b/tests/hover.rs @@ -85,7 +85,7 @@ fn test_citation_bibtex() { fn test_citation_latex() { block_on(async move { let contents = run("latex/citation", "foo.tex", Position::new(2, 8)).await; - assert_eq!(contents.is_some(), true); + assert!(contents.is_some()); }); } @@ -93,7 +93,7 @@ fn test_citation_latex() { fn test_component_class() { block_on(async move { let contents = run("latex/component", "foo.tex", Position::new(0, 19)).await; - assert_eq!(contents.is_some(), true); + assert!(contents.is_some()); }); } @@ -101,7 +101,7 @@ fn test_component_class() { fn test_component_package() { block_on(async move { let contents = run("latex/component", "foo.tex", Position::new(2, 16)).await; - assert_eq!(contents.is_some(), true); + assert!(contents.is_some()); }); } diff --git a/tests/synchronization.rs b/tests/synchronization.rs index 9c8496696..40e167f02 100644 --- a/tests/synchronization.rs +++ b/tests/synchronization.rs @@ -41,13 +41,9 @@ fn test_did_change() { }; scenario.server.did_change(params); scenario.server.execute_actions().await; - assert_eq!( - run_completion(&scenario, "foo.tex", Position::new(0, 1)) - .await - .len() - > 0, - true - ); + assert!(!run_completion(&scenario, "foo.tex", Position::new(0, 1)) + .await + .is_empty()); }); } @@ -72,6 +68,6 @@ fn test_indexing() { scenario.server.did_change(params); scenario.server.execute_actions().await; let items = run_completion(&scenario, "foo.tex", Position::new(0, 1)).await; - assert_eq!(items.iter().any(|item| item.label == "foo"), true); + assert!(items.iter().any(|item| item.label == "foo")); }); }