From 8fcae449cc6740834c5111633b4f17dd2898a7a6 Mon Sep 17 00:00:00 2001 From: Leon Wolf Date: Fri, 9 Feb 2024 12:24:41 +0100 Subject: [PATCH 01/18] refactoring: changed descriptions for 3 subtraction function --- src/arithmeticSubtraction.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/arithmeticSubtraction.c b/src/arithmeticSubtraction.c index bbabad9..339431b 100644 --- a/src/arithmeticSubtraction.c +++ b/src/arithmeticSubtraction.c @@ -2,21 +2,21 @@ #include -// arithmetic subtraction integer +// arithmetic subtraction for integer int* subtraction_integer(int a, int b) { int* result= malloc(sizeof (int)); *result=a - b; return result; } -// arithmetic subtraction float +// arithmetic subtraction for float float* subtraction_float(float a, float b) { float* result= malloc(sizeof (float)); *result=a - b; return result; } -// arithmetic subtraction double +// arithmetic subtraction for double double* subtraction_double(double a, double b) { double* result= malloc(sizeof (double)); *result=a - b; From 0609ed4765a882a509418b3d783282e3c75cb1dc Mon Sep 17 00:00:00 2001 From: Leon Wolf Date: Fri, 9 Feb 2024 12:31:04 +0100 Subject: [PATCH 02/18] refactoring: changed description mistake for kilometers --- src/convert_M_in_KM.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/convert_M_in_KM.c b/src/convert_M_in_KM.c index bf56016..4237094 100644 --- a/src/convert_M_in_KM.c +++ b/src/convert_M_in_KM.c @@ -1,6 +1,6 @@ #include "convert_M_in_KM.h" -// convert length for double metre into kilometre +// convert length for double metre into kilometers double meter_to_kilometer(double meter) { return meter / 1000.0; } From 20631017c988a60137353b20d7072cf0e38f507d Mon Sep 17 00:00:00 2001 From: Leon Wolf Date: Fri, 9 Feb 2024 12:44:52 +0100 Subject: [PATCH 03/18] Updated specification and gap at 3 trigonometric function --- src/trigonometricFunctions.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/trigonometricFunctions.c b/src/trigonometricFunctions.c index 6dbdfaf..db262a0 100644 --- a/src/trigonometricFunctions.c +++ b/src/trigonometricFunctions.c @@ -4,21 +4,19 @@ #include #include //function for trigonometric -//Function 1 double +//Function 1 for double double* calculate_sin_double(double angle) { double* result= malloc(sizeof (double)); *result=sin(angle); return result; } -//Function 2 double - +//Function 2 for double double* calculate_cos_double(double angle) { double* result= malloc(sizeof (double)); *result=cos(angle); return result; } -//Function 3 double - +//Function 3 for double double* calculate_tan_double(double angle) { double* result= malloc(sizeof (double)); *result=tan(angle); From 93bd716e6d6c1b7a180797039a9797155b3a1c2b Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Fri, 9 Feb 2024 16:09:57 +0100 Subject: [PATCH 04/18] Added multiple tests for arithmetic addition methods --- test/test_arithmeticAddition.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/test/test_arithmeticAddition.c b/test/test_arithmeticAddition.c index a7089a6..5e261b2 100644 --- a/test/test_arithmeticAddition.c +++ b/test/test_arithmeticAddition.c @@ -21,4 +21,25 @@ void test_arithmeticAddition_numberplusmaxintegervalueequalsnull(void) { int* result; result = addition_integer(INT_MAX, 1); TEST_ASSERT_NULL(result); -} \ No newline at end of file +} + +void test_arithmeticAddition_doublenumbercalculationequalscorrectdoublenumber(void) { + double expectedResult = 5.500000; + double* result; + result = addition_double(3.5, 2.0); + TEST_ASSERT_EQUAL_DOUBLE(expectedResult, *result); +} + +void test_arithmeticAddition_longnumbercalculationequalscorrectlong(void) { + long expectedResult = 10; + long* result; + result = addition_long(5, 5); + TEST_ASSERT_EQUAL_INT(expectedResult, *result); +} + +void test_arithmeticAddition_floatnumbercalculationequalsfloat(void) { + float expectedResult = 5.5; + float* result; + result = addition_float(3.5, 2.0); + TEST_ASSERT_EQUAL_FLOAT(expectedResult, *result); +} From 057982d1fb4c70735c8b510423799d066320e2f2 Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Fri, 9 Feb 2024 16:13:49 +0100 Subject: [PATCH 05/18] Added more tests for division methods with different datatypes --- test/test_arithmeticDivision.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/test_arithmeticDivision.c b/test/test_arithmeticDivision.c index 6428ea0..0ae60eb 100644 --- a/test/test_arithmeticDivision.c +++ b/test/test_arithmeticDivision.c @@ -17,3 +17,24 @@ void test_arithmeticDivision_numberdividedbynumberequalsnumber(void) { result = division_integer(14, 7); TEST_ASSERT_EQUAL_INT(expectedResult, *result); } + +void test_arithmeticDivision_longdividedbylongequalscorrectlong(void) { + long expectedResult = 5; + long* result; + result = division_long(10, 2); + TEST_ASSERT_EQUAL_INT(expectedResult, *result); +} + +void test_arithmeticDivsion_floatdividedbyfloatequalscorrectfloat(void) { + float expectedResult = 5.0; + float* result; + result = division_float(10.0, 2.0); + TEST_ASSERT_EQUAL_FLOAT(expectedResult, *result); +} + +void test_arithmeticDivision_doubledividedbydoublequalscorrectdouble(void) { + double expectedResult = 5.0; + double* result; + result = division_double(10.0, 2.0); + TEST_ASSERT_EQUAL_DOUBLE(expectedResult, *result); +} From f212040c96b85e88490736028946aa1c49263d37 Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Fri, 9 Feb 2024 16:18:24 +0100 Subject: [PATCH 06/18] Implemented unittest for input handler method --- test/test_inputHandler.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 test/test_inputHandler.c diff --git a/test/test_inputHandler.c b/test/test_inputHandler.c new file mode 100644 index 0000000..5cf92c7 --- /dev/null +++ b/test/test_inputHandler.c @@ -0,0 +1,18 @@ +#include "../src/inputHandler.h" +#include "unity.h" + +void setUp(void) { + // set stuff up here +} + +void tearDown(void) { + // clean stuff up here +} + + +void test_inputHandler_returntwoforinputminus(void) { + int expectedResult = 2; + int result; + result = getOperationIdBySymbol('-'); + TEST_ASSERT_EQUAL_INT(expectedResult, result); +} \ No newline at end of file From 6c33f586e6b52fc0394774c78171fa4b6985ee48 Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Fri, 9 Feb 2024 16:24:43 +0100 Subject: [PATCH 07/18] refactoring: implemented descriptions for methods in arithmetic addition --- src/arithmeticAddition.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/arithmeticAddition.c b/src/arithmeticAddition.c index 173c438..46a2e37 100644 --- a/src/arithmeticAddition.c +++ b/src/arithmeticAddition.c @@ -3,6 +3,7 @@ #include #include +// addition for two integer inputs (no decimal number) int* addition_integer(int num1, int num2) { if ((num2 > 0 && num1 > INT_MAX - num2) || (num2 < 0 && num1 < INT_MIN - num2)) { return NULL; @@ -12,18 +13,21 @@ int* addition_integer(int num1, int num2) { return result; } +// addition for two double inputs (decimal number) double* addition_double(double num1, double num2) { double* result = malloc(sizeof(double)); *result = num1+num2; return result; } +// addition for two float inputs (decimal number) float* addition_float(float num1, float num2) { float* result = malloc(sizeof(float)); *result = num1+num2; return result; } +// addition for two long inputs (no decimal number) long* addition_long(long num1, long num2) { long* result = malloc(sizeof(long)); *result = num1+num2; From 54be43dd7b708356e8188f5fa06793457e3cd033 Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Fri, 9 Feb 2024 16:25:50 +0100 Subject: [PATCH 08/18] Added test for different input in input handler --- test/test_inputHandler.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/test/test_inputHandler.c b/test/test_inputHandler.c index 5cf92c7..e7bff29 100644 --- a/test/test_inputHandler.c +++ b/test/test_inputHandler.c @@ -15,4 +15,11 @@ void test_inputHandler_returntwoforinputminus(void) { int result; result = getOperationIdBySymbol('-'); TEST_ASSERT_EQUAL_INT(expectedResult, result); -} \ No newline at end of file +} + +void test_inputHandler_returnoneforinputplus(void) { + int expectedResult = 1; + int result; + result = getOperationIdBySymbol('+'); + TEST_ASSERT_EQUAL_INT(expectedResult, result); +} From 7b3854c20195f45d23bd8f39526fbce2092bc053 Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Fri, 9 Feb 2024 16:27:38 +0100 Subject: [PATCH 09/18] Implemented input handler test for valid method --- test/test_inputHandler.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/test_inputHandler.c b/test/test_inputHandler.c index e7bff29..72dfd24 100644 --- a/test/test_inputHandler.c +++ b/test/test_inputHandler.c @@ -23,3 +23,10 @@ void test_inputHandler_returnoneforinputplus(void) { result = getOperationIdBySymbol('+'); TEST_ASSERT_EQUAL_INT(expectedResult, result); } + +void test_inputHandler_returnzeroforinvalidinput(void) { + int expectedResult = 0; + int result; + result = isOperationIdValid(0); + TEST_ASSERT_EQUAL_INT(expectedResult, result); +} From 07e2db5698093db634eea689edc486a00306bd57 Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Fri, 9 Feb 2024 16:32:58 +0100 Subject: [PATCH 10/18] Added final test for input handler --- test/test_inputHandler.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/test_inputHandler.c b/test/test_inputHandler.c index 72dfd24..4b4f874 100644 --- a/test/test_inputHandler.c +++ b/test/test_inputHandler.c @@ -30,3 +30,10 @@ void test_inputHandler_returnzeroforinvalidinput(void) { result = isOperationIdValid(0); TEST_ASSERT_EQUAL_INT(expectedResult, result); } + +void test_inputHandler_returnoneifinputtoobig(void) { + int expectedResult = 1; + int result; + result = isNumberTooBig(300); + TEST_ASSERT_EQUAL_INT(expectedResult, result); +} \ No newline at end of file From bc4efb63bbaf390c77a22817ea2e2a112df4c866 Mon Sep 17 00:00:00 2001 From: Jonas Zitzmann Date: Fri, 9 Feb 2024 16:33:49 +0100 Subject: [PATCH 11/18] refactoring: Change to better var name --- src/convert_time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/convert_time.c b/src/convert_time.c index 2114697..b938c82 100644 --- a/src/convert_time.c +++ b/src/convert_time.c @@ -38,8 +38,8 @@ double converter_sec_in_hour(double sec){ // Converts Days in Years double converter_days_to_years(double days){ - double time = days / 365; - return time; + double years = days / 365; + return years; } // convert Years in days From 0b58c8222f161639b584c3e64f8a82a5e495d26f Mon Sep 17 00:00:00 2001 From: Jonas Zitzmann Date: Fri, 9 Feb 2024 16:34:26 +0100 Subject: [PATCH 12/18] refactoring: Change to better var name --- src/convert_time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/convert_time.c b/src/convert_time.c index b938c82..ce48b2f 100644 --- a/src/convert_time.c +++ b/src/convert_time.c @@ -32,8 +32,8 @@ double converter_hour_in_sec(double hour){ // Converts Seconds in Hours double converter_sec_in_hour(double sec){ - double time = sec / 60 / 60; - return time; + double hours = sec / 60 / 60; + return hours; } // Converts Days in Years From 699d55a1065968511fea6a02f57d4c8bbb5c66b8 Mon Sep 17 00:00:00 2001 From: Jonas Zitzmann Date: Fri, 9 Feb 2024 16:34:43 +0100 Subject: [PATCH 13/18] refactoring: Change to better var name --- src/convert_time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/convert_time.c b/src/convert_time.c index ce48b2f..578baab 100644 --- a/src/convert_time.c +++ b/src/convert_time.c @@ -26,8 +26,8 @@ double converter_min_to_hour(double min){ // Converts Hours in Seconds double converter_hour_in_sec(double hour){ - double time = hour * 60 * 60; - return time; + double secs = hour * 60 * 60; + return secs; } // Converts Seconds in Hours From 39b88136b70221eef5aac90598c66324f8534341 Mon Sep 17 00:00:00 2001 From: Jonas Zitzmann Date: Fri, 9 Feb 2024 16:34:58 +0100 Subject: [PATCH 14/18] refactoring: Change to better var name --- src/convert_time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/convert_time.c b/src/convert_time.c index 578baab..a82fab0 100644 --- a/src/convert_time.c +++ b/src/convert_time.c @@ -20,8 +20,8 @@ double converter_hour_to_min(double hour){ // Converts Minutes To Hours double converter_min_to_hour(double min){ - double time = min / 60; - return time; + double hours = min / 60; + return hours; } // Converts Hours in Seconds From 8120a3c4465b0dbec486f990764d7bd4e451178a Mon Sep 17 00:00:00 2001 From: Jonas Zitzmann Date: Fri, 9 Feb 2024 16:36:42 +0100 Subject: [PATCH 15/18] refactoring: Change to better var name --- src/convert_time.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/convert_time.c b/src/convert_time.c index a82fab0..40a9403 100644 --- a/src/convert_time.c +++ b/src/convert_time.c @@ -14,8 +14,8 @@ double converter_min_to_sec(double min){ // Converts Hours to Minutes double converter_hour_to_min(double hour){ - double time = hour * 60; - return time; + double min = hour * 60; + return min; } // Converts Minutes To Hours From 2330458d3d27b5ff1496d6e53cadca8099018000 Mon Sep 17 00:00:00 2001 From: Eric Bagus Date: Fri, 9 Feb 2024 16:38:36 +0100 Subject: [PATCH 16/18] refactoring: realigned code and removed multiple comments --- src/convert_kg_to_ton.h | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/convert_kg_to_ton.h b/src/convert_kg_to_ton.h index cc38ea6..032dc7f 100644 --- a/src/convert_kg_to_ton.h +++ b/src/convert_kg_to_ton.h @@ -1,19 +1,7 @@ - #ifndef THEADMIRALS_CONVERT_KG_TO_TON_H #define THEADMIRALS_CONVERT_KG_TO_TON_H - - - // Convert kilograms to tons -// Parameters: -// kilograms: weight in kilograms -// Returns: -// The equivalent weight in tons - double kg_to_tons(double kilograms); - - - #endif //THEADMIRALS_CONVERT_KG_TO_TON_H From e6ae03f33b60824edcb45ce4ddc0e852b488cca6 Mon Sep 17 00:00:00 2001 From: Leon Wolf Date: Fri, 9 Feb 2024 16:39:35 +0100 Subject: [PATCH 17/18] refactoring: changed description mistake --- src/convert_M_in_KM.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/convert_M_in_KM.c b/src/convert_M_in_KM.c index 4237094..bf56016 100644 --- a/src/convert_M_in_KM.c +++ b/src/convert_M_in_KM.c @@ -1,6 +1,6 @@ #include "convert_M_in_KM.h" -// convert length for double metre into kilometers +// convert length for double metre into kilometre double meter_to_kilometer(double meter) { return meter / 1000.0; } From 7eb4a20bfcf83a407bf2aa1abcf053f693e0cc23 Mon Sep 17 00:00:00 2001 From: Leon Wolf Date: Fri, 9 Feb 2024 16:40:52 +0100 Subject: [PATCH 18/18] refactoring: changed description mistake --- src/convert_M_in_KM.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/convert_M_in_KM.c b/src/convert_M_in_KM.c index bf56016..4980a96 100644 --- a/src/convert_M_in_KM.c +++ b/src/convert_M_in_KM.c @@ -1,6 +1,6 @@ #include "convert_M_in_KM.h" -// convert length for double metre into kilometre +//convert length for double metre into kilometre double meter_to_kilometer(double meter) { return meter / 1000.0; }