Browse Source
merge feature/calculator-subtract to feature/display-menu-calculator and implement calculatorSubtract() in displayMenuCalculator()
remotes/origin/feature/display-menu-calculator
merge feature/calculator-subtract to feature/display-menu-calculator and implement calculatorSubtract() in displayMenuCalculator()
remotes/origin/feature/display-menu-calculator
fdai7514
2 years ago
5 changed files with 149 additions and 1 deletions
-
12src/calculatorSubtract.c
-
11src/calculatorSubtract.h
-
4src/displayMenuCalculator.c
-
2src/main.c
-
121tests/test_calculatorSubtract.c
@ -0,0 +1,12 @@ |
|||
#include "calculatorSubtract.h" |
|||
|
|||
// Note: |
|||
/* This Function may or may not be implemented in actual program, even if it is merged to the main branch. |
|||
If it is temporarily not included in the main Program, then this has a role in future Development of the Project */ |
|||
|
|||
float calculatorSubtract (float num1, float num2) |
|||
{ |
|||
return num1 - num2; |
|||
} |
|||
|
|||
|
@ -0,0 +1,11 @@ |
|||
#ifndef CALCULATORSUBTRACT_H |
|||
#define CALCULATORSUBTRACT_H |
|||
|
|||
#include <stdio.h> |
|||
#include <stdlib.h> |
|||
|
|||
float calculatorSubtract(float num1, float num2); |
|||
|
|||
|
|||
|
|||
#endif // CALCULATORSUBTRACT_H |
@ -0,0 +1,121 @@ |
|||
#ifdef TEST |
|||
|
|||
#include "unity.h" |
|||
|
|||
#include "calculatorSubtract.h" |
|||
|
|||
// Note: |
|||
/* This Function may or may not be implemented in actual program, even if it is merged to the main branch. |
|||
If it is temporarily not included in the main Program, then this has a role in future Development of the Project */ |
|||
|
|||
|
|||
void setUp(void) |
|||
{ |
|||
} |
|||
|
|||
void tearDown(void) |
|||
{ |
|||
} |
|||
|
|||
|
|||
void test1_calculatorSubtract(void) |
|||
{ |
|||
float num1, num2, actual, expected; //Arrange |
|||
num1 = 123.211; |
|||
num2 = 112.21; |
|||
expected = num1 - num2; |
|||
actual = calculatorSubtract(num1, num2); //Act |
|||
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert |
|||
} |
|||
|
|||
void test2_calculatorSubtract(void) |
|||
{ |
|||
float num1, num2, actual, expected; //Arrange |
|||
num1 = 13.21; |
|||
num2 = 112.21; |
|||
expected = num1 - num2; |
|||
actual = calculatorSubtract(num1, num2); //Act |
|||
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert |
|||
} |
|||
|
|||
void test3_calculatorSubtract(void) |
|||
{ |
|||
float num1, num2, actual, expected; //Arrange |
|||
num1 = 12231.211; |
|||
num2 = 1122.21; |
|||
expected = num1 - num2; |
|||
actual = calculatorSubtract(num1, num2); //Act |
|||
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert |
|||
} |
|||
|
|||
void test4_calculatorSubtract(void) |
|||
{ |
|||
float num1, num2, actual, expected; //Arrange |
|||
num1 = 113453.211; |
|||
num2 = 11254.21; |
|||
expected = num1 - num2; |
|||
actual = calculatorSubtract(num1, num2); //Act |
|||
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert |
|||
} |
|||
|
|||
void test5_calculatorSubtract(void) |
|||
{ |
|||
float num1, num2, actual, expected; //Arrange |
|||
num1 = 12133.211; |
|||
num2 = 112.231; |
|||
expected = num1 - num2; |
|||
actual = calculatorSubtract(num1, num2); //Act |
|||
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert |
|||
} |
|||
|
|||
void test6_calculatorSubtract(void) |
|||
{ |
|||
float num1, num2, actual, expected; //Arrange |
|||
num1 = 1133.201; |
|||
num2 = 11221.21; |
|||
expected = num1 - num2; |
|||
actual = calculatorSubtract(num1, num2); //Act |
|||
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert |
|||
} |
|||
|
|||
void test7_calculatorSubtract(void) |
|||
{ |
|||
float num1, num2, actual, expected; //Arrange |
|||
num1 = 12213.2211; |
|||
num2 = 111.21; |
|||
expected = num1 - num2; |
|||
actual = calculatorSubtract(num1, num2); //Act |
|||
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert |
|||
} |
|||
|
|||
void test8_calculatorSubtract(void) |
|||
{ |
|||
float num1, num2, actual, expected; //Arrange |
|||
num1 = 16213.711; |
|||
num2 = 1214.2251; |
|||
expected = num1 - num2; |
|||
actual = calculatorSubtract(num1, num2); //Act |
|||
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert |
|||
} |
|||
|
|||
void test9_calculatorSubtract(void) |
|||
{ |
|||
float num1, num2, actual, expected; //Arrange |
|||
num1 = 1933.611; |
|||
num2 = 1432.21; |
|||
expected = num1 - num2; |
|||
actual = calculatorSubtract(num1, num2); //Act |
|||
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert |
|||
} |
|||
|
|||
void test10_calculatorSubtract(void) |
|||
{ |
|||
float num1, num2, actual, expected; //Arrange |
|||
num1 = 1233.811; |
|||
num2 = 1121.131; |
|||
expected = num1 - num2; |
|||
actual = calculatorSubtract(num1, num2); //Act |
|||
TEST_ASSERT_EQUAL_FLOAT(expected, actual); //Assert |
|||
} |
|||
|
|||
#endif // TEST |
Write
Preview
Loading…
Cancel
Save
Reference in new issue