| 1 |
/* |
| 2 |
libheif Box equality unit tests |
| 3 |
|
| 4 |
MIT License |
| 5 |
|
| 6 |
Copyright (c) 2024 Brad Hards <[email protected]> |
| 7 |
|
| 8 |
Permission is hereby granted, free of charge, to any person obtaining a copy |
| 9 |
of this software and associated documentation files (the "Software"), to deal |
| 10 |
in the Software without restriction, including without limitation the rights |
| 11 |
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 12 |
copies of the Software, and to permit persons to whom the Software is |
| 13 |
furnished to do so, subject to the following conditions: |
| 14 |
|
| 15 |
The above copyright notice and this permission notice shall be included in all |
| 16 |
copies or substantial portions of the Software. |
| 17 |
|
| 18 |
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 19 |
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 20 |
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 21 |
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 22 |
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 23 |
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 24 |
SOFTWARE. |
| 25 |
*/ |
| 26 |
|
| 27 |
#include "catch_amalgamated.hpp" |
| 28 |
#include "box.h" |
| 29 |
|
| 30 |
TEST_CASE("box equals") { |
| 31 |
std::shared_ptr<Box_ispe> ispe1 = std::make_shared<Box_ispe>(); |
| 32 |
ispe1->set_size(100, 200); |
| 33 |
|
| 34 |
std::shared_ptr<Box_ispe> ispe2 = std::make_shared<Box_ispe>(); |
| 35 |
ispe2->set_size(100, 250); |
| 36 |
|
| 37 |
std::shared_ptr<Box_ispe> ispe3 = std::make_shared<Box_ispe>(); |
| 38 |
ispe3->set_size(100, 200); |
| 39 |
|
| 40 |
std::shared_ptr<Box_clap> clap = std::make_shared<Box_clap>(); |
| 41 |
clap->set(100, 200, 150, 250); |
| 42 |
|
| 43 |
REQUIRE(Box::equal(ispe1, ispe2) == false); |
| 44 |
REQUIRE(Box::equal(ispe1, ispe3) == true); |
| 45 |
REQUIRE(Box::equal(ispe3, ispe1) == true); |
| 46 |
REQUIRE(Box::equal(ispe1, 0) == false); |
| 47 |
REQUIRE(Box::equal(clap, ispe1) == false); |
| 48 |
REQUIRE(Box::equal(0, ispe1) == false); |
| 49 |
} |
| 50 |
|
| 51 |
TEST_CASE("add_box") { |
| 52 |
std::shared_ptr<Box_ispe> ispe1 = std::make_shared<Box_ispe>(); |
| 53 |
ispe1->set_size(100, 200); |
| 54 |
|
| 55 |
std::shared_ptr<Box_ispe> ispe2 = std::make_shared<Box_ispe>(); |
| 56 |
ispe2->set_size(100, 250); |
| 57 |
|
| 58 |
std::shared_ptr<Box_ispe> ispe3 = std::make_shared<Box_ispe>(); |
| 59 |
ispe3->set_size(100, 200); |
| 60 |
|
| 61 |
std::shared_ptr<Box_ipco> ipco = std::make_shared<Box_ipco>(); |
| 62 |
REQUIRE(ipco->find_or_append_child_box(ispe1) == 0); |
| 63 |
REQUIRE(ipco->find_or_append_child_box(ispe2) == 1); |
| 64 |
REQUIRE(ipco->find_or_append_child_box(ispe3) == 0); |
| 65 |
} |