1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-03 17:56:21 +03:00

0030536: Foundation Classes - TCollection_ExtendedString::StartsWith() and EndsWith() have a mistake

Draw-commands StartsWith and EndsWith are renamed to QAStartsWith and QAEndsWith.
The test script bug30536 was corrected.
This commit is contained in:
vro 2019-03-18 10:16:40 +03:00 committed by apn
parent 404504b234
commit 43c8661e5e
3 changed files with 73 additions and 2 deletions

View File

@ -3060,6 +3060,44 @@ static Standard_Integer OCC30391(Draw_Interpretor& theDI,
return 0;
}
//=======================================================================
//function : QAStartsWith string startstring
//=======================================================================
static Standard_Integer QAStartsWith(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n == 3)
{
TCollection_ExtendedString str = a[1];
TCollection_ExtendedString startstr = a[2];
if (str.StartsWith(startstr))
di << "Yes";
else
di << "No";
return 0;
}
std::cerr << "Syntax error\n";
return 1;
}
//=======================================================================
//function : QAEndsWith string endstring
//=======================================================================
static Standard_Integer QAEndsWith(Draw_Interpretor& di, Standard_Integer n, const char** a)
{
if (n == 3)
{
TCollection_ExtendedString str = a[1];
TCollection_ExtendedString endstr = a[2];
if (str.EndsWith(endstr))
di << "Yes";
else
di << "No";
return 0;
}
std::cerr << "Syntax error\n";
return 1;
}
void QABugs::Commands_20(Draw_Interpretor& theCommands) {
const char *group = "QABugs";
@ -3101,5 +3139,13 @@ void QABugs::Commands_20(Draw_Interpretor& theCommands) {
theCommands.Add("OCC29311", "OCC29311 shape counter nbiter: check performance of OBB calculation", __FILE__, OCC29311, group);
theCommands.Add("OCC30391", "OCC30391 result face LenBeforeUfirst LenAfterUlast LenBeforeVfirst LenAfterVlast", __FILE__, OCC30391, group);
theCommands.Add("QAStartsWith",
"QAStartsWith string startstring",
__FILE__, QAStartsWith, group);
theCommands.Add("QAEndsWith",
"QAEndsWith string endstring",
__FILE__, QAEndsWith, group);
return;
}

View File

@ -539,7 +539,7 @@ Standard_Boolean TCollection_ExtendedString::StartsWith (const TCollection_Exten
}
return mylength >= theStartString.mylength
&& memcmp (theStartString.mystring, mystring, theStartString.mylength) == 0;
&& memcmp (theStartString.mystring, mystring, theStartString.mylength * sizeof(Standard_ExtCharacter)) == 0;
}
// ----------------------------------------------------------------------------
@ -553,7 +553,7 @@ Standard_Boolean TCollection_ExtendedString::EndsWith (const TCollection_Extende
}
return mylength >= theEndString.mylength
&& memcmp (theEndString.mystring, mystring + mylength - theEndString.mylength, theEndString.mylength) == 0;
&& memcmp (theEndString.mystring, mystring + mylength - theEndString.mylength, theEndString.mylength * sizeof(Standard_ExtCharacter)) == 0;
}
// ----------------------------------------------------------------------------

View File

@ -0,0 +1,25 @@
puts "============"
puts "0030536: Foundation Classes - TCollection_ExtendedString::StartsWith() and EndsWith() have a mistake"
puts "============"
pload QAcommands
set ret1 [QAStartsWith hello help]
if { ${ret1} == "Yes" } {
puts "Error"
}
set ret2 [QAStartsWith hello he]
if { ${ret2} == "No" } {
puts "Error"
}
set ret3 [QAEndsWith hello ll]
if { ${ret3} == "Yes" } {
puts "Error"
}
set ret4 [QAEndsWith hello lo]
if { ${ret4} == "No" } {
puts "Error"
}