-
-
Save johnsogg/4638191 to your computer and use it in GitHub Desktop.
void remove(node** parent, int offset) { | |
node* cursor = *parent; | |
if (cursor->next==NULL || offset > size(*parent)) { | |
return; | |
} else if (offset==0) { | |
cursor=cursor->next; | |
} else { | |
for (int i=1;i<offset;i++) { | |
cursor=cursor->next; | |
} | |
cursor->next=cursor->next->next; | |
} | |
} |
Created a RetroGrade instance.
Assignment: hw_1_linked_lists
Student: [email protected]
Student Files: /tmp/tmpsHfsFt/linked_list.cpp
File: /tmp/tmpsHfsFt/linked_list.cpp
Determined language = cpp
About to copy files to working directory: /tmp/tmpVxLqvb
Copying Student files...
... /tmp/tmpsHfsFt/linked_list.cpp
Copied Student files.
Copying Instructor files...
... linked_list.h
... description.json
... linked_list_test.cpp
... RetroPrinter.h
... Makefile
... RetroPrinter.cpp
Copied Instructor files.
Copy files successful
Invoking grade script
Changing directory to /tmp/tmpVxLqvb
... successfully changed directory.
Using description files: /home/gabe/grading-scripts/hw_1_linked_lists/description-common.json /home/gabe/grading-scripts/hw_1_linked_lists/cpp/description.json
... got assignment instance.
Invoking grade()...
Description File: /home/gabe/grading-scripts/hw_1_linked_lists/description-common.json
Description File: /home/gabe/grading-scripts/hw_1_linked_lists/cpp/description.json
Assignment: Linked Lists
Language: cpp
Points Possible: 15
Instructor file(s) in place.
Student file(s) in place.
Running Build command: make...
... return value: True
g++ -I/usr/local/gtest-1.6.0/include -g -Wall -Wextra -c ./linked_list.cpp
g++ -I/usr/local/gtest-1.6.0/include -g -Wall -Wextra -c ./linked_list_test.cpp
g++ -I/usr/local/gtest-1.6.0/include -g -Wall -Wextra -c ./RetroPrinter.cpp
g++ -I/usr/local/gtest-1.6.0/include -g -Wall -Wextra -pthread linked_list.o linked_list_test.o RetroPrinter.o /usr/local/gtest-1.6.0/make/gtest_main.a -o linked_list_test
Running Unit Test command: ./linked_list_test...
... return value: False
Segmentation fault
Parsing outfile...
Checking for ommitted tests
- WARNING: Tests performed were not the same as those prescribed.
- missing: Contains
- missing: Size
Completed unit test command.
result: {'Insert': (3, 3), 'InitNode': (1, 1), 'InsertData': (1, 1), 'Remove': (0, 3), 'Report': (2, 2), 'AppendData': (1, 1), 'Append': (2, 2)}
errors: FYI: should be 4, 30, 20, 10: 4 30 20 10
FYI: should be 4, 30, -8, 20, 10: 4 30 -8 20 10
FYI: should be 4, 30, -8, 20, 10, 99: 4 30 -8 20 10 99
FYI: should be 5, 7, 98, -34: 5 7 98 -34
FYI: should be 5, 7, 20, 98, -34: 5 7 20 98 -34
FYI: should be 5, 7, 20, 98, -34, 800: 5 7 20 98 -34 800
7 != 86
Failure at ./linked_list_test.cpp:198:
Value of: expect_all(vals2, 2, &top)
Actual: false
Expected: true
Done reporting result and errors.
FYI: should be 4, 30, 20, 10: 4 30 20 10
FYI: should be 4, 30, -8, 20, 10: 4 30 -8 20 10
FYI: should be 4, 30, -8, 20, 10, 99: 4 30 -8 20 10 99
FYI: should be 5, 7, 98, -34: 5 7 98 -34
FYI: should be 5, 7, 20, 98, -34: 5 7 20 98 -34
FYI: should be 5, 7, 20, 98, -34, 800: 5 7 20 98 -34 800
7 != 86
Failure at ./linked_list_test.cpp:198:
Value of: expect_all(vals2, 2, &top)
Actual: false
Expected: true
Output is in the file: /tmp/tmpVxLqvb/unit_test_output.txt
It gives the same message even when I comment out everything in the remove function (except the brackets so that the driver will run).
well,
*cursor
is anode
.but,
cursor
is anode*
cursor->next
is also anode*
There are a bunch of syntax errors in the above, so I assume you didn't paste in literally what you have.
At any rate, if
cursor
(the node pointer) is null, then callingcursor->next
will segfault.Paste in the RG output.