ivanseidel / LinkedList

🔗 A fully implemented LinkedList made to work with general Microcontrollers and Arduino projects
MIT License
350 stars 118 forks source link

Install Instructions Are Incorrect #53

Closed Warren52 closed 2 years ago

Warren52 commented 3 years ago

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:

  1. Download the Latest release from gitHub.
  2. Unzip and modify the Folder name to "LinkedList" (Remove the '-version')
  3. Paste the modified folder on your Library folder (On your Libraries folder inside Sketchbooks or Arduino software). 3a. In the LinkedList Library folder, rename test.cpp to test.cpp_hidden
  4. Reopen the Arduino software.
jonathonball commented 2 years ago

I also encountered this issue. My solution was to delete test.cpp.

emergencyhamnet commented 2 years ago

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.

ivanseidel commented 2 years ago

This should be fixed in 1.3.3, can you verify?

Warren52 commented 2 years ago

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

// #include -- cannot use in an embedded world // #include -- using Serial.print...

void GivenNothingInList_WhenSizeCalled_Returns0() { //Arrange LinkedList list = LinkedList();

//Act Assert
Serial.print("list.size() == 0): ");
Serial.println(list.size() == 0);

}

void GivenNothingInList_WhenAddNodeAtPlace0_ReturnsTrue() { //Arrange LinkedList list = LinkedList();

//Act Assert
Serial.print("list.add(0, 1) == true): ");
Serial.println(list.add(0, 1) == true);

}

void GivenOneNodeInList_WhenAddNodeIndexLargerThanListSize_ThenNodeAddedToEndOfList() { //Arrange LinkedList list = LinkedList(); list.add(1);

//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 list = LinkedList(); list.add(1); list.add(2); list.add(3);

//Act Assert
Serial.print("list.size() == 3): ");
Serial.println(list.size() == 3);

}

void GivenNothingInList_WhenUnshiftCalled_ThenListSize1() { //Arrange LinkedList list = LinkedList();

//Act
list.unshift(1);

//Assert
Serial.print("list.size() == 1): ");
Serial.println(list.size() == 1);

}

void GivenOneNodeInList_WhenUnshiftCalled_ThenListSize2() { //Arrange LinkedList list = LinkedList(); list.add(1);

//Act
list.unshift(2);

//Assert
Serial.print("list.size() == 2): ");
Serial.println(list.size() == 2);

}

void GivenOneNodeInList_WhenUnshiftCalled_ThenExistingNodeLast() { //Arrange LinkedList list = LinkedList(); list.add(1);

//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 list = 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 list = LinkedList(); list.add(0); list.add(1); list.add(2);

//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 list = LinkedList();

//Act Assert
Serial.print("list.pop() == false): ");
Serial.println(list.pop() == false);

}

void GivenTwoNodesInList_WhenPopIsCalled_ThenReturnsLastNode() { //Arrange LinkedList list = LinkedList(); list.add(0); list.add(1);

//Act Assert
Serial.print("list.pop() == 1): ");
Serial.println(list.pop() == 1);

}

void GivenTwoNodesInList_WhenPopIsCalled_ThenListIsShorter() { //Arrange LinkedList list = LinkedList(); list.add(0); list.add(1);

//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 list = LinkedList();

//Act Assert
Serial.print("list.shift() == false): ");
Serial.println(list.shift() == false);

}

void GivenOneNodeInList_WhenShiftIsCalled_ThenReturnsData() { //Arrange LinkedList list = LinkedList(); list.add(5);

//Act Assert
Serial.print("list.shift() == 5): ");
Serial.println(list.shift() == 5);

}

void GivenOneNodeInList_WhenShiftIsCalled_ThenListEmpty() { //Arrange LinkedList list = LinkedList(); list.add(5);

//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 list = LinkedList(); list.add(0); list.add(1); list.add(2);

//Act Assert
Serial.print("list.shift() == 0): ");
Serial.println(list.shift() == 0);

}

void GivenThreeNodesInList_WhenShiftIsCalled_ThenListIsShorter() { //Arrange LinkedList list = LinkedList(); list.add(0); list.add(1); list.add(2);

//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 list = LinkedList();

//Act Assert
Serial.print("list.remove(0) == false): ");
Serial.println(list.remove(0) == false);

}

void GivenThreeNodesInList_WhenRemoveIsCalledAtPlace0_ThenFirstNodeDataIsReturned() { //Arrange LinkedList list = LinkedList(); list.add(0); list.add(1); list.add(2);

//Act Assert
Serial.print("list.remove(0) == 0): ");
Serial.println(list.remove(0) == 0);

}

void GivenThreeNodesInList_WhenRemoveIsCalledAtPlace2_ThenLastNodeDataIsReturned() { //Arrange LinkedList list = LinkedList(); list.add(0); list.add(1); list.add(2);

//Act Assert
Serial.print("list.remove(2) == 2): ");
Serial.println(list.remove(2) == 2);

}

void GivenThreeNodesInList_WhenRemoveIsCalled_ThenListIsShorter() { //Arrange LinkedList list = LinkedList(); list.add(0); list.add(1); list.add(2);

//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 list = LinkedList();

//Act Assert
Serial.print("list.get(0) == false): ");
Serial.println(list.get(0) == false);

}

void GivenThreeNodesInList_WhenGetIsCalled_ThenReturnsData() { //Arrange LinkedList list = LinkedList(); list.add(0); list.add(1); list.add(2);

//Act Assert
Serial.print("list.get(1) == 1): ");
Serial.println(list.get(1) == 1);

}

void GivenNothingInList_WhenClearIsCalled_ThenSizeUnchanged() { //Arrange LinkedList list = 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 list = LinkedList(); list.add(0); list.add(1); list.add(2);

//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++; }