Fix tests

This commit is contained in:
Andrej Kolchin 2024-08-01 22:45:33 +03:00
parent 318d6a4a2a
commit be816e52d7
4 changed files with 11 additions and 17 deletions

View File

@ -40,12 +40,12 @@ impl Command for DecodeBase32 {
Example {
description: "Decode an encoded string",
example: r#""NBUQ====" | decode base32 | decode"#,
result: Some(Value::test_string("hi")),
result: None,
},
Example {
description: "Parse a string without padding",
example: r#""NBUQ" | decode base32 --nopad"#,
result: Some(Value::test_binary(vec![68, 69])),
result: Some(Value::test_binary(vec![0x68, 0x69])),
},
]
}
@ -98,7 +98,6 @@ impl Command for EncodeBase32 {
(Type::String, Type::String),
(Type::Binary, Type::String),
])
.allow_variants_without_examples(true)
.switch("nopad", "Don't accept padding.", None)
.category(Category::Formats)
}

View File

@ -15,8 +15,7 @@ impl Command for DecodeBase32Hex {
fn signature(&self) -> Signature {
Signature::build("decode base32hex")
.input_output_types(vec![
(Type::String, Type::String),
(Type::Binary, Type::String),
(Type::String, Type::Binary),
])
.allow_variants_without_examples(true)
.switch("nopad", "Reject input with padding.", None)
@ -41,7 +40,7 @@ impl Command for DecodeBase32Hex {
Example {
description: "Decode an encoded string",
example: r#""D1KG====" | decode base32hex | decode"#,
result: Some(Value::test_string("hi")),
result: None,
},
Example {
description: "Parse a string without padding",
@ -101,7 +100,6 @@ impl Command for EncodeBase32Hex {
(Type::String, Type::String),
(Type::Binary, Type::String),
])
.allow_variants_without_examples(true)
.switch("nopad", "Don't pad the output.", None)
.category(Category::Formats)
}

View File

@ -62,17 +62,17 @@ impl Command for DecodeBase64 {
vec![
Example {
description: "Decode a Base64 string",
example: r#""U29tZSBEYXRh" | decode base64 | decode"#,
result: Some(Value::test_string("Some Data")),
example: r#""U29tZSBEYXRh" | decode new-base64 | decode"#,
result: None,
},
Example {
description: "Decode arbitrary data",
example: r#""/w==" | decode base64"#,
example: r#""/w==" | decode new-base64"#,
result: Some(Value::test_binary(vec![0xFF])),
},
Example {
description: "Decode a URL-safe Base64 string",
example: r#""_w==" | decode base64 --url"#,
example: r#""_w==" | decode new-base64 --url"#,
result: Some(Value::test_binary(vec![0xFF])),
},
]
@ -118,7 +118,6 @@ impl Command for EncodeBase64 {
(Type::String, Type::String),
(Type::Binary, Type::String),
])
.allow_variants_without_examples(true)
.switch("url", "Use the URL-safe Base64 version.", None)
.switch("nopad", "Don't pad the output.", None)
.category(Category::Formats)
@ -136,17 +135,17 @@ impl Command for EncodeBase64 {
vec![
Example {
description: "Encode a string with Base64",
example: r#""Alphabet from A to Z" | encode base64"#,
example: r#""Alphabet from A to Z" | encode new-base64"#,
result: Some(Value::test_string("QWxwaGFiZXQgZnJvbSBBIHRvIFo=")),
},
Example {
description: "Encode arbitrary data",
example: r#"0x[BE EE FF] | encode base64"#,
example: r#"0x[BE EE FF] | encode new-base64"#,
result: Some(Value::test_string("vu7/")),
},
Example {
description: "Use a URL-safe alphabet",
example: r#"0x[BE EE FF] | encode base64 --url"#,
example: r#"0x[BE EE FF] | encode new-base64 --url"#,
result: Some(Value::test_string("vu7_")),
},
]

View File

@ -11,7 +11,6 @@ impl Command for DecodeHex {
fn signature(&self) -> Signature {
Signature::build("decode hex")
.input_output_types(vec![(Type::String, Type::Binary)])
.allow_variants_without_examples(true)
.category(Category::Formats)
}
@ -72,7 +71,6 @@ impl Command for EncodeHex {
(Type::String, Type::String),
(Type::Binary, Type::String),
])
.allow_variants_without_examples(true)
.switch("lower", "Encode to lowercase hex.", None)
.category(Category::Formats)
}