Skip to content

Commit

Permalink
code formats
Browse files Browse the repository at this point in the history
  • Loading branch information
nkaaf committed Oct 29, 2023
1 parent 7b12216 commit 7e6f728
Show file tree
Hide file tree
Showing 11 changed files with 694 additions and 792 deletions.
132 changes: 66 additions & 66 deletions src/AbstractList.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -316,72 +316,72 @@ class AbstractList {
*/
bool isEmpty() { return getSize() == 0; }

// /*!
// * @brief Get an array which represent the list.
// *
// * @note If this list is empty, a nullptr will be returned.
// * @note The memory for the array is dynamically allocated. the returned
// * pointer has to be free'd with free() in order to prevent memory leaks. For
// * further processing of the array, e.g. inserting new elements, the other
// * method toArray(T* arr) is preferred!
// * @note The array contains always immutable representations of the elements,
// * saved in the list.
// *
// * @return Array representation of the list or nullptr if the list is
// * empty.
// */
// T *toArray() {
// if (getSize() == 0) {
// return nullptr;
// }
//
// T *arr = static_cast<T *>(malloc(getSize() * sizeof(T)));
// this->toArray(arr);
//
// return arr;
// }
//
// /*!
// * @brief Fill the passed array with immutable objects.
// *
// * @note The array contains always immutable representations of the elements,
// * saved in the list.
// * @note Be sure, that the array has enough free space for all elements of the
// * list.
// *
// * @param arr Array to fill.
// */
// void toArray(T *arr) {
// for (int i = 0; i < getSize(); i++) {
// arr[i] = get(i);
// }
// }
//
// /*!
// * @brief Create the list from given array.
// * @note Removes all entries in current list.
// *
// * @param arr Array
// * @param arrSize Size of Array
// */
// void fromArray(T *arr, size_t arrSize) {
// this->clear();
// addAll(arr, arrSize);
// }

// /*!
// * @brief Sort the entries in the list with Quicksort.
// *
// * @param compFunc Comparator Method
// */
// void sort(int (*compFunc)(const void *, const void *)) {
// T *arr = this->toArray();
//
// qsort(arr, getSize(), sizeof(*arr), compFunc);
//
// this->fromArray(arr, getSize());
// free(arr);
// }
// /*!
// * @brief Get an array which represent the list.
// *
// * @note If this list is empty, a nullptr will be returned.
// * @note The memory for the array is dynamically allocated. the returned
// * pointer has to be free'd with free() in order to prevent memory leaks. For
// * further processing of the array, e.g. inserting new elements, the other
// * method toArray(T* arr) is preferred!
// * @note The array contains always immutable representations of the elements,
// * saved in the list.
// *
// * @return Array representation of the list or nullptr if the list is
// * empty.
// */
// T *toArray() {
// if (getSize() == 0) {
// return nullptr;
// }
//
// T *arr = static_cast<T *>(malloc(getSize() * sizeof(T)));
// this->toArray(arr);
//
// return arr;
// }
//
// /*!
// * @brief Fill the passed array with immutable objects.
// *
// * @note The array contains always immutable representations of the elements,
// * saved in the list.
// * @note Be sure, that the array has enough free space for all elements of the
// * list.
// *
// * @param arr Array to fill.
// */
// void toArray(T *arr) {
// for (int i = 0; i < getSize(); i++) {
// arr[i] = get(i);
// }
// }
//
// /*!
// * @brief Create the list from given array.
// * @note Removes all entries in current list.
// *
// * @param arr Array
// * @param arrSize Size of Array
// */
// void fromArray(T *arr, size_t arrSize) {
// this->clear();
// addAll(arr, arrSize);
// }

// /*!
// * @brief Sort the entries in the list with Quicksort.
// *
// * @param compFunc Comparator Method
// */
// void sort(int (*compFunc)(const void *, const void *)) {
// T *arr = this->toArray();
//
// qsort(arr, getSize(), sizeof(*arr), compFunc);
//
// this->fromArray(arr, getSize());
// free(arr);
// }

/*!
* @brief Compare two lists whether their attributes and entries are equal.
Expand Down
36 changes: 12 additions & 24 deletions test/test_immutable_+/test_immutable_+.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

// ---------- In different scope (ds) ---------- //

void add_ds_rvalue_primitive(void)
{
void add_ds_rvalue_primitive(void) {
List<int> list;

{
Expand All @@ -24,8 +23,7 @@ void add_ds_rvalue_primitive(void)
TEST_ASSERT_EQUAL_INT(2, list.getSize());
}

void add_ds_lvalue_primitive(void)
{
void add_ds_lvalue_primitive(void) {
List<int> list;

{
Expand All @@ -50,8 +48,7 @@ void add_ds_lvalue_primitive(void)
TEST_ASSERT_EQUAL_INT(2, list.getSize());
}

void add_ds_rvalue_class(void)
{
void add_ds_rvalue_class(void) {
List<String> list;

{
Expand All @@ -68,8 +65,7 @@ void add_ds_rvalue_class(void)
TEST_ASSERT_EQUAL_INT(2, list.getSize());
}

void add_ds_lvalue_class(void)
{
void add_ds_lvalue_class(void) {
List<String> list;

{
Expand All @@ -96,8 +92,7 @@ void add_ds_lvalue_class(void)

// ---------- In same scope (ss) ---------- //

void add_ss_rvalue_primitive(void)
{
void add_ss_rvalue_primitive(void) {
List<int> list;

list + 1;
Expand All @@ -110,8 +105,7 @@ void add_ss_rvalue_primitive(void)
TEST_ASSERT_EQUAL_INT(2, list.getSize());
}

void add_ss_lvalue_primitive(void)
{
void add_ss_lvalue_primitive(void) {
List<int> list;

int a = 1, b = 2;
Expand All @@ -132,8 +126,7 @@ void add_ss_lvalue_primitive(void)
TEST_ASSERT_EQUAL_INT(2, list.getSize());
}

void add_ss_rvalue_class(void)
{
void add_ss_rvalue_class(void) {
List<String> list;

list + "1";
Expand All @@ -146,8 +139,7 @@ void add_ss_rvalue_class(void)
TEST_ASSERT_EQUAL_INT(2, list.getSize());
}

void add_ss_lvalue_class(void)
{
void add_ss_lvalue_class(void) {
List<String> list;

String a = "1", b = "2";
Expand All @@ -170,8 +162,7 @@ void add_ss_lvalue_class(void)

// ---------- void operator+(AbstractList<T> &list) ---------- //

void addAll_primitive(void)
{
void addAll_primitive(void) {
List<int> fromList;
List<int> toList;

Expand Down Expand Up @@ -200,8 +191,7 @@ void addAll_primitive(void)
TEST_ASSERT_EQUAL_INT(6, toList.getSize());
}

void addAll_class(void)
{
void addAll_class(void) {
List<String> fromList;
List<String> toList;

Expand Down Expand Up @@ -230,8 +220,7 @@ void addAll_class(void)
TEST_ASSERT_EQUAL_INT(6, toList.getSize());
}

void setup()
{
void setup() {
UNITY_BEGIN();

// different scope tests
Expand All @@ -253,6 +242,5 @@ void setup()
UNITY_END();
}

void loop()
{
void loop() {
}
30 changes: 10 additions & 20 deletions test/test_immutable_add/test_immutable_add.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

// ---------- In different scope (ds) ---------- //

void add_ds_rvalue_primitive(void)
{
void add_ds_rvalue_primitive(void) {
List<int> list;

{
Expand All @@ -24,8 +23,7 @@ void add_ds_rvalue_primitive(void)
TEST_ASSERT_EQUAL_INT(2, list.getSize());
}

void add_ds_lvalue_primitive(void)
{
void add_ds_lvalue_primitive(void) {
List<int> list;

{
Expand All @@ -50,8 +48,7 @@ void add_ds_lvalue_primitive(void)
TEST_ASSERT_EQUAL_INT(2, list.getSize());
}

void add_ds_rvalue_class(void)
{
void add_ds_rvalue_class(void) {
List<String> list;

{
Expand All @@ -68,8 +65,7 @@ void add_ds_rvalue_class(void)
TEST_ASSERT_EQUAL_INT(2, list.getSize());
}

void add_ds_lvalue_class(void)
{
void add_ds_lvalue_class(void) {
List<String> list;

{
Expand All @@ -96,8 +92,7 @@ void add_ds_lvalue_class(void)

// ---------- In same scope (ss) ---------- //

void add_ss_rvalue_primitive(void)
{
void add_ss_rvalue_primitive(void) {
List<int> list;

list.add(1);
Expand All @@ -110,8 +105,7 @@ void add_ss_rvalue_primitive(void)
TEST_ASSERT_EQUAL_INT(2, list.getSize());
}

void add_ss_lvalue_primitive(void)
{
void add_ss_lvalue_primitive(void) {
List<int> list;

int a = 1, b = 2;
Expand All @@ -134,8 +128,7 @@ void add_ss_lvalue_primitive(void)
TEST_ASSERT_EQUAL_INT(2, list.getSize());
}

void add_ss_rvalue_class(void)
{
void add_ss_rvalue_class(void) {
List<String> list;

list.add("1");
Expand All @@ -148,8 +141,7 @@ void add_ss_rvalue_class(void)
TEST_ASSERT_EQUAL_INT(2, list.getSize());
}

void add_ss_lvalue_class(void)
{
void add_ss_lvalue_class(void) {
List<String> list;

String a = "1", b = "2";
Expand All @@ -170,8 +162,7 @@ void add_ss_lvalue_class(void)
TEST_ASSERT_EQUAL_INT(2, list.getSize());
}

void setup()
{
void setup() {
UNITY_BEGIN();

// different scope tests
Expand All @@ -189,6 +180,5 @@ void setup()
UNITY_END();
}

void loop()
{
void loop() {
}
Loading

0 comments on commit 7e6f728

Please sign in to comment.