makeopensource / mOS

MakeOpenSource Operating System
GNU General Public License v3.0
4 stars 8 forks source link

Type-agnostic sorting (insertion sort) #52

Closed emilkovacev closed 1 year ago

emilkovacev commented 1 year ago

Description

I added insertion sort into stdlib (and made stdlib a common library for all c files to access). I also included thorough tests that demonstrate the type-agnostic approach (which C uses to implement qsort and heapsort). This function is useful in the issue #30 (Mallocation) because a small number of structures need to be sorted in-place.

Type of change

Testing

I created tests for sorting arrays of integers, and custom type Type which includes an int, float, and char. These two types of arrays have their own compar function which compares two elements and returns an int of -1, 0, 1 indicating the intended order. The test then sorts the arrays, and checks that the corresponding array follows the compar function ordering, and has the same elements as is expected.

Test Configuration:

Checklist: