Update documentation and add test for hex_to_string
parent
96fd50f78c
commit
1f93e4531f
|
@ -11,7 +11,9 @@ use std::env;
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ~~~
|
/// ~~~
|
||||||
/// hex_to_string("49") => I
|
/// let test: Vec<String> = vec![String::from("41"),
|
||||||
|
/// String::from("42")];
|
||||||
|
/// assert_eq!(hex_to_string(&test), "AB");
|
||||||
/// ~~~
|
/// ~~~
|
||||||
fn hex_to_string(hex_char: &Vec<String>) -> String {
|
fn hex_to_string(hex_char: &Vec<String>) -> String {
|
||||||
let mut output = String::new();
|
let mut output = String::new();
|
||||||
|
@ -30,7 +32,7 @@ fn hex_to_string(hex_char: &Vec<String>) -> String {
|
||||||
/// # Examples
|
/// # Examples
|
||||||
///
|
///
|
||||||
/// ~~~
|
/// ~~~
|
||||||
/// let test: Vec<u8> = vec![0x41, 0x42];
|
/// let test: Vec<u8> = vec![0x41, 0x42]; // "[A,B] in ascii"
|
||||||
/// let b64_encode = base64_encode(&test);
|
/// let b64_encode = base64_encode(&test);
|
||||||
/// assert_eq!(b64_encode, "QUI=");
|
/// assert_eq!(b64_encode, "QUI=");
|
||||||
/// ~~~
|
/// ~~~
|
||||||
|
@ -91,11 +93,16 @@ fn base64_encode(input: &Vec<u8>) -> String {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
// Test Base64 encode
|
// Test base64 encode()
|
||||||
let test: Vec<u8> = vec![0x41, 0x42]; // "[A,B] in ascii"
|
let test: Vec<u8> = vec![0x41, 0x42];
|
||||||
let b64_encode = base64_encode(&test);
|
let b64_encode = base64_encode(&test);
|
||||||
assert_eq!(b64_encode, "QUI=");
|
assert_eq!(b64_encode, "QUI=");
|
||||||
|
|
||||||
|
// Test hex_to_string()
|
||||||
|
let test: Vec<String> = vec![String::from("41"),
|
||||||
|
String::from("42")];
|
||||||
|
assert_eq!(hex_to_string(&test), "AB");
|
||||||
|
|
||||||
let args: Vec<String> = env::args().collect();
|
let args: Vec<String> = env::args().collect();
|
||||||
let input = &args[1];
|
let input = &args[1];
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue