Skip to content

Instantly share code, notes, and snippets.

@sassman
Created September 8, 2019 22:18
Show Gist options
  • Save sassman/49920f84d5d801f2d6733389a8e19eaa to your computer and use it in GitHub Desktop.
Save sassman/49920f84d5d801f2d6733389a8e19eaa to your computer and use it in GitHub Desktop.
rust tdd: test/alphabet_position_spec.rs
// test/alphabet_position_spec.rs
use dev_challenge_47::alphabet_position;
use speculate::speculate;
speculate! { // <-- it's a macro but who cares
describe "alphabet_position" {
it "should replace 'a' with 1" {
assert_eq!(alphabet_position("a"), "1");
}
it "should replace 'A' with 1" {
assert_eq!(alphabet_position("A"), "1");
}
it "should ignore non characters" {
assert_eq!(alphabet_position("'a a. 2"), "1 1");
}
it "should replace the full test sentence" {
assert_eq!(
alphabet_position("The sunset sets at twelve o' clock."),
"20 8 5 19 21 14 19 5 20 19 5 20 19 1 20 20 23 5 12 22 5 15 3 12 15 3 11"
);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment