diff --git a/exercises/concept/annalyns-infiltration/test_annalyns-infiltration.R b/exercises/concept/annalyns-infiltration/test_annalyns-infiltration.R index 68aaa99b..d5976c5d 100644 --- a/exercises/concept/annalyns-infiltration/test_annalyns-infiltration.R +++ b/exercises/concept/annalyns-infiltration/test_annalyns-infiltration.R @@ -5,12 +5,12 @@ library(testthat) test_that("Cannot execute fast attack if knight is awake", { knight_is_awake <- TRUE - expect_equal(can_fast_attack(knight_is_awake), FALSE) + expect_false(can_fast_attack(knight_is_awake)) }) test_that("Can execute fast attack if knight is sleeping", { knight_is_awake <- FALSE - expect_equal(can_fast_attack(knight_is_awake), TRUE) + expect_true(can_fast_attack(knight_is_awake)) }) # 2) can_spy diff --git a/exercises/concept/elyses-enchantments/test_elyses-enchantments.R b/exercises/concept/elyses-enchantments/test_elyses-enchantments.R index f548df5e..412c06b4 100644 --- a/exercises/concept/elyses-enchantments/test_elyses-enchantments.R +++ b/exercises/concept/elyses-enchantments/test_elyses-enchantments.R @@ -145,65 +145,65 @@ test_that("remove the card from the bottom", { test_that("an empty stack of cards", { stack <- c() stack_size <- 0 - expect_equal(check_size_of_stack(stack, stack_size), TRUE) + expect_true(check_size_of_stack(stack, stack_size)) }) test_that("an empty stack of cards", { stack <- c() stack_size <- 1 - expect_equal(check_size_of_stack(stack, stack_size), FALSE) + expect_false(check_size_of_stack(stack, stack_size)) }) test_that("has exactly 1 card", { stack <- c(7) stack_size <- 0 - expect_equal(check_size_of_stack(stack, stack_size), FALSE) + expect_false(check_size_of_stack(stack, stack_size)) }) test_that("has exactly 1 card", { stack <- c(7) stack_size <- 1 - expect_equal(check_size_of_stack(stack, stack_size), TRUE) + expect_true(check_size_of_stack(stack, stack_size)) }) test_that("has exactly 1 card", { stack <- c(7) stack_size <- 2 - expect_equal(check_size_of_stack(stack, stack_size), FALSE) + expect_false(check_size_of_stack(stack, stack_size)) }) test_that("has exactly 4 cards", { stack <- c(2, 4, 6, 8) stack_size <- 3 - expect_equal(check_size_of_stack(stack, stack_size), FALSE) + expect_false(check_size_of_stack(stack, stack_size)) }) test_that("has exactly 4 cards", { stack <- c(2, 4, 6, 8) stack_size <- 4 - expect_equal(check_size_of_stack(stack, stack_size), TRUE) + expect_true(check_size_of_stack(stack, stack_size)) }) test_that("has exactly 4 cards", { stack <- c(2, 4, 6, 8) stack_size <- 15 - expect_equal(check_size_of_stack(stack, stack_size), FALSE) + expect_false(check_size_of_stack(stack, stack_size)) }) test_that("has exactly 5 cards", { stack <- c(1, 3, 5, 7, 9) stack_size <- 3 - expect_equal(check_size_of_stack(stack, stack_size), FALSE) + expect_false(check_size_of_stack(stack, stack_size)) }) test_that("has exactly 5 cards", { stack <- c(1, 3, 5, 7, 9) stack_size <- 4 - expect_equal(check_size_of_stack(stack, stack_size), FALSE) + expect_false(check_size_of_stack(stack, stack_size)) }) test_that("has exactly 5 cards", { stack <- c(1, 3, 5, 7, 9) stack_size <- 5 - expect_equal(check_size_of_stack(stack, stack_size), TRUE) + expect_true(check_size_of_stack(stack, stack_size)) }) diff --git a/exercises/practice/armstrong-numbers/test_armstrong-numbers.R b/exercises/practice/armstrong-numbers/test_armstrong-numbers.R index b6934c0e..9558cdab 100644 --- a/exercises/practice/armstrong-numbers/test_armstrong-numbers.R +++ b/exercises/practice/armstrong-numbers/test_armstrong-numbers.R @@ -2,37 +2,37 @@ source("./armstrong-numbers.R") library(testthat) test_that("Zero is an Armstrong number", { - expect_equal(is_armstrong_number(0), TRUE) + expect_true(is_armstrong_number(0)) }) test_that("Single-digit numbers are Armstrong numbers", { - expect_equal(is_armstrong_number(5), TRUE) + expect_true(is_armstrong_number(5)) }) test_that("There are no two-digit Armstrong numbers", { - expect_equal(is_armstrong_number(10), FALSE) + expect_false(is_armstrong_number(10)) }) test_that("Three-digit number that is an Armstrong number", { - expect_equal(is_armstrong_number(153), TRUE) + expect_true(is_armstrong_number(153)) }) test_that("Three-digit number that is not an Armstrong number", { - expect_equal(is_armstrong_number(100), FALSE) + expect_false(is_armstrong_number(100)) }) test_that("Four-digit number that is an Armstrong number", { - expect_equal(is_armstrong_number(9474), TRUE) + expect_true(is_armstrong_number(9474)) }) test_that("Four-digit number that is not an Armstrong number", { - expect_equal(is_armstrong_number(9475), FALSE) + expect_false(is_armstrong_number(9475)) }) test_that("Seven-digit number that is an Armstrong number", { - expect_equal(is_armstrong_number(9926315), TRUE) + expect_true(is_armstrong_number(9926315)) }) test_that("Seven-digit number that is not an Armstrong number", { - expect_equal(is_armstrong_number(9926314), FALSE) + expect_false(is_armstrong_number(9926314)) }) diff --git a/exercises/practice/isbn-verifier/test_isbn-verifier.R b/exercises/practice/isbn-verifier/test_isbn-verifier.R index 5481a6fc..e8b3bd06 100644 --- a/exercises/practice/isbn-verifier/test_isbn-verifier.R +++ b/exercises/practice/isbn-verifier/test_isbn-verifier.R @@ -2,78 +2,77 @@ source("./isbn-verifier.R") library(testthat) test_that("Valid isbn", { - expect_equal(is_valid("3-598-21508-8"), TRUE) + expect_true(is_valid("3-598-21508-8")) }) test_that("Invalid isbn check digit", { - expect_equal(is_valid("3-598-21508-9"), FALSE) + expect_false(is_valid("3-598-21508-9")) }) test_that("Valid isbn with a check digit of 10", { - expect_equal(is_valid("3-598-21507-X"), TRUE) + expect_true(is_valid("3-598-21507-X")) }) test_that("Check digit is a character other than X", { - expect_equal(is_valid("3-598-21507-A"), FALSE) + expect_false(is_valid("3-598-21507-A")) }) test_that("Invalid check digit in isbn is not treated as zero", { - expect_equal(is_valid("4-598-21507-B"), FALSE) + expect_false(is_valid("4-598-21507-B")) }) test_that("Invalid character in isbn is not treated as zero", { - expect_equal(is_valid("3-598-P1581-X"), FALSE) + expect_false(is_valid("3-598-P1581-X")) }) test_that("X is only valid as a check digit", { - expect_equal(is_valid("3-598-2X507-9"), FALSE) + expect_false(is_valid("3-598-2X507-9")) }) test_that("Valid isbn without separating dashes", { - expect_equal(is_valid("3598215088"), TRUE) + expect_true(is_valid("3598215088")) }) test_that("Isbn without separating dashes and X as check digit", { - expect_equal(is_valid("359821507X"), TRUE) + expect_true(is_valid("359821507X")) }) test_that("Isbn without check digit and dashes", { - expect_equal(is_valid("359821507"), FALSE) + expect_false(is_valid("359821507")) }) test_that("Too long isbn and no dashes", { - expect_equal(is_valid("3598215078X"), FALSE) + expect_false(is_valid("3598215078X")) }) test_that("Too short isbn", { - expect_equal(is_valid("00"), FALSE) + expect_false(is_valid("00")) }) test_that("Isbn without check digit", { - expect_equal(is_valid("3-598-21507"), FALSE) + expect_false(is_valid("3-598-21507")) }) test_that("Check digit of X should not be used for 0", { - expect_equal(is_valid("3-598-21515-X"), FALSE) + expect_false(is_valid("3-598-21515-X")) }) test_that("Empty isbn", { - expect_equal(is_valid(""), FALSE) + expect_false(is_valid("")) }) test_that("Input is 9 characters", { - expect_equal(is_valid("134456729"), FALSE) + expect_false(is_valid("134456729")) }) test_that("Invalid characters are not ignored after checking length", { - expect_equal(is_valid("3132P34035"), FALSE) + expect_false(is_valid("3132P34035")) }) test_that("Invalid characters are not ignored before checking length", { - expect_equal(is_valid("3598P215088"), FALSE) + expect_false(is_valid("3598P215088")) }) test_that("Input is too long but contains a valid isbn", { - expect_equal(is_valid("98245726788"), FALSE) + expect_false(is_valid("98245726788")) }) - diff --git a/exercises/practice/isogram/test_isogram.R b/exercises/practice/isogram/test_isogram.R index acc63972..c68501c7 100644 --- a/exercises/practice/isogram/test_isogram.R +++ b/exercises/practice/isogram/test_isogram.R @@ -3,40 +3,40 @@ library(testthat) test_that("empty string", { word <- "" - expect_equal(is_isogram(word), TRUE) + expect_true(is_isogram(word)) }) test_that("isogram with only lower case characters", { word <- "isogram" - expect_equal(is_isogram(word), TRUE) + expect_true(is_isogram(word)) }) test_that("word with one duplicated character", { word <- "eleven" - expect_equal(is_isogram(word), FALSE) + expect_false(is_isogram(word)) }) test_that("longest reported english isogram", { word <- "subdermatoglyphic" - expect_equal(is_isogram(word), TRUE) + expect_true(is_isogram(word)) }) test_that("word with duplicated character in mixed case", { word <- "Alphabet" - expect_equal(is_isogram(word), FALSE) + expect_false(is_isogram(word)) }) test_that("hypothetical isogrammic word with hyphen", { word <- "thumbscrew-japingly" - expect_equal(is_isogram(word), TRUE) + expect_true(is_isogram(word)) }) test_that("isogram with duplicated non letter character", { word <- "Hjelmqvist-Gryb-Zock-Pfund-Wax" - expect_equal(is_isogram(word), TRUE) + expect_true(is_isogram(word)) }) test_that("made-up name that is an isogram", { word <- "Emily Jung Schwartzkopf" - expect_equal(is_isogram(word), TRUE) + expect_true(is_isogram(word)) }) diff --git a/exercises/practice/leap/test_leap.R b/exercises/practice/leap/test_leap.R index 1fb20a43..c9a06350 100644 --- a/exercises/practice/leap/test_leap.R +++ b/exercises/practice/leap/test_leap.R @@ -3,20 +3,20 @@ library(testthat) test_that("year not divisible by 4: common year", { year <- 2015 - expect_equal(leap(year), FALSE) + expect_false(leap(year)) }) test_that("year divisible by 4, not divisible by 100: leap year", { year <- 2016 - expect_equal(leap(year), TRUE) + expect_true(leap(year)) }) test_that("year divisible by 100, not divisible by 400: common year", { year <- 2100 - expect_equal(leap(year), FALSE) + expect_false(leap(year)) }) test_that("year divisible by 400: leap year", { year <- 2000 - expect_equal(leap(year), TRUE) + expect_true(leap(year)) }) diff --git a/exercises/practice/luhn/test_luhn.R b/exercises/practice/luhn/test_luhn.R index 3f639b39..64c4bcd7 100644 --- a/exercises/practice/luhn/test_luhn.R +++ b/exercises/practice/luhn/test_luhn.R @@ -3,70 +3,70 @@ library(testthat) test_that("single digit strings can not be valid", { input <- "1" - expect_equal(is_valid(input), FALSE) + expect_false(is_valid(input)) }) test_that("A single zero is invalid", { input <- "0" - expect_equal(is_valid(input), FALSE) + expect_false(is_valid(input)) }) test_that("a simple valid SIN that remains valid if reversed", { input <- "059" - expect_equal(is_valid(input), TRUE) + expect_true(is_valid(input)) }) test_that("a simple valid SIN that becomes invalid if reversed", { input <- "59" - expect_equal(is_valid(input), TRUE) + expect_true(is_valid(input)) }) test_that("valid Canadian SIN", { input <- "046 454 286" - expect_equal(is_valid(input), TRUE) + expect_true(is_valid(input)) }) test_that("invalid Canadian SIN", { input <- "046 454 287" - expect_equal(is_valid(input), FALSE) + expect_false(is_valid(input)) }) test_that("invalid credit card", { input <- "8273 1232 7352 0569" - expect_equal(is_valid(input), FALSE) + expect_false(is_valid(input)) }) test_that("valid strings with a non-digit added become invalid", { input <- "055a 444 285" - expect_equal(is_valid(input), FALSE) + expect_false(is_valid(input)) }) test_that("punctuation is not allowed", { input <- "055-444-285" - expect_equal(is_valid(input), FALSE) + expect_false(is_valid(input)) }) test_that("symbols are not allowed", { input <- "055£ 444$ 285" - expect_equal(is_valid(input), FALSE) + expect_false(is_valid(input)) }) test_that("single zero with space is invalid", { input <- " 0" - expect_equal(is_valid(input), FALSE) + expect_false(is_valid(input)) }) test_that("more than a single zero is valid", { input <- "0000 0" - expect_equal(is_valid(input), TRUE) + expect_true(is_valid(input)) }) test_that("another valid sin", { input <- "055 444 285" - expect_equal(is_valid(input), TRUE) + expect_true(is_valid(input)) }) test_that("nine doubled is nine", { input <- "091" - expect_equal(is_valid(input), TRUE) + expect_true(is_valid(input)) }) diff --git a/exercises/practice/matching-brackets/test_matching-brackets.R b/exercises/practice/matching-brackets/test_matching-brackets.R index 1d2fdd5a..92de039c 100644 --- a/exercises/practice/matching-brackets/test_matching-brackets.R +++ b/exercises/practice/matching-brackets/test_matching-brackets.R @@ -2,83 +2,83 @@ source("./matching-brackets.R") library(testthat) test_that("Paired square brackets", { - expect_equal(is_paired("[]"), TRUE) + expect_true(is_paired("[]")) }) test_that("Empty string", { - expect_equal(is_paired(""), TRUE) + expect_true(is_paired("")) }) test_that("Unpaired brackets", { - expect_equal(is_paired("[["), FALSE) + expect_false(is_paired("[[")) }) test_that("Wrong ordered brackets", { - expect_equal(is_paired("}{"), FALSE) + expect_false(is_paired("}{")) }) test_that("Wrong closing bracket", { - expect_equal(is_paired("{]"), FALSE) + expect_false(is_paired("{]")) }) test_that("Paired with whitespace", { - expect_equal(is_paired("{ }"), TRUE) + expect_true(is_paired("{ }")) }) test_that("Partially paired brackets", { - expect_equal(is_paired("{[])"), FALSE) + expect_false(is_paired("{[])")) }) test_that("Simple nested brackets", { - expect_equal(is_paired("{[]}"), TRUE) + expect_true(is_paired("{[]}")) }) test_that("Several paired brackets", { - expect_equal(is_paired("{}[]"), TRUE) + expect_true(is_paired("{}[]")) }) test_that("Paired and nested brackets", { - expect_equal(is_paired("([{}({}[])])"), TRUE) + expect_true(is_paired("([{}({}[])])")) }) test_that("Unopened closing brackets", { - expect_equal(is_paired("{[)][]}"), FALSE) + expect_false(is_paired("{[)][]}")) }) test_that("Unpaired and nested brackets", { - expect_equal(is_paired("([{])"), FALSE) + expect_false(is_paired("([{])")) }) test_that("Paired and wrong nested brackets", { - expect_equal(is_paired("[({]})"), FALSE) + expect_false(is_paired("[({]})")) }) test_that("Paired and wrong nested brackets but innermost are correct", { - expect_equal(is_paired("[({}])"), FALSE) + expect_false(is_paired("[({}])")) }) test_that("Paired and incomplete brackets", { - expect_equal(is_paired("{}["), FALSE) + expect_false(is_paired("{}[")) }) test_that("Too many closing brackets", { - expect_equal(is_paired("[]]"), FALSE) + expect_false(is_paired("[]]")) }) test_that("Early unexpected brackets", { - expect_equal(is_paired(")()"), FALSE) + expect_false(is_paired(")()")) }) test_that("Early mismatched brackets", { - expect_equal(is_paired("{)()"), FALSE) + expect_false(is_paired("{)()")) }) test_that("Math expression", { input <- "(((185 + 223.85) * 15) - 543)/2" - expect_equal(is_paired(input), TRUE) + expect_true(is_paired(input)) }) test_that("Complex latex expression", { input <- "\\left(\\begin{array}{cc} \\frac{1}{3} & x\\ \\mathrm{e}^{x} &... x^2 \\end{array}\\right)" # nolint - expect_equal(is_paired(input), TRUE) + expect_true(is_paired(input)) }) diff --git a/exercises/practice/phone-number/test_phone-number.R b/exercises/practice/phone-number/test_phone-number.R index c32440d2..78c5102e 100644 --- a/exercises/practice/phone-number/test_phone-number.R +++ b/exercises/practice/phone-number/test_phone-number.R @@ -14,11 +14,11 @@ test_that("cleans numbers with multiple spaces", { }) test_that("invalid when 9 digits", { - expect_equal(parse_phone_number("123456789"), NULL) + expect_null(parse_phone_number("123456789")) }) test_that("invalid when 11 digits and not starting with a 1", { - expect_equal(parse_phone_number("22234567890"), NULL) + expect_null(parse_phone_number("22234567890")) }) test_that("valid when 11 digits and starting with 1", { @@ -30,46 +30,45 @@ test_that("valid when 11 digits and starting with 1 even with punctuation", { }) test_that("invalid when more than 11 digits", { - expect_equal(parse_phone_number("321234567890"), NULL) + expect_null(parse_phone_number("321234567890")) }) test_that("invalid with letters", { - expect_equal(parse_phone_number("523-abc-7890"), NULL) + expect_null(parse_phone_number("523-abc-7890")) }) test_that("invalid with punctuations", { - expect_equal(parse_phone_number("523-@:!-7890"), NULL) + expect_null(parse_phone_number("523-@:!-7890")) }) test_that("invalid if area code starts with 0", { - expect_equal(parse_phone_number("(023) 456-7890"), NULL) + expect_null(parse_phone_number("(023) 456-7890")) }) test_that("invalid if area code starts with 1", { - expect_equal(parse_phone_number("(123) 456-7890"), NULL) + expect_null(parse_phone_number("(123) 456-7890")) }) test_that("invalid if exchange code starts with 0", { - expect_equal(parse_phone_number("(223) 056-7890"), NULL) + expect_null(parse_phone_number("(223) 056-7890")) }) test_that("invalid if exchange code starts with 1", { - expect_equal(parse_phone_number("(223) 156-7890"), NULL) + expect_null(parse_phone_number("(223) 156-7890")) }) test_that("invalid if area code starts with 0 on valid 11-digit number", { - expect_equal(parse_phone_number("1 (023) 456-7890"), NULL) + expect_null(parse_phone_number("1 (023) 456-7890")) }) test_that("invalid if area code starts with 1 on valid 11-digit number", { - expect_equal(parse_phone_number("1 (123) 456-7890"), NULL) + expect_null(parse_phone_number("1 (123) 456-7890")) }) test_that("invalid if exchange code starts with 0 on valid 11-digit number", { - expect_equal(parse_phone_number("1 (223) 056-7890"), NULL) + expect_null(parse_phone_number("1 (223) 056-7890")) }) test_that("invalid if exchange code starts with 1 on valid 11-digit number", { - expect_equal(parse_phone_number("1 (223) 156-7890"), NULL) + expect_null(parse_phone_number("1 (223) 156-7890")) }) - diff --git a/exercises/practice/protein-translation/test_protein-translation.R b/exercises/practice/protein-translation/test_protein-translation.R index 04ce15fd..cd2a0e4c 100644 --- a/exercises/practice/protein-translation/test_protein-translation.R +++ b/exercises/practice/protein-translation/test_protein-translation.R @@ -1,64 +1,64 @@ -source('./protein-translation.R') +source("./protein-translation.R") library(testthat) test_that("Empty RNA sequence results in no proteins", { - expect_equal(translate(""), NULL) + expect_null(translate("")) }) test_that("Methionine RNA sequence", { - expect_equal(translate("AUG"), 'Methionine') + expect_equal(translate("AUG"), "Methionine") }) test_that("Phenylalanine RNA sequence 1", { - expect_equal(translate("UUU"), 'Phenylalanine') + expect_equal(translate("UUU"), "Phenylalanine") }) test_that("Phenylalanine RNA sequence 2", { - expect_equal(translate("UUC"), 'Phenylalanine') + expect_equal(translate("UUC"), "Phenylalanine") }) test_that("Leucine RNA sequence 1", { - expect_equal(translate("UUA"), 'Leucine') + expect_equal(translate("UUA"), "Leucine") }) test_that("Leucine RNA sequence 2", { - expect_equal(translate("UUG"), 'Leucine') + expect_equal(translate("UUG"), "Leucine") }) test_that("Serine RNA sequence 1", { - expect_equal(translate("UCU"), 'Serine') + expect_equal(translate("UCU"), "Serine") }) test_that("Serine RNA sequence 2", { - expect_equal(translate("UCC"), 'Serine') + expect_equal(translate("UCC"), "Serine") }) test_that("Serine RNA sequence 3", { - expect_equal(translate("UCA"), 'Serine') + expect_equal(translate("UCA"), "Serine") }) test_that("Serine RNA sequence 4", { - expect_equal(translate("UCG"), 'Serine') + expect_equal(translate("UCG"), "Serine") }) test_that("Tyrosine RNA sequence 1", { - expect_equal(translate("UAU"), 'Tyrosine') + expect_equal(translate("UAU"), "Tyrosine") }) test_that("Tyrosine RNA sequence 2", { - expect_equal(translate("UAC"), 'Tyrosine') + expect_equal(translate("UAC"), "Tyrosine") }) test_that("Cysteine RNA sequence 1", { - expect_equal(translate("UGU"), 'Cysteine') + expect_equal(translate("UGU"), "Cysteine") }) test_that("Cysteine RNA sequence 2", { - expect_equal(translate("UGC"), 'Cysteine') + expect_equal(translate("UGC"), "Cysteine") }) test_that("Tryptophan RNA sequence", { - expect_equal(translate("UGG"), 'Tryptophan') + expect_equal(translate("UGG"), "Tryptophan") }) test_that("STOP codon RNA sequence 1", { @@ -74,16 +74,18 @@ test_that("STOP codon RNA sequence 3", { }) test_that("Sequence of two protein codons translates into proteins", { - expect_equal(translate("UUUUUU"), c('Phenylalanine', 'Phenylalanine')) + expect_equal(translate("UUUUUU"), c("Phenylalanine", "Phenylalanine")) }) test_that("Sequence of two different protein codons translates into proteins", { - expect_equal(translate("UUAUUG"), c('Leucine', 'Leucine')) + expect_equal(translate("UUAUUG"), c("Leucine", "Leucine")) }) test_that("Translate RNA strand into correct protein list", { - expect_equal(translate("AUGUUUUGG"), - c('Methionine', 'Phenylalanine', 'Tryptophan')) + expect_equal( + translate("AUGUUUUGG"), + c("Methionine", "Phenylalanine", "Tryptophan") + ) }) test_that("Translation stops if STOP codon at beginning of sequence", { @@ -91,20 +93,22 @@ test_that("Translation stops if STOP codon at beginning of sequence", { }) test_that("Translation stops if STOP codon at end of two-codon sequence", { - expect_equal(translate("UGGUAG"), c('Tryptophan')) + expect_equal(translate("UGGUAG"), c("Tryptophan")) }) test_that("Translation stops if STOP codon at end of three-codon sequence", { - expect_equal(translate("AUGUUUUAA"), c('Methionine', 'Phenylalanine')) + expect_equal(translate("AUGUUUUAA"), c("Methionine", "Phenylalanine")) }) test_that("Translation stops if STOP codon in middle of three-codon sequence", { - expect_equal(translate("UGGUAGUGG"), c('Tryptophan')) + expect_equal(translate("UGGUAGUGG"), c("Tryptophan")) }) test_that("Translation stops if STOP codon in middle of six-codon sequence", { - expect_equal(translate("UGGUGUUAUUAAUGGUUU"), - c('Tryptophan', 'Cysteine', 'Tyrosine')) + expect_equal( + translate("UGGUGUUAUUAAUGGUUU"), + c("Tryptophan", "Cysteine", "Tyrosine") + ) }) test_that("Non-existing codon can't translate", { @@ -120,6 +124,5 @@ test_that("Incomplete RNA sequence can't translate", { }) test_that("Incomplete RNA sequence can translate if valid until a STOP codon", { - expect_equal(translate("UUCUUCUAAUGGU"), c('Phenylalanine', 'Phenylalanine')) + expect_equal(translate("UUCUUCUAAUGGU"), c("Phenylalanine", "Phenylalanine")) }) - diff --git a/exercises/practice/queen-attack/test_queen-attack.R b/exercises/practice/queen-attack/test_queen-attack.R index f1e87585..a178500a 100644 --- a/exercises/practice/queen-attack/test_queen-attack.R +++ b/exercises/practice/queen-attack/test_queen-attack.R @@ -38,43 +38,43 @@ test_that("queen must have column on board", { test_that("cannot attack", { queen1 <- create(2, 4) queen2 <- create(6, 6) - expect_equal(can_attack(queen1, queen2), FALSE) + expect_false(can_attack(queen1, queen2)) }) test_that("can attack on same row", { queen1 <- create(2, 4) queen2 <- create(2, 6) - expect_equal(can_attack(queen1, queen2), TRUE) + expect_true(can_attack(queen1, queen2)) }) test_that("can attack on same column", { queen1 <- create(4, 5) queen2 <- create(2, 5) - expect_equal(can_attack(queen1, queen2), TRUE) + expect_true(can_attack(queen1, queen2)) }) test_that("can attack on first diagonal", { queen1 <- create(2, 2) queen2 <- create(0, 4) - expect_equal(can_attack(queen1, queen2), TRUE) + expect_true(can_attack(queen1, queen2)) }) test_that("can attack on second diagonal", { queen1 <- create(2, 2) queen2 <- create(3, 1) - expect_equal(can_attack(queen1, queen2), TRUE) + expect_true(can_attack(queen1, queen2)) }) test_that("can attack on third diagonal", { queen1 <- create(2, 2) queen2 <- create(1, 1) - expect_equal(can_attack(queen1, queen2), TRUE) + expect_true(can_attack(queen1, queen2)) }) test_that("can attack on fourth diagonal", { queen1 <- create(1, 7) queen2 <- create(0, 6) - expect_equal(can_attack(queen1, queen2), TRUE) + expect_true(can_attack(queen1, queen2)) }) # cannot attack if falling diagonals are only the same when reflected @@ -82,5 +82,5 @@ test_that("can attack on fourth diagonal", { test_that("cannot attack", { queen1 <- create(4, 1) queen2 <- create(2, 5) - expect_equal(can_attack(queen1, queen2), FALSE) + expect_false(can_attack(queen1, queen2)) }) diff --git a/exercises/practice/simple-cipher/test_simple-cipher.R b/exercises/practice/simple-cipher/test_simple-cipher.R index cebc88bf..ce6fa443 100644 --- a/exercises/practice/simple-cipher/test_simple-cipher.R +++ b/exercises/practice/simple-cipher/test_simple-cipher.R @@ -3,7 +3,7 @@ library(testthat) test_that("Random key cipher - Key is made only of lowercase letters", { key <- generate_key() - expect_equal(all(grepl("^[a-z]+$", key)), TRUE) + expect_match(key, "^[a-z]+$") }) test_that("Random key cipher - Can encode", { diff --git a/exercises/practice/vehicle-purchase/test_vehicle-purchase.R b/exercises/practice/vehicle-purchase/test_vehicle-purchase.R index 3c37f5f4..a14eda06 100644 --- a/exercises/practice/vehicle-purchase/test_vehicle-purchase.R +++ b/exercises/practice/vehicle-purchase/test_vehicle-purchase.R @@ -4,23 +4,23 @@ library(testthat) # needs_license test_that("requires a license for a car", { - expect_equal(needs_license("car"), TRUE) + expect_true(needs_license("car")) }) test_that("requires a license for a truck", { - expect_equal(needs_license("truck"), TRUE) + expect_true(needs_license("truck")) }) test_that("requires a license for a bike", { - expect_equal(needs_license("bike"), FALSE) + expect_false(needs_license("bike")) }) test_that("requires a license for a stroller", { - expect_equal(needs_license("stroller"), FALSE) + expect_false(needs_license("stroller")) }) test_that("requires a license for an e-scooter", { - expect_equal(needs_license("e-scooter"), FALSE) + expect_false(needs_license("e-scooter")) }) # choose_vehicle