From 2b17955f784d216237f6f8fd7f89f20d3580576f Mon Sep 17 00:00:00 2001 From: Daniel Silverstone Date: Thu, 5 Jul 2012 09:52:43 +0100 Subject: CharacterData.delete: Fix this and enable 5 more tests --- src/core/characterdata.c | 6 ++- .../core/characterdatadeletedatabegining.xml | 45 ++++++++++++++++++ .../core/characterdatadeletedatabegining.xml.kfail | 45 ------------------ .../level1/core/characterdatadeletedataend.xml | 47 +++++++++++++++++++ .../core/characterdatadeletedataend.xml.kfail | 47 ------------------- .../core/characterdatadeletedataexceedslength.xml | 49 ++++++++++++++++++++ .../characterdatadeletedataexceedslength.xml.kfail | 49 -------------------- .../characterdatadeletedatagetlengthanddata.xml | 54 ++++++++++++++++++++++ ...aracterdatadeletedatagetlengthanddata.xml.kfail | 54 ---------------------- .../level1/core/characterdatadeletedatamiddle.xml | 47 +++++++++++++++++++ .../core/characterdatadeletedatamiddle.xml.kfail | 47 ------------------- 11 files changed, 247 insertions(+), 243 deletions(-) create mode 100644 test/testcases/tests/level1/core/characterdatadeletedatabegining.xml delete mode 100644 test/testcases/tests/level1/core/characterdatadeletedatabegining.xml.kfail create mode 100644 test/testcases/tests/level1/core/characterdatadeletedataend.xml delete mode 100644 test/testcases/tests/level1/core/characterdatadeletedataend.xml.kfail create mode 100644 test/testcases/tests/level1/core/characterdatadeletedataexceedslength.xml delete mode 100644 test/testcases/tests/level1/core/characterdatadeletedataexceedslength.xml.kfail create mode 100644 test/testcases/tests/level1/core/characterdatadeletedatagetlengthanddata.xml delete mode 100644 test/testcases/tests/level1/core/characterdatadeletedatagetlengthanddata.xml.kfail create mode 100644 test/testcases/tests/level1/core/characterdatadeletedatamiddle.xml delete mode 100644 test/testcases/tests/level1/core/characterdatadeletedatamiddle.xml.kfail diff --git a/src/core/characterdata.c b/src/core/characterdata.c index 79b5fbe..0883444 100644 --- a/src/core/characterdata.c +++ b/src/core/characterdata.c @@ -343,6 +343,7 @@ dom_exception _dom_characterdata_delete_data(struct dom_characterdata *cdata, dom_exception err; struct dom_document *doc; bool success = true; + dom_string *empty; if (_dom_node_readonly(c)) { return DOM_NO_MODIFICATION_ALLOWED_ERR; @@ -364,7 +365,10 @@ dom_exception _dom_characterdata_delete_data(struct dom_characterdata *cdata, end = (offset + count) >= len ? len : offset + count; - err = dom_string_replace(c->value, NULL, offset, end, &temp); + empty = ((struct dom_document *) + ((struct dom_node_internal *)c)->owner)->_memo_empty; + + err = dom_string_replace(c->value, empty, offset, end, &temp); if (err != DOM_NO_ERR) { return err; } diff --git a/test/testcases/tests/level1/core/characterdatadeletedatabegining.xml b/test/testcases/tests/level1/core/characterdatadeletedatabegining.xml new file mode 100644 index 0000000..d1cf6a3 --- /dev/null +++ b/test/testcases/tests/level1/core/characterdatadeletedatabegining.xml @@ -0,0 +1,45 @@ + + + + +characterdataDeleteDataBeginning +NIST + +The "deleteData(offset,count)" method removes a range of +characters from the node. Delete data at the beginning +of the character data. + +Retrieve the character data from the last child of the +first employee. The "deleteData(offset,count)" +method is then called with offset=0 and count=16. +The method should delete the characters from position +0 thru position 16. The new value of the character data +should be "Dallas, Texas 98551". + +Mary Brady +2001-08-17 + + + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/core/characterdatadeletedatabegining.xml.kfail b/test/testcases/tests/level1/core/characterdatadeletedatabegining.xml.kfail deleted file mode 100644 index d1cf6a3..0000000 --- a/test/testcases/tests/level1/core/characterdatadeletedatabegining.xml.kfail +++ /dev/null @@ -1,45 +0,0 @@ - - - - -characterdataDeleteDataBeginning -NIST - -The "deleteData(offset,count)" method removes a range of -characters from the node. Delete data at the beginning -of the character data. - -Retrieve the character data from the last child of the -first employee. The "deleteData(offset,count)" -method is then called with offset=0 and count=16. -The method should delete the characters from position -0 thru position 16. The new value of the character data -should be "Dallas, Texas 98551". - -Mary Brady -2001-08-17 - - - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/core/characterdatadeletedataend.xml b/test/testcases/tests/level1/core/characterdatadeletedataend.xml new file mode 100644 index 0000000..052ae11 --- /dev/null +++ b/test/testcases/tests/level1/core/characterdatadeletedataend.xml @@ -0,0 +1,47 @@ + + + + + +characterdataDeleteDataEnd +NIST + + The "deleteData(offset,count)" method removes a range of + characters from the node. Delete data at the end + of the character data. + + Retrieve the character data from the last child of the + first employee. The "deleteData(offset,count)" + method is then called with offset=30 and count=5. + The method should delete the characters from position + 30 thru position 35. The new value of the character data + should be "1230 North Ave. Dallas, Texas". + +Mary Brady +2001-08-17 + + + + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/core/characterdatadeletedataend.xml.kfail b/test/testcases/tests/level1/core/characterdatadeletedataend.xml.kfail deleted file mode 100644 index 052ae11..0000000 --- a/test/testcases/tests/level1/core/characterdatadeletedataend.xml.kfail +++ /dev/null @@ -1,47 +0,0 @@ - - - - - -characterdataDeleteDataEnd -NIST - - The "deleteData(offset,count)" method removes a range of - characters from the node. Delete data at the end - of the character data. - - Retrieve the character data from the last child of the - first employee. The "deleteData(offset,count)" - method is then called with offset=30 and count=5. - The method should delete the characters from position - 30 thru position 35. The new value of the character data - should be "1230 North Ave. Dallas, Texas". - -Mary Brady -2001-08-17 - - - - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/core/characterdatadeletedataexceedslength.xml b/test/testcases/tests/level1/core/characterdatadeletedataexceedslength.xml new file mode 100644 index 0000000..fe80a3b --- /dev/null +++ b/test/testcases/tests/level1/core/characterdatadeletedataexceedslength.xml @@ -0,0 +1,49 @@ + + + + + +characterdataDeleteDataExceedsLength +NIST + + If the sum of the offset and count used in the + "deleteData(offset,count) method is greater than the + length of the character data then all the characters + from the offset to the end of the data are deleted. + + Retrieve the character data from the last child of the + first employee. The "deleteData(offset,count)" + method is then called with offset=4 and count=50. + The method should delete the characters from position 4 + to the end of the data since the offset+count(50+4) + is greater than the length of the character data(35). + The new value of the character data should be "1230". + +Mary Brady +2001-08-17 + + + + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/core/characterdatadeletedataexceedslength.xml.kfail b/test/testcases/tests/level1/core/characterdatadeletedataexceedslength.xml.kfail deleted file mode 100644 index fe80a3b..0000000 --- a/test/testcases/tests/level1/core/characterdatadeletedataexceedslength.xml.kfail +++ /dev/null @@ -1,49 +0,0 @@ - - - - - -characterdataDeleteDataExceedsLength -NIST - - If the sum of the offset and count used in the - "deleteData(offset,count) method is greater than the - length of the character data then all the characters - from the offset to the end of the data are deleted. - - Retrieve the character data from the last child of the - first employee. The "deleteData(offset,count)" - method is then called with offset=4 and count=50. - The method should delete the characters from position 4 - to the end of the data since the offset+count(50+4) - is greater than the length of the character data(35). - The new value of the character data should be "1230". - -Mary Brady -2001-08-17 - - - - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/core/characterdatadeletedatagetlengthanddata.xml b/test/testcases/tests/level1/core/characterdatadeletedatagetlengthanddata.xml new file mode 100644 index 0000000..533a19e --- /dev/null +++ b/test/testcases/tests/level1/core/characterdatadeletedatagetlengthanddata.xml @@ -0,0 +1,54 @@ + + + + + +characterdataDeleteDataGetLengthAndData +NIST + + On successful invocation of the "deleteData(offset,count)" + method, the "getData()" and "getLength()" methods reflect + the changes. + + Retrieve the character data from the last child of the + first employee. The "deleteData(offset,count)" + method is then called with offset=30 and count=5. + The method should delete the characters from position + 30 thru position 35. The new value of the character data + should be "1230 North Ave. Dallas, Texas" which is + returned by the "getData()" method and "getLength()" + method should return 30". + +Mary Brady +2001-08-17 + + + + + + + + + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/core/characterdatadeletedatagetlengthanddata.xml.kfail b/test/testcases/tests/level1/core/characterdatadeletedatagetlengthanddata.xml.kfail deleted file mode 100644 index 533a19e..0000000 --- a/test/testcases/tests/level1/core/characterdatadeletedatagetlengthanddata.xml.kfail +++ /dev/null @@ -1,54 +0,0 @@ - - - - - -characterdataDeleteDataGetLengthAndData -NIST - - On successful invocation of the "deleteData(offset,count)" - method, the "getData()" and "getLength()" methods reflect - the changes. - - Retrieve the character data from the last child of the - first employee. The "deleteData(offset,count)" - method is then called with offset=30 and count=5. - The method should delete the characters from position - 30 thru position 35. The new value of the character data - should be "1230 North Ave. Dallas, Texas" which is - returned by the "getData()" method and "getLength()" - method should return 30". - -Mary Brady -2001-08-17 - - - - - - - - - - - - - - - - - - - - - diff --git a/test/testcases/tests/level1/core/characterdatadeletedatamiddle.xml b/test/testcases/tests/level1/core/characterdatadeletedatamiddle.xml new file mode 100644 index 0000000..8488008 --- /dev/null +++ b/test/testcases/tests/level1/core/characterdatadeletedatamiddle.xml @@ -0,0 +1,47 @@ + + + + + +characterdataDeleteDataMiddle +NIST + + The "deleteData(offset,count)" method removes a range of + characters from the node. Delete data in the middle + of the character data. + + Retrieve the character data from the last child of the + first employee. The "deleteData(offset,count)" + method is then called with offset=16 and count=8. + The method should delete the characters from position + 16 thru position 24. The new value of the character data + should be "1230 North Ave. Texas 98551". + +Mary Brady +2001-08-17 + + + + + + + + + + + + + + + + diff --git a/test/testcases/tests/level1/core/characterdatadeletedatamiddle.xml.kfail b/test/testcases/tests/level1/core/characterdatadeletedatamiddle.xml.kfail deleted file mode 100644 index 8488008..0000000 --- a/test/testcases/tests/level1/core/characterdatadeletedatamiddle.xml.kfail +++ /dev/null @@ -1,47 +0,0 @@ - - - - - -characterdataDeleteDataMiddle -NIST - - The "deleteData(offset,count)" method removes a range of - characters from the node. Delete data in the middle - of the character data. - - Retrieve the character data from the last child of the - first employee. The "deleteData(offset,count)" - method is then called with offset=16 and count=8. - The method should delete the characters from position - 16 thru position 24. The new value of the character data - should be "1230 North Ave. Texas 98551". - -Mary Brady -2001-08-17 - - - - - - - - - - - - - - - - -- cgit v1.2.3