I am sorry about this but this really confuses me for some reason. I am just trying to do statement coverage for a header file that I am including in my cpp file. This header file contains various functions used to do different things to the linked list. I am really stuck on this and I'm sure it's a simple thing. Here is the header file that contains all the functions I need to use for my statement coverage:
Code:
template <typename Data>
struct LListNode
{
Data data;
LListNode<Data>* next;
LListNode() {next = 0;}
LListNode (const Data& d, LListNode<Data>* nxt = 0)
: data(d), next(nxt)
{}
};
template <typename Data>
struct LListHeader {
LListNode<Data>* first;
LListHeader();
void addToFront (const Data& value);
void addToEnd (const Data& value);
// Add value after the indicated position
void addAfter (LListNode<Data>* afterThis, const Data& value);
// Add value before the indicated position
void addBefore (LListNode<Data>* beforeThis, const Data& value);
// Add value in sorted order.
//Pre: all existing values are already ordered
void addInOrder (const Data& value);
// Remove value at the indicated position
void remove (LListNode<Data>* here);
// Add value after the indicated position
void removeAfter (LListNode<Data>* afterThis);
// Search for a value. Returns null if not found
LListNode<Data>* find (const Data& value) const;
// Search an ordered list for a value. Returns null if not found
LListNode<Data>* findOrdered (const Data& value) const;
// Empty the list
void clear();
// Append another list onto the end of this one
void append (const LListHeader<Data>& list);
};
Also, here is my attempt at making a cpp file run all the functions:
Code:
#include <iostream>
#include <string>
#include <sstream>
#include <fstream>
#include <cstdlib>
#include "sflistUtils.h"
using namespace std;
// Unit test driver for Singly Linked Lists
int main(int argc, char** argv)
{
string line;
getline(cin, line);
while(cin)
{
istringstream in (line);
cout << line << endl;
string toSearchFor;
in >> toSearchFor;
string LListNode(line);
addToFront(toSearchFor);
getline(cin, line);
}
return 0;
}
I know I just attempted at addToFront but I can't get it to work!
Thanks for the help guys!