diff --git a/modules/core/test/test_misc.cpp b/modules/core/test/test_misc.cpp index 0f083bd951..ae71d8d149 100644 --- a/modules/core/test/test_misc.cpp +++ b/modules/core/test/test_misc.cpp @@ -133,6 +133,52 @@ TEST(Core_OutputArrayAssign, _Matxf_UMatd) } + +int fixedType_handler(OutputArray dst) +{ + int type = CV_32FC2; // return points only {x, y} + if (dst.fixedType()) + { + type = dst.type(); + CV_Assert(type == CV_32FC2 || type == CV_32FC3); // allow points + confidence level: {x, y, confidence} + } + const int N = 100; + dst.create(Size(1, N), type); + Mat m = dst.getMat(); + if (m.type() == CV_32FC2) + { + for (int i = 0; i < N; i++) + m.at(i) = Vec2f((float)i, (float)(i*2)); + } + else if (m.type() == CV_32FC3) + { + for (int i = 0; i < N; i++) + m.at(i) = Vec3f((float)i, (float)(i*2), 1.0f / (i + 1)); + } + else + { + CV_Assert(0 && "Internal error"); + } + return CV_MAT_CN(type); +} + +TEST(Core_OutputArray, FixedType) +{ + Mat_ pointsOnly; + int num_pointsOnly = fixedType_handler(pointsOnly); + EXPECT_EQ(2, num_pointsOnly); + + Mat_ pointsWithConfidence; + int num_pointsWithConfidence = fixedType_handler(pointsWithConfidence); + EXPECT_EQ(3, num_pointsWithConfidence); + + Mat defaultResult; + int num_defaultResult = fixedType_handler(defaultResult); + EXPECT_EQ(2, num_defaultResult); +} + + + TEST(Core_String, find_last_of__with__empty_string) { cv::String s;