Skip to content

Commit

Permalink
sync all exercises with changed tera templates
Browse files Browse the repository at this point in the history
  • Loading branch information
senekor committed Mar 31, 2024
1 parent 511d188 commit c8d6bb1
Show file tree
Hide file tree
Showing 16 changed files with 243 additions and 211 deletions.
34 changes: 18 additions & 16 deletions exercises/practice/affine-cipher/tests/affine-cipher.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
use affine_cipher::*;

use affine_cipher::AffineCipherError::NotCoprime;

#[test]
fn encode_yes() {
let phrase = "yes";
let (a, b) = (5, 7);
let output = affine_cipher::encode(phrase, a, b);
let output = encode(phrase, a, b);
let expected = Ok("xbt".into());
assert_eq!(output, expected);
}
Expand All @@ -14,7 +16,7 @@ fn encode_yes() {
fn encode_no() {
let phrase = "no";
let (a, b) = (15, 18);
let output = affine_cipher::encode(phrase, a, b);
let output = encode(phrase, a, b);
let expected = Ok("fu".into());
assert_eq!(output, expected);
}
Expand All @@ -24,7 +26,7 @@ fn encode_no() {
fn encode_omg() {
let phrase = "OMG";
let (a, b) = (21, 3);
let output = affine_cipher::encode(phrase, a, b);
let output = encode(phrase, a, b);
let expected = Ok("lvz".into());
assert_eq!(output, expected);
}
Expand All @@ -34,7 +36,7 @@ fn encode_omg() {
fn encode_o_m_g() {
let phrase = "O M G";
let (a, b) = (25, 47);
let output = affine_cipher::encode(phrase, a, b);
let output = encode(phrase, a, b);
let expected = Ok("hjp".into());
assert_eq!(output, expected);
}
Expand All @@ -44,7 +46,7 @@ fn encode_o_m_g() {
fn encode_mindblowingly() {
let phrase = "mindblowingly";
let (a, b) = (11, 15);
let output = affine_cipher::encode(phrase, a, b);
let output = encode(phrase, a, b);
let expected = Ok("rzcwa gnxzc dgt".into());
assert_eq!(output, expected);
}
Expand All @@ -54,7 +56,7 @@ fn encode_mindblowingly() {
fn encode_numbers() {
let phrase = "Testing,1 2 3, testing.";
let (a, b) = (3, 4);
let output = affine_cipher::encode(phrase, a, b);
let output = encode(phrase, a, b);
let expected = Ok("jqgjc rw123 jqgjc rw".into());
assert_eq!(output, expected);
}
Expand All @@ -64,7 +66,7 @@ fn encode_numbers() {
fn encode_deep_thought() {
let phrase = "Truth is fiction.";
let (a, b) = (5, 17);
let output = affine_cipher::encode(phrase, a, b);
let output = encode(phrase, a, b);
let expected = Ok("iynia fdqfb ifje".into());
assert_eq!(output, expected);
}
Expand All @@ -74,7 +76,7 @@ fn encode_deep_thought() {
fn encode_all_the_letters() {
let phrase = "The quick brown fox jumps over the lazy dog.";
let (a, b) = (17, 33);
let output = affine_cipher::encode(phrase, a, b);
let output = encode(phrase, a, b);
let expected = Ok("swxtj npvyk lruol iejdc blaxk swxmh qzglf".into());
assert_eq!(output, expected);
}
Expand All @@ -84,7 +86,7 @@ fn encode_all_the_letters() {
fn encode_with_a_not_coprime_to_m() {
let phrase = "This is a test.";
let (a, b) = (6, 17);
let output = affine_cipher::encode(phrase, a, b);
let output = encode(phrase, a, b);
let expected = Err(NotCoprime(6));
assert_eq!(output, expected);
}
Expand All @@ -94,7 +96,7 @@ fn encode_with_a_not_coprime_to_m() {
fn decode_exercism() {
let phrase = "tytgn fjr";
let (a, b) = (3, 7);
let output = affine_cipher::decode(phrase, a, b);
let output = decode(phrase, a, b);
let expected = Ok("exercism".into());
assert_eq!(output, expected);
}
Expand All @@ -104,7 +106,7 @@ fn decode_exercism() {
fn decode_a_sentence() {
let phrase = "qdwju nqcro muwhn odqun oppmd aunwd o";
let (a, b) = (19, 16);
let output = affine_cipher::decode(phrase, a, b);
let output = decode(phrase, a, b);
let expected = Ok("anobstacleisoftenasteppingstone".into());
assert_eq!(output, expected);
}
Expand All @@ -114,7 +116,7 @@ fn decode_a_sentence() {
fn decode_numbers() {
let phrase = "odpoz ub123 odpoz ub";
let (a, b) = (25, 7);
let output = affine_cipher::decode(phrase, a, b);
let output = decode(phrase, a, b);
let expected = Ok("testing123testing".into());
assert_eq!(output, expected);
}
Expand All @@ -124,7 +126,7 @@ fn decode_numbers() {
fn decode_all_the_letters() {
let phrase = "swxtj npvyk lruol iejdc blaxk swxmh qzglf";
let (a, b) = (17, 33);
let output = affine_cipher::decode(phrase, a, b);
let output = decode(phrase, a, b);
let expected = Ok("thequickbrownfoxjumpsoverthelazydog".into());
assert_eq!(output, expected);
}
Expand All @@ -134,7 +136,7 @@ fn decode_all_the_letters() {
fn decode_with_no_spaces_in_input() {
let phrase = "swxtjnpvyklruoliejdcblaxkswxmhqzglf";
let (a, b) = (17, 33);
let output = affine_cipher::decode(phrase, a, b);
let output = decode(phrase, a, b);
let expected = Ok("thequickbrownfoxjumpsoverthelazydog".into());
assert_eq!(output, expected);
}
Expand All @@ -144,7 +146,7 @@ fn decode_with_no_spaces_in_input() {
fn decode_with_too_many_spaces() {
let phrase = "vszzm cly yd cg qdp";
let (a, b) = (15, 16);
let output = affine_cipher::decode(phrase, a, b);
let output = decode(phrase, a, b);
let expected = Ok("jollygreengiant".into());
assert_eq!(output, expected);
}
Expand All @@ -154,7 +156,7 @@ fn decode_with_too_many_spaces() {
fn decode_with_a_not_coprime_to_m() {
let phrase = "Test";
let (a, b) = (13, 5);
let output = affine_cipher::decode(phrase, a, b);
let output = decode(phrase, a, b);
let expected = Err(NotCoprime(13));
assert_eq!(output, expected);
}
38 changes: 20 additions & 18 deletions exercises/practice/book-store/tests/book-store.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use book_store::*;

#[test]
fn only_a_single_book() {
let input = &[1];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 800;
assert_eq!(output, expected);
}
Expand All @@ -10,7 +12,7 @@ fn only_a_single_book() {
#[ignore]
fn two_of_the_same_book() {
let input = &[2, 2];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 1600;
assert_eq!(output, expected);
}
Expand All @@ -19,7 +21,7 @@ fn two_of_the_same_book() {
#[ignore]
fn empty_basket() {
let input = &[];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 0;
assert_eq!(output, expected);
}
Expand All @@ -28,7 +30,7 @@ fn empty_basket() {
#[ignore]
fn two_different_books() {
let input = &[1, 2];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 1520;
assert_eq!(output, expected);
}
Expand All @@ -37,7 +39,7 @@ fn two_different_books() {
#[ignore]
fn three_different_books() {
let input = &[1, 2, 3];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 2160;
assert_eq!(output, expected);
}
Expand All @@ -46,7 +48,7 @@ fn three_different_books() {
#[ignore]
fn four_different_books() {
let input = &[1, 2, 3, 4];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 2560;
assert_eq!(output, expected);
}
Expand All @@ -55,7 +57,7 @@ fn four_different_books() {
#[ignore]
fn five_different_books() {
let input = &[1, 2, 3, 4, 5];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 3000;
assert_eq!(output, expected);
}
Expand All @@ -64,7 +66,7 @@ fn five_different_books() {
#[ignore]
fn two_groups_of_four_is_cheaper_than_group_of_five_plus_group_of_three() {
let input = &[1, 1, 2, 2, 3, 3, 4, 5];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 5120;
assert_eq!(output, expected);
}
Expand All @@ -73,7 +75,7 @@ fn two_groups_of_four_is_cheaper_than_group_of_five_plus_group_of_three() {
#[ignore]
fn two_groups_of_four_is_cheaper_than_groups_of_five_and_three() {
let input = &[1, 1, 2, 3, 4, 4, 5, 5];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 5120;
assert_eq!(output, expected);
}
Expand All @@ -82,7 +84,7 @@ fn two_groups_of_four_is_cheaper_than_groups_of_five_and_three() {
#[ignore]
fn group_of_four_plus_group_of_two_is_cheaper_than_two_groups_of_three() {
let input = &[1, 1, 2, 2, 3, 4];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 4080;
assert_eq!(output, expected);
}
Expand All @@ -91,7 +93,7 @@ fn group_of_four_plus_group_of_two_is_cheaper_than_two_groups_of_three() {
#[ignore]
fn two_each_of_first_four_books_and_one_copy_each_of_rest() {
let input = &[1, 1, 2, 2, 3, 3, 4, 4, 5];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 5560;
assert_eq!(output, expected);
}
Expand All @@ -100,7 +102,7 @@ fn two_each_of_first_four_books_and_one_copy_each_of_rest() {
#[ignore]
fn two_copies_of_each_book() {
let input = &[1, 1, 2, 2, 3, 3, 4, 4, 5, 5];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 6000;
assert_eq!(output, expected);
}
Expand All @@ -109,7 +111,7 @@ fn two_copies_of_each_book() {
#[ignore]
fn three_copies_of_first_book_and_two_each_of_remaining() {
let input = &[1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 6800;
assert_eq!(output, expected);
}
Expand All @@ -118,7 +120,7 @@ fn three_copies_of_first_book_and_two_each_of_remaining() {
#[ignore]
fn three_each_of_first_two_books_and_two_each_of_remaining_books() {
let input = &[1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 1, 2];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 7520;
assert_eq!(output, expected);
}
Expand All @@ -127,7 +129,7 @@ fn three_each_of_first_two_books_and_two_each_of_remaining_books() {
#[ignore]
fn four_groups_of_four_are_cheaper_than_two_groups_each_of_five_and_three() {
let input = &[1, 1, 2, 2, 3, 3, 4, 5, 1, 1, 2, 2, 3, 3, 4, 5];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 10240;
assert_eq!(output, expected);
}
Expand All @@ -139,7 +141,7 @@ fn check_that_groups_of_four_are_created_properly_even_when_there_are_more_group
let input = &[
1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 5, 5,
];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 14560;
assert_eq!(output, expected);
}
Expand All @@ -148,7 +150,7 @@ fn check_that_groups_of_four_are_created_properly_even_when_there_are_more_group
#[ignore]
fn one_group_of_one_and_four_is_cheaper_than_one_group_of_two_and_three() {
let input = &[1, 1, 2, 3, 4];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 3360;
assert_eq!(output, expected);
}
Expand All @@ -157,7 +159,7 @@ fn one_group_of_one_and_four_is_cheaper_than_one_group_of_two_and_three() {
#[ignore]
fn one_group_of_one_and_two_plus_three_groups_of_four_is_cheaper_than_one_group_of_each_size() {
let input = &[1, 2, 2, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 5];
let output = book_store::lowest_price(input);
let output = lowest_price(input);
let expected = 10000;
assert_eq!(output, expected);
}
14 changes: 8 additions & 6 deletions exercises/practice/proverb/tests/proverb.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use proverb::*;

#[test]
fn zero_pieces() {
let input = &[];
let output = proverb::build_proverb(input);
let output = build_proverb(input);
let expected = String::new();
assert_eq!(output, expected);
}
Expand All @@ -10,7 +12,7 @@ fn zero_pieces() {
#[ignore]
fn one_piece() {
let input = &["nail"];
let output = proverb::build_proverb(input);
let output = build_proverb(input);
let expected: String = ["And all for the want of a nail."].join("\n");
assert_eq!(output, expected);
}
Expand All @@ -19,7 +21,7 @@ fn one_piece() {
#[ignore]
fn two_pieces() {
let input = &["nail", "shoe"];
let output = proverb::build_proverb(input);
let output = build_proverb(input);
let expected: String = [
"For want of a nail the shoe was lost.",
"And all for the want of a nail.",
Expand All @@ -32,7 +34,7 @@ fn two_pieces() {
#[ignore]
fn three_pieces() {
let input = &["nail", "shoe", "horse"];
let output = proverb::build_proverb(input);
let output = build_proverb(input);
let expected: String = [
"For want of a nail the shoe was lost.",
"For want of a shoe the horse was lost.",
Expand All @@ -48,7 +50,7 @@ fn full_proverb() {
let input = &[
"nail", "shoe", "horse", "rider", "message", "battle", "kingdom",
];
let output = proverb::build_proverb(input);
let output = build_proverb(input);
let expected: String = [
"For want of a nail the shoe was lost.",
"For want of a shoe the horse was lost.",
Expand All @@ -66,7 +68,7 @@ fn full_proverb() {
#[ignore]
fn four_pieces_modernized() {
let input = &["pin", "gun", "soldier", "battle"];
let output = proverb::build_proverb(input);
let output = build_proverb(input);
let expected: String = [
"For want of a pin the gun was lost.",
"For want of a gun the soldier was lost.",
Expand Down
Loading

0 comments on commit c8d6bb1

Please sign in to comment.