mirror of
https://github.com/sharkdp/bat.git
synced 2025-02-22 21:08:40 +00:00
Rename test methods
This commit is contained in:
parent
dfd3ef022e
commit
eb2f3ddb7c
@ -246,7 +246,7 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn syntax_name_with_content(&self, file_name: &str, first_line: &str) -> String {
|
fn synax_for_file_with_content(&self, file_name: &str, first_line: &str) -> String {
|
||||||
let file_path = self.temp_dir.path().join(file_name);
|
let file_path = self.temp_dir.path().join(file_name);
|
||||||
{
|
{
|
||||||
let mut temp_file = File::create(&file_path).unwrap();
|
let mut temp_file = File::create(&file_path).unwrap();
|
||||||
@ -264,8 +264,8 @@ mod tests {
|
|||||||
syntax.name.clone()
|
syntax.name.clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn syntax_name(&self, file_name: &str) -> String {
|
fn syntax_for_file(&self, file_name: &str) -> String {
|
||||||
self.syntax_name_with_content(file_name, "")
|
self.synax_for_file_with_content(file_name, "")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -273,22 +273,25 @@ mod tests {
|
|||||||
fn syntax_detection_basic() {
|
fn syntax_detection_basic() {
|
||||||
let test = SyntaxDetectionTest::new();
|
let test = SyntaxDetectionTest::new();
|
||||||
|
|
||||||
assert_eq!(test.syntax_name("test.rs"), "Rust");
|
assert_eq!(test.syntax_for_file("test.rs"), "Rust");
|
||||||
assert_eq!(test.syntax_name("test.cpp"), "C++");
|
assert_eq!(test.syntax_for_file("test.cpp"), "C++");
|
||||||
assert_eq!(test.syntax_name("test.build"), "NAnt Build File");
|
assert_eq!(test.syntax_for_file("test.build"), "NAnt Build File");
|
||||||
assert_eq!(test.syntax_name("PKGBUILD"), "Bourne Again Shell (bash)");
|
assert_eq!(
|
||||||
assert_eq!(test.syntax_name(".bashrc"), "Bourne Again Shell (bash)");
|
test.syntax_for_file("PKGBUILD"),
|
||||||
assert_eq!(test.syntax_name("Makefile"), "Makefile");
|
"Bourne Again Shell (bash)"
|
||||||
|
);
|
||||||
|
assert_eq!(test.syntax_for_file(".bashrc"), "Bourne Again Shell (bash)");
|
||||||
|
assert_eq!(test.syntax_for_file("Makefile"), "Makefile");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn syntax_detection_well_defined_mapping_for_duplicate_extensions() {
|
fn syntax_detection_well_defined_mapping_for_duplicate_extensions() {
|
||||||
let test = SyntaxDetectionTest::new();
|
let test = SyntaxDetectionTest::new();
|
||||||
|
|
||||||
assert_eq!(test.syntax_name("test.h"), "C++");
|
assert_eq!(test.syntax_for_file("test.h"), "C++");
|
||||||
assert_eq!(test.syntax_name("test.sass"), "Sass");
|
assert_eq!(test.syntax_for_file("test.sass"), "Sass");
|
||||||
assert_eq!(test.syntax_name("test.hs"), "Haskell (improved)");
|
assert_eq!(test.syntax_for_file("test.hs"), "Haskell (improved)");
|
||||||
assert_eq!(test.syntax_name("test.js"), "JavaScript (Babel)");
|
assert_eq!(test.syntax_for_file("test.js"), "JavaScript (Babel)");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@ -296,35 +299,38 @@ mod tests {
|
|||||||
let test = SyntaxDetectionTest::new();
|
let test = SyntaxDetectionTest::new();
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
test.syntax_name_with_content("my_script", "#!/bin/bash"),
|
test.synax_for_file_with_content("my_script", "#!/bin/bash"),
|
||||||
"Bourne Again Shell (bash)"
|
"Bourne Again Shell (bash)"
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
test.syntax_name_with_content("build", "#!/bin/bash"),
|
test.synax_for_file_with_content("build", "#!/bin/bash"),
|
||||||
"Bourne Again Shell (bash)"
|
"Bourne Again Shell (bash)"
|
||||||
);
|
);
|
||||||
assert_eq!(test.syntax_name_with_content("my_script", "<?php"), "PHP");
|
assert_eq!(
|
||||||
|
test.synax_for_file_with_content("my_script", "<?php"),
|
||||||
|
"PHP"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn syntax_detection_with_custom_mapping() {
|
fn syntax_detection_with_custom_mapping() {
|
||||||
let mut test = SyntaxDetectionTest::new();
|
let mut test = SyntaxDetectionTest::new();
|
||||||
|
|
||||||
assert_eq!(test.syntax_name("test.h"), "C++");
|
assert_eq!(test.syntax_for_file("test.h"), "C++");
|
||||||
test.syntax_mapping
|
test.syntax_mapping
|
||||||
.insert("*.h", MappingTarget::MapTo("C"))
|
.insert("*.h", MappingTarget::MapTo("C"))
|
||||||
.ok();
|
.ok();
|
||||||
assert_eq!(test.syntax_name("test.h"), "C");
|
assert_eq!(test.syntax_for_file("test.h"), "C");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn syntax_detection_is_case_sensitive() {
|
fn syntax_detection_is_case_sensitive() {
|
||||||
let mut test = SyntaxDetectionTest::new();
|
let mut test = SyntaxDetectionTest::new();
|
||||||
|
|
||||||
assert_ne!(test.syntax_name("README.MD"), "Markdown");
|
assert_ne!(test.syntax_for_file("README.MD"), "Markdown");
|
||||||
test.syntax_mapping
|
test.syntax_mapping
|
||||||
.insert("*.MD", MappingTarget::MapTo("Markdown"))
|
.insert("*.MD", MappingTarget::MapTo("Markdown"))
|
||||||
.ok();
|
.ok();
|
||||||
assert_eq!(test.syntax_name("README.MD"), "Markdown");
|
assert_eq!(test.syntax_for_file("README.MD"), "Markdown");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user