Test cases for a Singly Linked list
Asked Answered
M

2

6

What are some good testcases for a Linked list problem in general? for example test cases for a function which finds and eliminates duplicates and returns the pointer to the first node. Some core cases could be: the function is in c# or Java and not c, c++. Assume all positive integers as nodes of the list.

  • Null
  • Empty List
  • Linked list with a loop
  • List with all dups
  • List with one node or 2 nodes (2 dups)
  • No duplicates
  • The list could encounter integer over flow, incase low memory (depending on 32 bit machine, 64 bit machine)
  • Security testing, language automation, memory issues, performance and stress

What else? expecting outrageous test cases..any experts out there?

Margravine answered 25/3, 2011 at 19:22 Comment(1)
Since you mentioned that last bullet about Security, Automation, etc, can you tell us more about the context?Alburga
A
6

How about these?

  • traversing the list
  • edge cases:
    • traversing an empty list
    • traversing list where 1+ stored values are NULL
  • operations (if applicable):
    • deleting from the list
    • inserting into the list
    • inserting a sub-list into the linked list
    • traversing the list backwards (if doubly-linked list)
  • concurrency tests (if applicable):
    • race condition tests
Alburga answered 25/3, 2011 at 19:27 Comment(1)
i would also test for lists with one or two nodes as most algos are usually of flavors like saving the next->next and deleting next and son on.Isabeau
M
4
  • Security -> what level of permission is required to use the API, roles etc
  • Memory - > How much memory is consumed when this API is used; Does it affect performance?
  • Compatibility testing - > testing the suite using this API on different platforms, windows, MAC, Unix etc.
  • Stress testing -> Invoke the API by using a master slave architecture and parallel processing on different clients.
  • UI-> If the API has a UI, UI test cases come into picture like usability testing
Margravine answered 25/3, 2011 at 20:26 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.