Advertisement
Guest User

sample_tests_5

a guest
Jan 20th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.58 KB | None | 0 0
  1. #define DOCTEST_CONFIG_IMPLEMENT
  2. #include "doctest.h"
  3. #include <iostream>
  4.  
  5. int countReads(char grid[30][30][101], int gridRows, int gridColumns, char sentence[90001]);
  6.  
  7. TEST_CASE("works for a single word") {
  8.     char grid[30][30][101] = {
  9.         {"cat"}
  10.     };
  11.     char sentence[101] = "cat";
  12.  
  13.     CHECK(countReads(grid, 1, 1, sentence) == 1);
  14. }
  15.  
  16. TEST_CASE("starts from any point of the grid") {
  17.     char grid[30][30][101] = {
  18.         {"cat", "dog"},
  19.         {"tiger", "cat"}
  20.     };
  21.     char sentence[101] = "cat";
  22.  
  23.     CHECK(countReads(grid, 2, 2, sentence) == 2);
  24. }
  25.  
  26. TEST_CASE("repeats squares") {
  27.     char grid[30][30][101] = {
  28.         {"one", "two", "three"},
  29.         {"four", "five", "six"}
  30.     };
  31.     char sentence[101] = "one two three two five";
  32.  
  33.     CHECK(countReads(grid, 2, 3, sentence) == 1);
  34. }
  35.  
  36. TEST_CASE("works for given example") {
  37.     char grid[30][30][101] = {
  38.         {"is", "the", "question"},
  39.         {"that", "be", "or"},
  40.         {"be", "to", "not"},
  41.         {"or", "not", "to"}
  42.     };
  43.     char sentence[101] = "to be or not to be that is the question";
  44.  
  45.     CHECK(countReads(grid, 4, 3, sentence) == 4);
  46. }
  47.  
  48. TEST_CASE("works for made up") {
  49.     char grid[30][30][101] = {
  50.         {"hello", "friend", "dear"},
  51.         {"my", "dear", "my"},
  52.         {"friend", "friend", "hello"},
  53.     };
  54.     char sentence[101] = "hello my dear friend";
  55.  
  56.     CHECK(countReads(grid, 3, 3, sentence) == 5);
  57. }
  58.  
  59. TEST_CASE("works for sentence with consecutive repeating words") {
  60.     char grid[30][30][101] = {
  61.         {"it", "is", "an"},
  62.         {"is", "objective", "objective"},
  63.         {"an", "objective", "objective"},
  64.     };
  65.     char sentence[101] = "it is an objective objective";
  66.  
  67.     CHECK(countReads(grid, 3, 3, sentence) == 4);
  68. }
  69.  
  70. TEST_CASE("works for even bigger sentence with consecutive repeating words") {
  71.     char grid[30][30][101] = {
  72.         {"end", "cannot", "end", "a", "conjunction"},
  73.         {"a", "you", "conjunction", "sentence", "with"},
  74.         {"sentence", "cannot", "a", "is", "because"},
  75.         {"conjunction", "a", "is", "because", "because"} };
  76.  
  77.     char sentence[101] = "you cannot end a sentence with because because because is a conjunction";
  78.  
  79.     CHECK(countReads(grid, 4, 5, sentence) == 4);
  80. }
  81.  
  82. int main() {
  83.     // Пускане на тестовете с Doctest
  84.     doctest::Context context;
  85.     context.setOption("no-breaks", true);
  86.  
  87.     int status = context.run();
  88.  
  89.     // Магия за Visual Studio :)
  90.     // `_MSC_VER` е дефинирано само ако компилатора е Visual Studio
  91. #ifdef _MSC_VER
  92.     // Ако сме във Visual Studio - задръж ~вратата~ конзолата отворена
  93.     std::cout << "Press any key to continue...";
  94.     std::cin.get();
  95. #endif
  96.  
  97.     return status;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement