cepxuozab

CowTests

Nov 6th, 2024
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.90 KB | None | 0 0
  1. void TileCoWTest(){
  2.     using namespace std;
  3.         {
  4.             Tile tile_1('1');
  5.             cout << Tile::GetInstanceCount() << endl;
  6.             tile_1.SetPixel({1, 2}, 's');
  7.             cout << Tile::GetInstanceCount() << endl;
  8.  
  9.             Tile tile_2(tile_1);
  10.             cout << Tile::GetInstanceCount() << endl;
  11.            
  12.             tile_2.SetPixel({1, 2}, 'n');
  13.             cout << Tile::GetInstanceCount() << endl;
  14.  
  15.             tile_1.SetPixel({1, 2}, 'w');
  16.             cout << Tile::GetInstanceCount() << endl;
  17.         }
  18.         {
  19.             Tile tile('1');
  20.             tile.SetPixel({1, 2}, 's');
  21.             cout << Tile::GetInstanceCount() << endl;
  22.             Tile tile2('2');
  23.             cout << Tile::GetInstanceCount() << endl;
  24.             tile2.SetPixel({1, 2}, 'n');
  25.             cout << Tile::GetInstanceCount() << endl;
  26.         }
  27.     }
  28.  
  29. /*
  30. 1
  31. 1
  32. 2
  33. 2
  34. 2
  35. 1
  36. 2
  37. 2
  38. */
  39.  
  40. void ImageCoWTest(){
  41.      using namespace std;
  42.      
  43.       cout << Tile::GetInstanceCount() << endl;
  44.       auto side = Tile::SIZE;
  45.      
  46.       const Size size{side * 2 + 3, side * 2 + 5};
  47.       const char color = 'g';
  48.      
  49.       Image img(size, color);
  50.       cout << Tile::GetInstanceCount() << endl;
  51.      
  52.       char new_color = 'n';
  53.      
  54.       img.SetPixel({0, 0}, new_color);
  55.       cout << Tile::GetInstanceCount() << endl;
  56.       img.SetPixel({1, 1}, new_color);
  57.       cout << Tile::GetInstanceCount() << endl;
  58.      
  59.       img.SetPixel({side + 2, 0}, new_color);
  60.       cout << Tile::GetInstanceCount() << endl;
  61.      
  62.       img.SetPixel({0, side + 2}, new_color);
  63.       cout << Tile::GetInstanceCount() << endl;
  64.      
  65.       img.SetPixel({side + 3, side + 2}, new_color);
  66.       cout << Tile::GetInstanceCount() << endl;
  67.      
  68.       Image img2 = img;
  69.       cout << Tile::GetInstanceCount() << endl;
  70.      
  71.       img2.SetPixel({side + 1, side + 1}, new_color);
  72.       cout << Tile::GetInstanceCount() << endl;
  73.      
  74.       Print(img, cout);
  75.       Print(img2, cout);
  76.      
  77.     }
  78.  
  79. /*
  80. 0
  81. 1
  82. 2
  83. 2
  84. 3
  85. 4
  86. 5
  87. 5
  88. 6
  89. ngggggggggngggggggg
  90. gnggggggggggggggggg
  91. ggggggggggggggggggg
  92. ggggggggggggggggggg
  93. ggggggggggggggggggg
  94. ggggggggggggggggggg
  95. ggggggggggggggggggg
  96. ggggggggggggggggggg
  97. ggggggggggggggggggg
  98. ggggggggggggggggggg
  99. nggggggggggnggggggg
  100. ggggggggggggggggggg
  101. ggggggggggggggggggg
  102. ggggggggggggggggggg
  103. ggggggggggggggggggg
  104. ggggggggggggggggggg
  105. ggggggggggggggggggg
  106. ggggggggggggggggggg
  107. ggggggggggggggggggg
  108. ggggggggggggggggggg
  109. ggggggggggggggggggg
  110. ngggggggggngggggggg
  111. gnggggggggggggggggg
  112. ggggggggggggggggggg
  113. ggggggggggggggggggg
  114. ggggggggggggggggggg
  115. ggggggggggggggggggg
  116. ggggggggggggggggggg
  117. ggggggggggggggggggg
  118. ggggggggggggggggggg
  119. gggggggggnggggggggg
  120. nggggggggggnggggggg
  121. ggggggggggggggggggg
  122. ggggggggggggggggggg
  123. ggggggggggggggggggg
  124. ggggggggggggggggggg
  125. ggggggggggggggggggg
  126. ggggggggggggggggggg
  127. ggggggggggggggggggg
  128. ggggggggggggggggggg
  129. ggggggggggggggggggg
  130. ggggggggggggggggggg
  131. */
Add Comment
Please, Sign In to add comment