mirror of
https://github.com/theoludwig/libcproject.git
synced 2025-05-21 23:21:15 +02:00
feat: add mathematics_max
, mathematics_min
Also add `mathematics_max_values` and `mathematics_min_values` to check in array.
This commit is contained in:
@@ -6,6 +6,11 @@ void mathematics_test() {
|
||||
mathematics_root_test();
|
||||
mathematics_square_root_test();
|
||||
mathematics_factorial_test();
|
||||
mathematics_opposite_test();
|
||||
mathematics_max_test();
|
||||
mathematics_max_values_test();
|
||||
mathematics_min_test();
|
||||
mathematics_min_values_test();
|
||||
}
|
||||
|
||||
void mathematics_absolute_value_test() {
|
||||
@@ -56,3 +61,38 @@ void mathematics_factorial_test() {
|
||||
assert(mathematics_factorial(9) == 362880);
|
||||
assert(mathematics_factorial(10) == 3628800);
|
||||
}
|
||||
|
||||
void mathematics_opposite_test() {
|
||||
assert(mathematics_opposite(-7) == 7);
|
||||
assert(mathematics_opposite(7) == -7);
|
||||
}
|
||||
|
||||
void mathematics_max_test() {
|
||||
assert(mathematics_max(0, 0) == 0);
|
||||
assert(mathematics_max(0, 1) == 1);
|
||||
assert(mathematics_max(2, 0) == 2);
|
||||
assert(mathematics_max(54, 37) == 54);
|
||||
}
|
||||
|
||||
void mathematics_max_values_test() {
|
||||
int64_t values[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
assert(mathematics_max_values(values, 10) == 9);
|
||||
|
||||
int64_t values2[] = {8, 6, 4, 7};
|
||||
assert(mathematics_max_values(values2, 4) == 8);
|
||||
}
|
||||
|
||||
void mathematics_min_test() {
|
||||
assert(mathematics_min(0, 0) == 0);
|
||||
assert(mathematics_min(3, 5) == 3);
|
||||
assert(mathematics_min(2, 1) == 1);
|
||||
assert(mathematics_min(54, 37) == 37);
|
||||
}
|
||||
|
||||
void mathematics_min_values_test() {
|
||||
int64_t values[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
|
||||
assert(mathematics_min_values(values, 10) == 0);
|
||||
|
||||
int64_t values2[] = {9, 6, 8, 7};
|
||||
assert(mathematics_min_values(values2, 4) == 6);
|
||||
}
|
||||
|
@@ -17,4 +17,14 @@ void mathematics_square_root_test();
|
||||
|
||||
void mathematics_factorial_test();
|
||||
|
||||
void mathematics_opposite_test();
|
||||
|
||||
void mathematics_max_test();
|
||||
|
||||
void mathematics_max_values_test();
|
||||
|
||||
void mathematics_min_test();
|
||||
|
||||
void mathematics_min_values_test();
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user