Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define DOCTEST_CONFIG_IMPLEMENT
- #include "doctest.h"
- #include <iostream>
- int countReads(char grid[30][30][101], int gridRows, int gridColumns, char sentence[90001]);
- TEST_CASE("works for a single word") {
- char grid[30][30][101] = {
- {"cat"}
- };
- char sentence[101] = "cat";
- CHECK(countReads(grid, 1, 1, sentence) == 1);
- }
- TEST_CASE("starts from any point of the grid") {
- char grid[30][30][101] = {
- {"cat", "dog"},
- {"tiger", "cat"}
- };
- char sentence[101] = "cat";
- CHECK(countReads(grid, 2, 2, sentence) == 2);
- }
- TEST_CASE("repeats squares") {
- char grid[30][30][101] = {
- {"one", "two", "three"},
- {"four", "five", "six"}
- };
- char sentence[101] = "one two three two five";
- CHECK(countReads(grid, 2, 3, sentence) == 1);
- }
- TEST_CASE("works for given example") {
- char grid[30][30][101] = {
- {"is", "the", "question"},
- {"that", "be", "or"},
- {"be", "to", "not"},
- {"or", "not", "to"}
- };
- char sentence[101] = "to be or not to be that is the question";
- CHECK(countReads(grid, 4, 3, sentence) == 4);
- }
- TEST_CASE("works for made up") {
- char grid[30][30][101] = {
- {"hello", "friend", "dear"},
- {"my", "dear", "my"},
- {"friend", "friend", "hello"},
- };
- char sentence[101] = "hello my dear friend";
- CHECK(countReads(grid, 3, 3, sentence) == 5);
- }
- TEST_CASE("works for sentence with consecutive repeating words") {
- char grid[30][30][101] = {
- {"it", "is", "an"},
- {"is", "objective", "objective"},
- {"an", "objective", "objective"},
- };
- char sentence[101] = "it is an objective objective";
- CHECK(countReads(grid, 3, 3, sentence) == 4);
- }
- TEST_CASE("works for even bigger sentence with consecutive repeating words") {
- char grid[30][30][101] = {
- {"end", "cannot", "end", "a", "conjunction"},
- {"a", "you", "conjunction", "sentence", "with"},
- {"sentence", "cannot", "a", "is", "because"},
- {"conjunction", "a", "is", "because", "because"} };
- char sentence[101] = "you cannot end a sentence with because because because is a conjunction";
- CHECK(countReads(grid, 4, 5, sentence) == 4);
- }
- int main() {
- // Пускане на тестовете с Doctest
- doctest::Context context;
- context.setOption("no-breaks", true);
- int status = context.run();
- // Магия за Visual Studio :)
- // `_MSC_VER` е дефинирано само ако компилатора е Visual Studio
- #ifdef _MSC_VER
- // Ако сме във Visual Studio - задръж ~вратата~ конзолата отворена
- std::cout << "Press any key to continue...";
- std::cin.get();
- #endif
- return status;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement