Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Test cases for a Singly Linked list

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?

like image 201
RashMans Avatar asked Mar 25 '11 19:03

RashMans


1 Answers

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
like image 184
rlb.usa Avatar answered Sep 18 '22 11:09

rlb.usa