vendor: OpenCV 5.0.0 snapshot at 755e50675d97db9b7d449d8bd6b09888646f6c6e
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
/**
|
||||
* Tests whether cvv::debugMode() and cvv::setDebugFlag(bool)`
|
||||
* (from /include/opencv2/debug_mode.hpp) behave correctly.
|
||||
*/
|
||||
|
||||
TEST(DebugFlagTest, SetAndUnsetDebugMode)
|
||||
{
|
||||
EXPECT_EQ(cvv::debugMode(), true);
|
||||
cvv::setDebugFlag(false);
|
||||
EXPECT_EQ(cvv::debugMode(), false);
|
||||
cvv::setDebugFlag(true);
|
||||
EXPECT_EQ(cvv::debugMode(), true);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
@@ -0,0 +1,46 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
#include "../src/util/util.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
/**
|
||||
* Tests whether the `cvv::util::isAnyOf()` function (from /src/util/util.hpp) correctly recognises
|
||||
* the first parameter as element or not element of the data structure in the second parameter
|
||||
* for the following structures:
|
||||
* - Initializer lists with `int int`
|
||||
* - Initializer lists with `long int`
|
||||
* - Vectors of `int int`
|
||||
* - Vectors of `long int`
|
||||
*/
|
||||
|
||||
using cvv::util::isAnyOf;
|
||||
|
||||
TEST(IsAnyOfTest, InitializerListIntInt)
|
||||
{
|
||||
EXPECT_EQ(isAnyOf(3, { 1, 2, 3, 4 }), true);
|
||||
EXPECT_EQ(isAnyOf(3, { 1, 2, 4 }), false);
|
||||
}
|
||||
|
||||
TEST(IsAnyOfTest, InitializerListLongInt)
|
||||
{
|
||||
EXPECT_EQ(isAnyOf(3, { 1L, 2L, 3L, 4L }), true);
|
||||
EXPECT_EQ(isAnyOf(3, { 1L, 2L, 4L }), false);
|
||||
}
|
||||
|
||||
TEST(IsAnyOfTest, VectorIntInt)
|
||||
{
|
||||
EXPECT_EQ(isAnyOf(3, std::vector<int>{ 1, 2, 3, 4 }), true);
|
||||
EXPECT_EQ(isAnyOf(3, std::vector<int>{ 1, 2, 4 }), false);
|
||||
}
|
||||
|
||||
TEST(IsAnyOfTest, VectorLongInt)
|
||||
{
|
||||
EXPECT_EQ(isAnyOf(3, std::vector<long>{ 1, 2, 3, 4 }), true);
|
||||
EXPECT_EQ(isAnyOf(3, std::vector<long>{ 1, 2, 4 }), false);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
@@ -0,0 +1,33 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
/**
|
||||
* Tests whether the `CVVISUAL_LOCATION` macro (from /include/opencv2/call_meta_data.hpp)
|
||||
* works as expected, i.e. the instance of `cvv::impl::CallMetaData` as which it gets defined has the correct data.
|
||||
* The second test in this file checks wether a `cvv::impl::CallMataData` created by hand and with an empty
|
||||
* initializer list has no known location, as it is supposed to be.
|
||||
*/
|
||||
|
||||
TEST(LocationTest, FileLineFunction)
|
||||
{
|
||||
auto locationMacroResult = CVVISUAL_LOCATION;
|
||||
size_t line = __LINE__ - 1;
|
||||
auto file = __FILE__;
|
||||
auto fun = CV_Func;
|
||||
EXPECT_EQ(locationMacroResult.isKnown, true);
|
||||
EXPECT_EQ(locationMacroResult.file, file);
|
||||
EXPECT_EQ(locationMacroResult.line, line);
|
||||
EXPECT_EQ(locationMacroResult.function, fun);
|
||||
}
|
||||
|
||||
TEST(LocationTest, EmptyLocation)
|
||||
{
|
||||
cvv::impl::CallMetaData loc{};
|
||||
EXPECT_EQ(loc.isKnown, false);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
@@ -0,0 +1,6 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
CV_TEST_MAIN(".", /*Empty VA_ARGS for C++11*/)
|
||||
@@ -0,0 +1,27 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
#include "../src/util/observer_ptr.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
/**
|
||||
* Verifies that assigning `nullptr` and a nonzero value to a `cvv::util::ObserverPtr<Int>`
|
||||
* (from /src/util/observer_ptr.hpp) work and that `isNull()` and `getPtr()` return the correct result.
|
||||
*/
|
||||
|
||||
using cvv::util::ObserverPtr;
|
||||
|
||||
TEST(ObserverPtrTest, ConstructionAssignment)
|
||||
{
|
||||
ObserverPtr<int> ptr = nullptr;
|
||||
EXPECT_TRUE(ptr.isNull());
|
||||
int x = 3;
|
||||
ptr = x;
|
||||
EXPECT_FALSE(ptr.isNull());
|
||||
EXPECT_EQ(&x, ptr.getPtr());
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
@@ -0,0 +1,12 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#ifndef __OPENCV_TEST_PRECOMP_HPP__
|
||||
#define __OPENCV_TEST_PRECOMP_HPP__
|
||||
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <opencv2/ts.hpp>
|
||||
#include <opencv2/cvv.hpp>
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,109 @@
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
#include "../src/util/util.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
|
||||
/**
|
||||
* Makes sure that
|
||||
* - creating, reassigning and comparing `cvv::util::Reference<int>`s (from /src/util/util.hpp) works,
|
||||
* as well as the
|
||||
* - `makeRef()` and `getPtr()` functions; that
|
||||
* - `Reference<const int>`s can be created with `makeRef(const int)`, `{const int}` initializer list
|
||||
* and via `Reference<const int>{int}` and, finally, that
|
||||
* - `cvv::util::Reference`s of super classes can be constructed with derived classes and
|
||||
* - `Reference`s to base classes can be `castTo()` `References` to the derived classes, but not the other way.
|
||||
*/
|
||||
|
||||
using cvv::util::Reference;
|
||||
using cvv::util::makeRef;
|
||||
|
||||
TEST(ReferenceTest, Construction)
|
||||
{
|
||||
int i = 3;
|
||||
Reference<int> ref1{ i };
|
||||
EXPECT_EQ(*ref1, 3);
|
||||
}
|
||||
|
||||
TEST(ReferenceTest, Reassignment)
|
||||
{
|
||||
int i1 = 3;
|
||||
int i2 = 4;
|
||||
Reference<int> ref{ i1 };
|
||||
EXPECT_EQ(ref.getPtr(), &i1);
|
||||
EXPECT_EQ(*ref, 3);
|
||||
ref = Reference<int>{ i2 };
|
||||
EXPECT_EQ(*ref, 4);
|
||||
EXPECT_EQ(ref.getPtr(), &i2);
|
||||
}
|
||||
|
||||
TEST(ReferenceTest, Comparing)
|
||||
{
|
||||
int i1 = 1, i2 = 1;
|
||||
auto ref1 = makeRef(i1);
|
||||
auto ref2 = makeRef(i1);
|
||||
auto ref3 = makeRef(i2);
|
||||
|
||||
EXPECT_EQ(ref1 == ref2, true);
|
||||
EXPECT_EQ(ref1 != ref2, false);
|
||||
EXPECT_EQ(ref1 == ref3, false);
|
||||
EXPECT_EQ(ref1 != ref3, true);
|
||||
}
|
||||
|
||||
TEST(ReferenceTest, MakeRef)
|
||||
{
|
||||
int i1 = 3, i2 = 4;
|
||||
auto ref = makeRef(i1);
|
||||
EXPECT_EQ(*ref, 3);
|
||||
EXPECT_EQ(ref.getPtr(), &i1);
|
||||
ref = makeRef(i2);
|
||||
EXPECT_EQ(*ref, 4);
|
||||
EXPECT_EQ(ref.getPtr(), &i2);
|
||||
}
|
||||
|
||||
TEST(ReferenceTest, ConstRefs)
|
||||
{
|
||||
const int i = 3;
|
||||
auto ref1 = makeRef(i);
|
||||
Reference<const int> ref2{ i };
|
||||
EXPECT_EQ(ref1, ref2);
|
||||
}
|
||||
|
||||
TEST(ReferenceTest, ConstRefsFromMutable)
|
||||
{
|
||||
int i = 100;
|
||||
Reference<const int> ref{ i };
|
||||
EXPECT_EQ(ref.getPtr(), &i);
|
||||
}
|
||||
|
||||
struct Base
|
||||
{
|
||||
virtual ~Base() = default;
|
||||
};
|
||||
struct Derived : Base
|
||||
{
|
||||
};
|
||||
struct Derived2 : Base
|
||||
{
|
||||
};
|
||||
|
||||
TEST(ReferenceTest, LiberalConstruction)
|
||||
{
|
||||
Derived var;
|
||||
auto derivedRef = makeRef(var);
|
||||
Reference<Base> baseRef{ derivedRef };
|
||||
EXPECT_EQ(&var, baseRef.getPtr());
|
||||
}
|
||||
|
||||
TEST(ReferenceTest, castTo)
|
||||
{
|
||||
Derived var;
|
||||
Reference<Base> baseRef{ var };
|
||||
auto derivedRef = baseRef.castTo<Derived>();
|
||||
EXPECT_EQ(&var, derivedRef.getPtr());
|
||||
EXPECT_THROW(baseRef.castTo<Derived2>(), std::bad_cast);
|
||||
// should result in a compiler-error:
|
||||
// EXPECT_THROW(baseRef.castTo<std::vector<int>>(), std::bad_cast);
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
Reference in New Issue
Block a user