Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hikjik committed Oct 18, 2023
1 parent 17e9598 commit 5ad5e2c
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 9 deletions.
18 changes: 15 additions & 3 deletions solutions/circular-sentence/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,26 @@

TEST_CASE("Simple") {
struct TestCase {
std::string sentence;bool expected;
std::string sentence;
bool expected;
};

std::vector<TestCase> test_cases{
{.sentence="leetcode exercises sound delightful",.expected=true,},{.sentence="eetcode",.expected=true,},{.sentence="Leetcode is cool",.expected=false,},
{
.sentence = "leetcode exercises sound delightful",
.expected = true,
},
{
.sentence = "eetcode",
.expected = true,
},
{
.sentence = "Leetcode is cool",
.expected = false,
},
};

for (const auto &[sentence,expected] : test_cases) {
for (const auto &[sentence, expected] : test_cases) {
const auto actual = Solution::isCircularSentence(sentence);
REQUIRE(expected == actual);
}
Expand Down
22 changes: 19 additions & 3 deletions solutions/find-the-maximum-divisibility-score/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,30 @@

TEST_CASE("Simple") {
struct TestCase {
std::vector<int> nums;std::vector<int> divisors;int expected;
std::vector<int> nums;
std::vector<int> divisors;
int expected;
};

std::vector<TestCase> test_cases{
{.nums{4,7,9,3,9},.divisors{5,2,3},.expected=3,},{.nums{20,14,21,10},.divisors{5,7,5},.expected=5,},{.nums{12},.divisors{10,16},.expected=10,},
{
.nums{4, 7, 9, 3, 9},
.divisors{5, 2, 3},
.expected = 3,
},
{
.nums{20, 14, 21, 10},
.divisors{5, 7, 5},
.expected = 5,
},
{
.nums{12},
.divisors{10, 16},
.expected = 10,
},
};

for (const auto &[nums,divisors,expected] : test_cases) {
for (const auto &[nums, divisors, expected] : test_cases) {
const auto actual = Solution::maxDivScore(nums, divisors);
REQUIRE(expected == actual);
}
Expand Down
14 changes: 11 additions & 3 deletions solutions/prime-in-diagonal/test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,22 @@

TEST_CASE("Simple") {
struct TestCase {
std::vector<std::vector<int>> nums;int expected;
std::vector<std::vector<int>> nums;
int expected;
};

std::vector<TestCase> test_cases{
{.nums{{1,2,3},{5,6,7},{9,10,11}},.expected=11,},{.nums{{1,2,3},{5,17,7},{9,11,10}},.expected=17,},
{
.nums{{1, 2, 3}, {5, 6, 7}, {9, 10, 11}},
.expected = 11,
},
{
.nums{{1, 2, 3}, {5, 17, 7}, {9, 11, 10}},
.expected = 17,
},
};

for (const auto &[nums,expected] : test_cases) {
for (const auto &[nums, expected] : test_cases) {
const auto actual = Solution::diagonalPrime(nums);
REQUIRE(expected == actual);
}
Expand Down

0 comments on commit 5ad5e2c

Please sign in to comment.