Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
O
opencv
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
opencv
Commits
c1778f11
Commit
c1778f11
authored
Aug 20, 2015
by
Alexander Alekhin
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5161 from alalek:fix_string
parents
3afe8832
cda9ed44
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
0 deletions
+12
-0
cvstd.hpp
modules/core/include/opencv2/core/cvstd.hpp
+3
-0
test_misc.cpp
modules/core/test/test_misc.cpp
+9
-0
No files found.
modules/core/include/opencv2/core/cvstd.hpp
View file @
c1778f11
...
@@ -896,6 +896,7 @@ size_t String::find_first_of(const String& str, size_t pos) const
...
@@ -896,6 +896,7 @@ size_t String::find_first_of(const String& str, size_t pos) const
inline
inline
size_t
String
::
find_first_of
(
const
char
*
s
,
size_t
pos
)
const
size_t
String
::
find_first_of
(
const
char
*
s
,
size_t
pos
)
const
{
{
if
(
len_
==
0
)
return
npos
;
if
(
pos
>=
len_
||
!
s
[
0
])
return
npos
;
if
(
pos
>=
len_
||
!
s
[
0
])
return
npos
;
const
char
*
lmax
=
cstr_
+
len_
;
const
char
*
lmax
=
cstr_
+
len_
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
<
lmax
;
++
i
)
for
(
const
char
*
i
=
cstr_
+
pos
;
i
<
lmax
;
++
i
)
...
@@ -910,6 +911,7 @@ size_t String::find_first_of(const char* s, size_t pos) const
...
@@ -910,6 +911,7 @@ size_t String::find_first_of(const char* s, size_t pos) const
inline
inline
size_t
String
::
find_last_of
(
const
char
*
s
,
size_t
pos
,
size_t
n
)
const
size_t
String
::
find_last_of
(
const
char
*
s
,
size_t
pos
,
size_t
n
)
const
{
{
if
(
len_
==
0
)
return
npos
;
if
(
pos
>=
len_
)
pos
=
len_
-
1
;
if
(
pos
>=
len_
)
pos
=
len_
-
1
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
>=
cstr_
;
--
i
)
for
(
const
char
*
i
=
cstr_
+
pos
;
i
>=
cstr_
;
--
i
)
{
{
...
@@ -935,6 +937,7 @@ size_t String::find_last_of(const String& str, size_t pos) const
...
@@ -935,6 +937,7 @@ size_t String::find_last_of(const String& str, size_t pos) const
inline
inline
size_t
String
::
find_last_of
(
const
char
*
s
,
size_t
pos
)
const
size_t
String
::
find_last_of
(
const
char
*
s
,
size_t
pos
)
const
{
{
if
(
len_
==
0
)
return
npos
;
if
(
pos
>=
len_
)
pos
=
len_
-
1
;
if
(
pos
>=
len_
)
pos
=
len_
-
1
;
for
(
const
char
*
i
=
cstr_
+
pos
;
i
>=
cstr_
;
--
i
)
for
(
const
char
*
i
=
cstr_
+
pos
;
i
>=
cstr_
;
--
i
)
{
{
...
...
modules/core/test/test_misc.cpp
View file @
c1778f11
...
@@ -129,3 +129,12 @@ TEST(Core_OutputArrayAssign, _Matxf_UMatd)
...
@@ -129,3 +129,12 @@ TEST(Core_OutputArrayAssign, _Matxf_UMatd)
EXPECT_LE
(
maxAbsDiff
(
expected
,
actual
),
FLT_EPSILON
);
EXPECT_LE
(
maxAbsDiff
(
expected
,
actual
),
FLT_EPSILON
);
}
}
TEST
(
Core_String
,
find_last_of__with__empty_string
)
{
cv
::
String
s
;
size_t
p
=
s
.
find_last_of
(
"q"
,
0
);
// npos is not exported: EXPECT_EQ(cv::String::npos, p);
EXPECT_EQ
(
std
::
string
::
npos
,
p
);
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment