mirror of
https://github.com/nushell/nushell
synced 2024-12-26 13:03:07 +00:00
Test for external quoted strings
This commit is contained in:
parent
7f1150d0fc
commit
4821707f96
2 changed files with 22 additions and 0 deletions
|
@ -165,6 +165,18 @@ pub fn file_contents(full_path: &str) -> String {
|
|||
contents
|
||||
}
|
||||
|
||||
pub fn normalize_string(input: &str) -> String {
|
||||
#[cfg(windows)]
|
||||
{
|
||||
input.to_string()
|
||||
}
|
||||
|
||||
#[cfg(not(windows))]
|
||||
{
|
||||
format!("\"{}\"", input)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn create_file_at(full_path: &str) {
|
||||
std::fs::write(PathBuf::from(full_path), "fake data".as_bytes()).expect("can not create file");
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
mod helpers;
|
||||
|
||||
use helpers::in_directory as cwd;
|
||||
use helpers::normalize_string;
|
||||
|
||||
#[test]
|
||||
fn external_num() {
|
||||
|
@ -13,6 +14,15 @@ fn external_num() {
|
|||
assert_eq!(output, "10");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn external_has_correct_quotes() {
|
||||
nu!(output, cwd("."), r#"echo "hello world""#);
|
||||
|
||||
let output = normalize_string(&output);
|
||||
|
||||
assert_eq!(output, r#""hello world""#);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inc_plugin() {
|
||||
nu!(
|
||||
|
|
Loading…
Reference in a new issue