From 7b82e04292b59bcaa1ed93f97cc63d11aa17a943 Mon Sep 17 00:00:00 2001 From: cxnnqr Date: Tue, 6 Feb 2024 12:54:28 +0100 Subject: [PATCH 1/6] refactoring: summarized tests --- test/ggT/test_ggT.c | 55 +++++---------------------------------------- 1 file changed, 5 insertions(+), 50 deletions(-) diff --git a/test/ggT/test_ggT.c b/test/ggT/test_ggT.c index 6c14258..7e4beec 100644 --- a/test/ggT/test_ggT.c +++ b/test/ggT/test_ggT.c @@ -5,66 +5,21 @@ void setUp(){} void tearDown(){} void test_ggTOf5And10(){ - //arrange - int a = 5; - int b = 10; - int expected = 5; - - //act - int result = ggT(a,b); - - //assert - TEST_ASSERT_EQUAL_INT(expected, result); + TEST_ASSERT_EQUAL_INT(5, ggT(5, 10)); } void test_ggTOfFirstNumberZero(){ - //arrange - int a = 0; - int b = 5; - int expected = 5; - - //act - int result = ggT(a,b); - - //assert - TEST_ASSERT_EQUAL_INT(expected, result); + TEST_ASSERT_EQUAL_INT(5, ggT(0, 5)); } void test_ggTOfSecondNumberZero(){ - //arrange - int a = 10; - int b = 0; - int expected = 10; - - //act - int result = ggT(a,b); - - //assert - TEST_ASSERT_EQUAL_INT(expected, result); + TEST_ASSERT_EQUAL_INT(10, ggT(10, 0)); } void test_ggTOfBothNumbersZero(){ - //arrange - int a = 0; - int b = 0; - int expected = 0; - - //act - int result = ggT(a,b); - - //assert - TEST_ASSERT_EQUAL_INT(expected,result); + TEST_ASSERT_EQUAL_INT(0, ggT(0, 0)); } void test_ggTOfCoprimes(){ - //arrange - int a = 13; - int b = 27; - int expected = 1; - - //act - int result = ggT(a,b); - - //assert - TEST_ASSERT_EQUAL_INT(expected,result); + TEST_ASSERT_EQUAL_INT(1, ggT(13, 27)); } \ No newline at end of file From 7ddc4b2251cfa91f7c999afc394cd8658c66571b Mon Sep 17 00:00:00 2001 From: cxnnqr Date: Tue, 6 Feb 2024 13:15:04 +0100 Subject: [PATCH 2/6] added main.c for ggT --- src/ggT/main.c | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 src/ggT/main.c diff --git a/src/ggT/main.c b/src/ggT/main.c new file mode 100644 index 0000000..a02ee74 --- /dev/null +++ b/src/ggT/main.c @@ -0,0 +1,6 @@ +int main(){ + + + return 0; +} + From fda5883b0c053a2d26e2cc652bd5915aaeffc18f Mon Sep 17 00:00:00 2001 From: cxnnqr Date: Tue, 6 Feb 2024 13:15:56 +0100 Subject: [PATCH 3/6] added functions to get the two numbers by the user --- src/ggT/main.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/ggT/main.c b/src/ggT/main.c index a02ee74..f6334b2 100644 --- a/src/ggT/main.c +++ b/src/ggT/main.c @@ -1,5 +1,11 @@ -int main(){ +#include "ggT.h" +#include "../userinput.h" +#include +int main(){ + printf("add two numbers:\n"); + int firstNum = usergetd("first number: ", 0, NULL); + int secondNum = usergetd("second number: ", 0, NULL); return 0; } From 9d410dc9f2f887c59926ff25b863ce6efacd4b4c Mon Sep 17 00:00:00 2001 From: cxnnqr Date: Tue, 6 Feb 2024 13:17:22 +0100 Subject: [PATCH 4/6] added ggT function to get the result --- src/ggT/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ggT/main.c b/src/ggT/main.c index f6334b2..fd29c99 100644 --- a/src/ggT/main.c +++ b/src/ggT/main.c @@ -6,6 +6,7 @@ int main(){ printf("add two numbers:\n"); int firstNum = usergetd("first number: ", 0, NULL); int secondNum = usergetd("second number: ", 0, NULL); + int result = ggT(firstNum, secondNum); return 0; } From e783ed4f25b40527ae377befac9dd3be078bd95d Mon Sep 17 00:00:00 2001 From: cxnnqr Date: Tue, 6 Feb 2024 13:18:08 +0100 Subject: [PATCH 5/6] print the ggT of those two numbers --- src/ggT/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/ggT/main.c b/src/ggT/main.c index fd29c99..b40637a 100644 --- a/src/ggT/main.c +++ b/src/ggT/main.c @@ -7,6 +7,7 @@ int main(){ int firstNum = usergetd("first number: ", 0, NULL); int secondNum = usergetd("second number: ", 0, NULL); int result = ggT(firstNum, secondNum); + printf("The ggT is: %d\n", result); return 0; } From 1db5c0ef757dd10746e3de45531e1b4589f9db82 Mon Sep 17 00:00:00 2001 From: cxnnqr Date: Tue, 6 Feb 2024 13:19:58 +0100 Subject: [PATCH 6/6] refactoring: changed print messages --- src/ggT/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ggT/main.c b/src/ggT/main.c index b40637a..e9bc365 100644 --- a/src/ggT/main.c +++ b/src/ggT/main.c @@ -3,11 +3,11 @@ #include int main(){ - printf("add two numbers:\n"); + printf("Please add the two numbers you want the ggT of:\n"); int firstNum = usergetd("first number: ", 0, NULL); int secondNum = usergetd("second number: ", 0, NULL); int result = ggT(firstNum, secondNum); - printf("The ggT is: %d\n", result); + printf("The ggT of %d and %d is: %d\n", firstNum, secondNum, result); return 0; }