Anthony Barbier | dbdab85 | 2017-06-23 15:42:00 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2017 ARM Limited. |
| 3 | * |
| 4 | * SPDX-License-Identifier: MIT |
| 5 | * |
| 6 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | * of this software and associated documentation files (the "Software"), to |
| 8 | * deal in the Software without restriction, including without limitation the |
| 9 | * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or |
| 10 | * sell copies of the Software, and to permit persons to whom the Software is |
| 11 | * furnished to do so, subject to the following conditions: |
| 12 | * |
| 13 | * The above copyright notice and this permission notice shall be included in all |
| 14 | * copies or substantial portions of the Software. |
| 15 | * |
| 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | * SOFTWARE. |
| 23 | */ |
| 24 | #include "TypePrinter.h" |
| 25 | #include "validation/Validation.h" |
| 26 | |
| 27 | #include "arm_compute/core/TensorShape.h" |
| 28 | |
| 29 | #include "boost_wrapper.h" |
| 30 | |
| 31 | using namespace arm_compute; |
| 32 | using namespace arm_compute::test; |
| 33 | using namespace arm_compute::test::validation; |
| 34 | |
| 35 | #ifndef DOXYGEN_SKIP_THIS |
| 36 | BOOST_AUTO_TEST_SUITE(UNIT) |
| 37 | BOOST_AUTO_TEST_SUITE(TensorShapeValidation) |
| 38 | |
| 39 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) |
| 40 | BOOST_DATA_TEST_CASE(Construction, |
| 41 | boost::unit_test::data::make({ TensorShape{}, |
| 42 | TensorShape{ 1U }, |
| 43 | TensorShape{ 2U }, |
| 44 | TensorShape{ 2U, 3U }, |
| 45 | TensorShape{ 2U, 3U, 5U }, |
| 46 | TensorShape{ 2U, 3U, 5U, 7U }, |
| 47 | TensorShape{ 2U, 3U, 5U, 7U, 11U }, |
| 48 | TensorShape{ 2U, 3U, 5U, 7U, 11U, 13U } |
| 49 | }) |
| 50 | ^ boost::unit_test::data::make({ 0, 0, 1, 2, 3, 4, 5, 6 }) ^ boost::unit_test::data::make({ 0, 1, 2, 6, 30, 210, 2310, 30030 }), |
| 51 | shape, num_dimensions, total_size) |
| 52 | { |
| 53 | BOOST_TEST(shape.num_dimensions() == num_dimensions); |
| 54 | BOOST_TEST(shape.total_size() == total_size); |
| 55 | } |
| 56 | |
| 57 | BOOST_TEST_DECORATOR(*boost::unit_test::label("precommit") * boost::unit_test::label("nightly")) |
| 58 | BOOST_DATA_TEST_CASE(SetEmpty, boost::unit_test::data::make({ 0, 1, 2, 3, 4, 5 }), dimension) |
| 59 | { |
| 60 | TensorShape shape; |
| 61 | |
| 62 | shape.set(dimension, 10); |
| 63 | |
| 64 | BOOST_TEST(shape.num_dimensions() == dimension + 1); |
| 65 | BOOST_TEST(shape.total_size() == 10); |
| 66 | } |
| 67 | |
| 68 | BOOST_AUTO_TEST_SUITE_END() |
| 69 | BOOST_AUTO_TEST_SUITE_END() |
| 70 | #endif |