Closed Warren52 closed 2 years ago
I also encountered this issue. My solution was to delete test.cpp.
Good help, I had same issue would not compile. missing correct file. I deleted the file test.cpp from the LinkedList library and all seems well now.
This should be fixed in 1.3.3, can you verify?
Sorry for the delay - was involved with another project. Installed 1.3.3 and created a LinkedList.ino file from your Test.cpp. Built it and programmed a Teensy 3.2. All tests passed and did not have to change any file names or anything. Nice job - thanks!
FYI - If you want, my LinkedList.ino code follows:
// -------------------------------------------------------------------------- // // Title: // LinkedList.ino - LinkedList Test.cpp turned into an .ino file // // Purpose: // I had entered a LinkedList github issue: "Install Instructions Are // Incorrect". The maintainer got back to me with an updated version // of LinkedList (1.3.3). I thought I would make sure everything worked // and copied his Test.cpp it to this file, renamed it, modified some // conntent, programmed a Teensy 3.2, then ran it. All worked well. // // // History: // ddmmmyyyy Author Description // --------- ------- ----------- // 04apr2022 W. Holt // Initial creation from LinkedList Test.cpp // When this was compiled and run on a Teensy 3.2, all tests passed // // // --------------------------------------------------------------------------
// ------- includes
// #include
void GivenNothingInList_WhenSizeCalled_Returns0()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.size() == 0): ");
Serial.println(list.size() == 0);
}
void GivenNothingInList_WhenAddNodeAtPlace0_ReturnsTrue()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.add(0, 1) == true): ");
Serial.println(list.add(0, 1) == true);
}
void GivenOneNodeInList_WhenAddNodeIndexLargerThanListSize_ThenNodeAddedToEndOfList()
{
//Arrange
LinkedList
//Act
list.add(5, 2);
list.add(4, 3);
//Assert
Serial.print("list.get(0) == 1): ");
Serial.println(list.get(0) == 1);
Serial.print("list.get(1) == 2): ");
Serial.println(list.get(1) == 2);
Serial.print("list.get(2) == 3): ");
Serial.println(list.get(2) == 3);
}
void GivenThreeNodesInList_WhenSizeCalled_Returns3()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.size() == 3): ");
Serial.println(list.size() == 3);
}
void GivenNothingInList_WhenUnshiftCalled_ThenListSize1()
{
//Arrange
LinkedList
//Act
list.unshift(1);
//Assert
Serial.print("list.size() == 1): ");
Serial.println(list.size() == 1);
}
void GivenOneNodeInList_WhenUnshiftCalled_ThenListSize2()
{
//Arrange
LinkedList
//Act
list.unshift(2);
//Assert
Serial.print("list.size() == 2): ");
Serial.println(list.size() == 2);
}
void GivenOneNodeInList_WhenUnshiftCalled_ThenExistingNodeLast()
{
//Arrange
LinkedList
//Act
list.unshift(2);
//Assert
Serial.print("list.get(0) == 2): ");
Serial.println(list.get(0) == 2);
Serial.print("list.get(1) == 1): ");
Serial.println(list.get(1) == 1);
}
void GivenNothingInList_WhenSetIsCalled_ThenReturnsFalse()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.set(-1, 1) == false): ");
Serial.println(list.set(-1, 1) == false);
Serial.print("list.set(0, 1) == false): ");
Serial.println(list.set(0, 1) == false);
Serial.print("list.set(1, 1) == false): ");
Serial.println(list.set(1, 1) == false);
}
void GivenThreeNodesInList_WhenSetIsCalledAtPlace1_ThenSecondNodeIsSet()
{
//Arrange
LinkedList
//Act
list.set(1, 10);
//Assert
Serial.print("list.get(0) == 0): ");
Serial.println(list.get(0) == 0);
Serial.print("list.get(1) == 10): ");
Serial.println(list.get(1) == 10);
Serial.print("list.get(2) == 2): ");
Serial.println(list.get(2) == 2);
}
void GivenNothingInList_WhenPopIsCalled_ThenReturnsFalse()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.pop() == false): ");
Serial.println(list.pop() == false);
}
void GivenTwoNodesInList_WhenPopIsCalled_ThenReturnsLastNode()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.pop() == 1): ");
Serial.println(list.pop() == 1);
}
void GivenTwoNodesInList_WhenPopIsCalled_ThenListIsShorter()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.size() == 2): ");
Serial.println(list.size() == 2);
list.pop();
Serial.print("list.size() == 1): ");
Serial.println(list.size() == 1);
}
void GivenNothingInList_WhenShiftIsCalled_ThenReturnsFalse()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.shift() == false): ");
Serial.println(list.shift() == false);
}
void GivenOneNodeInList_WhenShiftIsCalled_ThenReturnsData()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.shift() == 5): ");
Serial.println(list.shift() == 5);
}
void GivenOneNodeInList_WhenShiftIsCalled_ThenListEmpty()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.size() == 1): ");
Serial.println(list.size() == 1);
list.shift();
Serial.print("list.size() == 0): ");
Serial.println(list.size() == 0);
}
void GivenThreeNodesInList_WhenShiftIsCalled_ThenReturnsFirstData()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.shift() == 0): ");
Serial.println(list.shift() == 0);
}
void GivenThreeNodesInList_WhenShiftIsCalled_ThenListIsShorter()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.size() == 3): ");
Serial.println(list.size() == 3);
list.shift();
Serial.print("list.size() == 2): ");
Serial.println(list.size() == 2);
}
void GivenNothingInList_WhenRemoveIsCalled_ThenFalseIsReturned()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.remove(0) == false): ");
Serial.println(list.remove(0) == false);
}
void GivenThreeNodesInList_WhenRemoveIsCalledAtPlace0_ThenFirstNodeDataIsReturned()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.remove(0) == 0): ");
Serial.println(list.remove(0) == 0);
}
void GivenThreeNodesInList_WhenRemoveIsCalledAtPlace2_ThenLastNodeDataIsReturned()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.remove(2) == 2): ");
Serial.println(list.remove(2) == 2);
}
void GivenThreeNodesInList_WhenRemoveIsCalled_ThenListIsShorter()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.size() == 3): ");
Serial.println(list.size() == 3);
list.remove(1);
Serial.print("list.size() == 2): ");
Serial.println(list.size() == 2);
}
void GivenNothingInList_WhenGetIsCalled_ThenReturnsFalse()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.get(0) == false): ");
Serial.println(list.get(0) == false);
}
void GivenThreeNodesInList_WhenGetIsCalled_ThenReturnsData()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.get(1) == 1): ");
Serial.println(list.get(1) == 1);
}
void GivenNothingInList_WhenClearIsCalled_ThenSizeUnchanged()
{
//Arrange
LinkedList
//Act Assert
Serial.print("list.size() == 0): ");
Serial.println(list.size() == 0);
list.clear();
Serial.print("list.size() == 0): ");
Serial.println(list.size() == 0);
}
void GivenThreeInList_WhenClearIsCalled_ThenListEmpty()
{
//Arrange
LinkedList
//Act
list.clear();
//Assert
Serial.print("list.size() == 0): ");
Serial.println(list.size() == 0);
}
// -------------------------------------------------------------------------- // // Function: setup() // // -------------------------------------------------------------------------- void setup() { // ------- inits pinMode(LED_BUILTIN, OUTPUT); Serial.begin(9600); }
// -------------------------------------------------------------------------- // // Function: setup() // // -------------------------------------------------------------------------- void loop() { // ------- variables static int ndx = 0;
// ------- delay, led on, do switch delay(500); digitalWrite(LED_BUILTIN, HIGH); switch(ndx) { case 0: GivenNothingInList_WhenSizeCalled_Returns0(); break; case 1: GivenNothingInList_WhenAddNodeAtPlace0_ReturnsTrue(); break; case 2: GivenOneNodeInList_WhenAddNodeIndexLargerThanListSize_ThenNodeAddedToEndOfList(); break; case 3: GivenThreeNodesInList_WhenSizeCalled_Returns3(); break; case 4: GivenNothingInList_WhenUnshiftCalled_ThenListSize1(); break; case 5: GivenOneNodeInList_WhenUnshiftCalled_ThenListSize2(); break; case 6: GivenOneNodeInList_WhenUnshiftCalled_ThenExistingNodeLast(); break; case 7: GivenNothingInList_WhenSetIsCalled_ThenReturnsFalse(); break; case 8: GivenThreeNodesInList_WhenSetIsCalledAtPlace1_ThenSecondNodeIsSet(); break; case 9: GivenNothingInList_WhenPopIsCalled_ThenReturnsFalse(); break; case 10: GivenTwoNodesInList_WhenPopIsCalled_ThenReturnsLastNode(); break; case 11: GivenTwoNodesInList_WhenPopIsCalled_ThenListIsShorter(); break; case 12: GivenNothingInList_WhenShiftIsCalled_ThenReturnsFalse(); break; case 13: GivenOneNodeInList_WhenShiftIsCalled_ThenReturnsData(); break; case 14: GivenOneNodeInList_WhenShiftIsCalled_ThenListEmpty(); break; case 15: GivenThreeNodesInList_WhenShiftIsCalled_ThenReturnsFirstData(); break; case 16: GivenThreeNodesInList_WhenShiftIsCalled_ThenListIsShorter(); break; case 17: GivenNothingInList_WhenRemoveIsCalled_ThenFalseIsReturned(); break; case 18: GivenThreeNodesInList_WhenRemoveIsCalledAtPlace0_ThenFirstNodeDataIsReturned(); break; case 19: GivenThreeNodesInList_WhenRemoveIsCalledAtPlace2_ThenLastNodeDataIsReturned(); break; case 20: GivenThreeNodesInList_WhenRemoveIsCalled_ThenListIsShorter(); break; case 21: GivenNothingInList_WhenGetIsCalled_ThenReturnsFalse(); break; case 22: GivenThreeNodesInList_WhenGetIsCalled_ThenReturnsData(); break; case 23: GivenNothingInList_WhenClearIsCalled_ThenSizeUnchanged(); break; case 24: GivenThreeInList_WhenClearIsCalled_ThenListEmpty(); break; default: if(ndx > 25) ndx = 25; break; }
// ------- delay, led off, update ndx delay(200); digitalWrite(LED_BUILTIN,LOW); ndx++; }
The current install instructions need to have an additional step included when used with Arduino (at least 1.8.13). Without this step, the test.cpp file will be included when compiling a script that includes LinkedList. The result will be a second "main()" function, from test.cpp, included in the compile which will override the correct "main()" function for the chosen board / MCU. This means the normal "setup()" and "loop()" functions will NOT run making it appear like LinkedList has trashed the program or the program cannot work.
The solution is quite simple. After the third step of pasting the modified folder to the Library folder, add:
3a - In the LinkedList Library folder, rename test.cpp to test.cpp_hidden
So the resulting steps are: