]> OCCT Git - occt.git/commitdiff
0026448: Method Prepend() of sequence breaks it if argument is empty sequence
authorabv <abv@opencascade.com>
Wed, 15 Jul 2015 21:34:02 +0000 (00:34 +0300)
committerabv <abv@opencascade.com>
Thu, 16 Jul 2015 14:23:56 +0000 (17:23 +0300)
Check for empty input sequence added in methods Append() and Prepend() of TCollection and NCollection sequences.

Test bugs fclasses bug26448 added

src/NCollection/NCollection_BaseSequence.cxx
src/QABugs/QABugs_19.cxx
src/TCollection/TCollection_BaseSequence.cxx
tests/bugs/fclasses/bug26448 [new file with mode: 0644]

index fa39c9ae47d354d49f785edf93b2b13760f0ff27..ed4fb9fc0bf71493b6ab0b037fb2cb00f1c486ae 100644 (file)
@@ -68,6 +68,8 @@ void NCollection_BaseSequence::PAppend (NCollection_SeqNode * theItem)
 
 void NCollection_BaseSequence::PAppend(NCollection_BaseSequence& Other)
 {
+  if (Other.mySize == 0)
+    return;
   if (mySize == 0) {
     mySize         = Other.mySize;
     myFirstItem    = Other.myFirstItem;
@@ -113,6 +115,8 @@ void NCollection_BaseSequence::PPrepend (NCollection_SeqNode * theItem)
 
 void NCollection_BaseSequence::PPrepend (NCollection_BaseSequence& Other)
 {
+  if (Other.mySize == 0)
+    return;
   if (mySize == 0) {
     mySize         = Other.mySize;
     myFirstItem    = Other.myFirstItem;
index 35dd54732f26322de60901592c1ac54375b3dd05..0cc6a48de09c94a56db3ea0b87ed0a35a0ade398 100644 (file)
@@ -3663,6 +3663,22 @@ static Standard_Integer OCC24923(
   return 0;
 }
 
+static Standard_Integer OCC26448 (Draw_Interpretor& theDI, Standard_Integer, const char **)
+{
+  TColStd_SequenceOfReal aSeq1, aSeq2;
+  aSeq1.Append(11.);
+  aSeq1.Prepend (aSeq2);
+  theDI << "TCollection: 11 -> " << aSeq1.First() << "\n";
+
+  NCollection_Sequence<Standard_Real> nSeq1, nSeq2;
+  nSeq1.Append(11.);
+  nSeq1.Prepend (nSeq2);
+  theDI << "NCollection: 11 -> " << nSeq1.First() << "\n";
+
+  theDI << "OK";
+  return 0;
+}
+
 void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   const char *group = "QABugs";
 
@@ -3734,5 +3750,6 @@ void QABugs::Commands_19(Draw_Interpretor& theCommands) {
   theCommands.Add ("OCC24923", "OCC24923", __FILE__, OCC24923, group);
   theCommands.Add ("OCC26139", "OCC26139 [-boxsize value] [-boxgrid value] [-compgrid value]", __FILE__, OCC26139, group);
   theCommands.Add ("OCC26284", "OCC26284", __FILE__, OCC26284, group);
+  theCommands.Add ("OCC26448", "OCC26448: check method Prepend() of sequence", __FILE__, OCC26448, group);
   return;
 }
index 10f753f748178bf236ad38515fd551f17f44bd44..e6611245542293c3c049ca64293e401e3383505b 100644 (file)
@@ -67,6 +67,8 @@ void TCollection_BaseSequence::PAppend(const Standard_Address newnode)
 // ---------------------------------------------------
 void TCollection_BaseSequence::PAppend(TCollection_BaseSequence& Other)
 {
+  if (Other.Size == 0)
+    return;
   if (Size == 0) {
     Size         = Other.Size;
     FirstItem    = Other.FirstItem;
@@ -104,6 +106,8 @@ void TCollection_BaseSequence::PPrepend(const Standard_Address newnode)
 
 void TCollection_BaseSequence::PPrepend(TCollection_BaseSequence& Other)
 {
+  if (Other.Size == 0)
+    return;
   if (Size == 0) {
     Size         = Other.Size;
     FirstItem    = Other.FirstItem;
diff --git a/tests/bugs/fclasses/bug26448 b/tests/bugs/fclasses/bug26448
new file mode 100644 (file)
index 0000000..fe1f663
--- /dev/null
@@ -0,0 +1,10 @@
+puts "============"
+puts "OCC26448"
+puts "============"
+puts ""
+#######################################################################
+# Method Prepend() of sequence breaks it if argument is empty sequence
+#######################################################################
+
+pload QAcommands
+OCC26448