Advertisement
cepxuozab

CowImageTests

Apr 9th, 2024
866
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1. void ImageGetPixelTest(){
  2.       auto side = Tile::SIZE;
  3.       Size size{side * 2 + 3, side * 2 + 5};
  4.       const char color = 'g';
  5.       const Image img(size, color);
  6.       for (auto x = 0; x < size.width; ++x){
  7.         for (auto y = 0; y < size.height; ++y){
  8.           PRACTIKUM_ASSERT_EQUAL(img.GetPixel({x, y}), color);
  9.         }
  10.       }
  11.      
  12.       char blank = ' ';
  13.       ASSERT_EQUAL(img.GetPixel({-1, 2}), blank);
  14.       ASSERT_EQUAL(img.GetPixel({1, -2}), blank);
  15.       ASSERT_EQUAL(img.GetPixel({side*5, 2}), blank);
  16.       ASSERT_EQUAL(img.GetPixel({2, side*5}), blank);
  17.     }
  18.    
  19.     void ImageSetPixelTest(){
  20.       auto side = Tile::SIZE;
  21.       const Size size{side * 2 + 3, side * 2 + 5};
  22.       const char color = 'g';
  23.       Image img(size, color);
  24.       char new_color = 'n';
  25.       for (auto x = 0; x < size.width; ++x){
  26.         for (auto y = 0; y < size.height; ++y){
  27.           img.SetPixel({x, y}, new_color);
  28.           ASSERT_EQUAL(img.GetPixel({x, y}), new_color);
  29.         }
  30.       }
  31.      
  32.       img.SetPixel({-1, 3}, new_color);
  33.       img.SetPixel({1, -3}, new_color);
  34.       img.SetPixel({-1, -3}, new_color);
  35.       img.SetPixel({size.width, size.height + 2}, new_color);
  36.       img.SetPixel({size.width + 2, size.height}, new_color);
  37.       img.SetPixel({size.width + 2, size.height + 2}, new_color);
  38.       Print(img, cout);
  39.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement