test/common/rect.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 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 | 266318 | Rect::Rect(size_t start_row, size_t start_col, size_t height, size_t width) : | |
| 15 | 266318 | _start_row(start_row), _start_col(start_col), _height(height), _width(width) { | |
| 16 | 266318 | } | |
| 17 | |||
| 18 | 37969813 | size_t Rect::start_row() const { | |
| 19 | 37969813 | return _start_row; | |
| 20 | } | ||
| 21 | |||
| 22 | 36271160 | size_t Rect::start_col() const { | |
| 23 | 36271160 | return _start_col; | |
| 24 | } | ||
| 25 | |||
| 26 | 555848 | size_t Rect::height() const { | |
| 27 | 555848 | return _height; | |
| 28 | } | ||
| 29 | |||
| 30 | 15410758 | size_t Rect::width() const { | |
| 31 | 15410758 | return _width; | |
| 32 | } | ||
| 33 | |||
| 34 | 130194022 | size_t Rect::end_row() const { | |
| 35 | 130194022 | return _start_row + _height; | |
| 36 | } | ||
| 37 | |||
| 38 | 104876614 | size_t Rect::end_col() const { | |
| 39 | 104876614 | return _start_col + _width; | |
| 40 | } | ||
| 41 | |||
| 42 | 143617143 | bool Rect::contains(size_t row, size_t col) const { | |
| 43 |
6/6✓ Branch 0 taken 123303017 times.
✓ Branch 1 taken 20314126 times.
✓ Branch 2 taken 117774818 times.
✓ Branch 3 taken 5528199 times.
✓ Branch 4 taken 18287696 times.
✓ Branch 5 taken 99487122 times.
|
143617143 | 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 | ||
| 52 |