| 1 | // |
| 2 | // SPDX-FileCopyrightText: Copyright 2024 Arm Limited and/or its affiliates <open-source-office@arm.com> |
| 3 | // |
| 4 | // SPDX-License-Identifier: Apache-2.0 |
| 5 | // |
| 6 | |
| 7 | #include "test/common/rect.hpp" |
| 8 | |
| 9 | #include <cstddef> |
| 10 | #include <ostream> |
| 11 | |
| 12 | namespace kai::test { |
| 13 | |
| 14 | Rect::Rect(size_t start_row, size_t start_col, size_t height, size_t width) : |
| 15 | _start_row(start_row), _start_col(start_col), _height(height), _width(width) { |
| 16 | } |
| 17 | |
| 18 | size_t Rect::start_row() const { |
| 19 | return _start_row; |
| 20 | } |
| 21 | |
| 22 | size_t Rect::start_col() const { |
| 23 | return _start_col; |
| 24 | } |
| 25 | |
| 26 | size_t Rect::height() const { |
| 27 | return _height; |
| 28 | } |
| 29 | |
| 30 | size_t Rect::width() const { |
| 31 | return _width; |
| 32 | } |
| 33 | |
| 34 | size_t Rect::end_row() const { |
| 35 | return _start_row + _height; |
| 36 | } |
| 37 | |
| 38 | size_t Rect::end_col() const { |
| 39 | return _start_col + _width; |
| 40 | } |
| 41 | |
| 42 | bool Rect::contains(size_t row, size_t col) const { |
| 43 | return row >= _start_row && row < end_row() && col >= _start_col && col < end_col(); |
| 44 | } |
| 45 | |
| 46 | std::ostream& operator<<(std::ostream& os, const Rect& rect) { |
| 47 | return os << "[start_row=" << rect.start_row() << ", start_col=" << rect.start_col() << ", height=" << rect.height() |
| 48 | << ", width=" << rect.width() << "]"; |
| 49 | } |
| 50 | |
| 51 | } // namespace kai::test |