• Abstract Data Types

    • A collection of data and operations on that data.
    • What the operations do is understood, but how they get the job done is left to the coder.
    • For example, consider a Set ADT that models a mathematical set.
      • Data: a unique collection of items of the same type
      • Operations:
        • add(some_item): bool - attempt to add some_item to the set. If it is already present, don’t duplicate it in the set. Returns true if item was successfully added or false if it is a duplicate.
        • remove(some_item): bool - remove some_item from the set if it is present. Returns true if the item was successfully removed and false otherwise.
        • clear(): void - remove all items from the set
        • find(some_item): bool- returns true if some_item is found inside the set.
      • NOTE: this is not an exhaustive list of operations… just for example purposes.
  • Class Templates allow us to write code that will work for multiple data types.

    //A DSSet contains a unique collection of items.
    //Attempting to add an element that already exists in the set doesn't
    //cause a duplicate to be created.
    
    template <typename T>
    class DSSet {
    private:
    	T* items;
    	int cap;
    	int size;
    public:
    	//...
    
    };
    
    //To instantiate a DSSet object:
    DSSet<int> set_of_integers;
    DSSet<float> set_of_floats;
    
    //Assume we had a class Person already declared
    class Person {...};
    DSSet<Person> set_of_persons; 
    
  • DSVector<T>

    • DSVector is a List Abstract Data Type (ADT) implemented using an array.
    • Should mimic std::vector<T>
    • pushBack(…)
    • resize()
    • Catch 2 tests for each function should be created
    • Make sure to test containers with primitive types as well as complex types like DSStrings and/or other vectors.
  • Adding multiple targets in the CMakeList.txt file to support Testing

    • every add_executable(...) generates a different executable file.
    • the first arg to add_executable(...) will be the name of the executable
    • If you add a new executable statement in the CMakeLists.txt file and reload the cmake project, the executable options will show up in the Configurations dropdown (between the 🔨 and ▶️ buttons in the top right of the CLion window).
    • Suggestion:
      • make one target for the project proper that includes compiling your main driver and all other classes needed, but DON”T INCLUDE the catch file and tests.
      • make another target for testing that includes catch.hpp and your testing files (such as sample_tests.cpp). You also need to include each class (.h and .cpp) for any classes that are being tested.
    • Understanding basics of writing unit tests With Catch2
  • Extra help with Catch:

    • Catch 2 Framework Github Repo > here <
    • Catch 2 - Tutorial
    • Catch 2 - Reference Section