Commit 2a44e5e8 authored by Matthew P. Russell's avatar Matthew P. Russell
Browse files

Update ArrayList_tests.cpp

parent 3d42f417
/*
ArraryList_tests.cpp
matt russell
comp15 2020 summer
This file demonstrates a few tests you might run on an ArrayList class.
The format followed below will work correctly with the COMP15 autograding framework.
Rules:
All tests must return void, and have no arguments
If a test finishes execution, it is considered successful.
Use assert(boolean_condition) to test for a known condition.
If the condition evaluates to false, then the assertion fails, the test will fail.
You should #include any .h files (as in #include "ArrayList.h" below) as necessary
You may have multiple _tests.cpp files, but each test must have a unique name
Note that valgrind will be run automatically on all tests, so even tests that seem to do
nothing (i.e. constructor_0) can still be quite useful.
You are encouraged to write MANY, MANY tests!!!
Furthermore, you are encouraged to write tests immediately after writing a function.
So, write a function, then write test cases for it, and run the test cases, and so on.
*****It is usually wise to debug BEFORE moving on to writing the next function.*****
NB: The ArrayList code has bugs, so the tests will fail first on purpose!
* ArraryList_tests.cpp
* Matt Russell
* 1/6/2021
* This file demonstrates test style for the unit_test unit testing framework.
*
* Rules for unit tests:
* All test file names must end with the string "_tests.cpp"
* All test functions must take no arguments
* All test functions must return void
*
* Background info for tests:
* If a test finishes execution, it is considered successful.
* Use assert(boolean_expression) to test for known conditions.
* If the expression evaluates to false, then the assertion fails.
* Tests will also fail on segfaults, etc.
*
* Other notes:
* Be sure to #include any .h files as necessary
* You may have multiple testing files, but all tests must have unique names
* Valgrind will be run automatically on all tests
*
* Workflow encouragements:
* You are encouraged to write MANY, MANY tests!!!
* Furthermore, you are encouraged to write and run tests as you work.
* So, the workflow should be something along the lines of:
* 1) Write a function (or part of a function)
* 2) Write at least 1 test for the code you just wrote
* 3) Run the tests, and fix all errors (including memory issues)
* 4) Repeat!
* *** It is wise to debug BEFORE moving on to writing the next function. ***
*
* NB: The ArrayList code has bugs, so the tests will fail first on purpose!
* Be sure to ask questions on piazza, or come to office hours!
*/
#include <cassert>
#include "ArrayList.h"
/*
* constructor test 0 - make sure no fatal errors/memory leaks in the default constructor
* constructor test 0
* Make sure no fatal errors/memory leaks in the default constructor
*/
void constructor_0() {
ArrayList list = ArrayList();
}
/*
* constructor test 1 - make sure no items exist in the list upon construction
* note: given the provided code, this test should fail.
* constructor test 1
* Make sure no items exist in the list upon construction
* Note: given the provided code, this test should fail.
*/
void constructor_1() {
ArrayList list = ArrayList();
......@@ -55,8 +56,9 @@ void constructor_1() {
}
/*
* destructor test (destructor called implicitly)
* make sure no fatal errors/memory leaks in the destructor (based on default constructor)
* destructor test
* Destructor called implicitly
* Make sure no fatal errors/memory leaks in the destructor
*/
void destructor() {
ArrayList list = ArrayList();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment