Browse Source

Updated the file name from test_taschenrechner.c to test_calculator.c

remotes/origin/kabrel
fdai7782 11 months ago
parent
commit
2ebea95823
  1. 390
      src/test/c/test_calculator.c

390
src/test/c/test_taschenrechner.c → src/test/c/test_calculator.c

@ -1,195 +1,195 @@
#ifdef TEST
#include "unity.h"
#include "taschenrechner.h"
void setUp(void)
{
}
void tearDown(void)
{
}
void test_addition(void)
{
doulbe result = add(1, 2);
TEST_ASSERT_EQUAL(3, result);
}
void test_minus(void)
{
doulbe result = minus(3, 1);
TEST_ASSERT_EQUAL(2, result);
}
void test_multiply(void)
{
doulbe result = multiply(1, 2);
TEST_ASSERT_EQUAL(2, result);
}
void test_divide(void)
{
doulbe result = divide(4, 2);
TEST_ASSERT_EQUAL(2, result);
doulbe result1 = divide(4, 0);
TEST_ASSERT_EQUAL(0, result1);
}
void test_ConMeter(void) {//5 mm to cm
double result = ConMeter(5, 0, 1);
TEST_ASSERT_EQUAL(50, result);
}
void test_ConMeterToFoot(void) {//5 m to foot
double result = ConMeterToFoot(5, 0, 1);
TEST_ASSERT_EQUAL(16.4042, result);
}
void test_ConKilometerToMiles(void) {//5 miles to km
double result = ConKilometerToMiles(5, 0, 1);
TEST_ASSERT_EQUAL(3.10686, result);
}
void test_ConGram(void) {//5 mg to g
double result = ConGram(5, 0, 1);
TEST_ASSERT_EQUAL(5000, result);
}
void test_ConGramToPounds(void) {//5 kg to pounds
double result = ConGramToPounds(5, 0, 1);
TEST_ASSERT_EQUAL(11.0231, result);
}
void test_ConTemp(void) {//5 celsius to fahrenheit
double result = ConTemp(5, 0, 1);
TEST_ASSERT_EQUAL(41, result);
}
void test_ConSpeed(void) {//5 kmh to mph
double result = ConTemp(5, 0, 1);
TEST_ASSERT_EQUAL(3.10686, result);
}
void test_ConLiter(void) {//5 l to ml
double result = ConTemp(5, 1, 0);
TEST_ASSERT_EQUAL(5000, result);
}
void test_ConLiterToGallon(void) {//5 l to gallon
double result = ConTemp(5, 0, 1);
TEST_ASSERT_EQUAL(1.32086, result);
}
void test_ConData(void) {//5 b to kb
double result = ConData(5, 0, 1);
TEST_ASSERT_EQUAL(0.005, result);
}
void test_ConArea(void) {//5 mm to cm
double result = ConData(5, 0, 1);
TEST_ASSERT_EQUAL(0.05), result);
}
void test_ConVolume(void) {//5 mm to cm
double result = ConData(5, 0, 1);
TEST_ASSERT_EQUAL(0.005), result);
}
void test_ConClock(void) {//5:00 to 5AM
double result = ConData(5, 0, 1);
TEST_ASSERT_EQUAL(5), result);
}
void test_ConTime(void) {//5 ms to s
double result = ConData(5, 0, 1);
TEST_ASSERT_EQUAL(0.005), result);
}
// Square root function
void test_squareRootFunction(void) {
TEST_ASSERT_EQUAL_FLOAT(2.0, squareRootFunction(4.0));
}
// Sine function
void test_sineFunction(void) {
// Your test code here
TEST_ASSERT_EQUAL_FLOAT(0.0, sineFunction(0.0));
}
// Cosine function
void test_cosineFunction(void) {
// Your test code here
TEST_ASSERT_EQUAL_FLOAT(1.0, cosineFunction(0.0));
}
// Tangent function
void test_tangentFunction(void) {
// Your test code here
TEST_ASSERT_EQUAL_FLOAT(0.0, tangentFunction(0.0));
}
// Logarithm function
void test_logarithmFunction(void) {
// Your test code here
TEST_ASSERT_EQUAL_FLOAT(1.0, logarithmFunction(10.0));
}
// Natural logarithm function
void test_naturalLogarithmFunction(void) {
// Your test code here
TEST_ASSERT_EQUAL_FLOAT(0.0, naturalLogarithmFunction(1.0));
}
// Logarithm with base 2 function
void test_logarithmBase2Function(void) {
// Your test code here
TEST_ASSERT_EQUAL_FLOAT(3.0, logarithmBase2Function(8.0));
}
// Exponential function
void test_exponentialFunction(void) {
// Your test code here
TEST_ASSERT_EQUAL_FLOAT(1.0, exponentialFunction(0.0));
}
// Test case for subtraction
void test_performOperation_Subtraction(void) {
// Arrange
int result;
// Act
result = performOperation(10, '-', 3);
// Assert
TEST_ASSERT_EQUAL_INT(7, result);
}
// Test case for multiplication
void test_performOperation_Multiplication(void) {
// Arrange
int result;
// Act
result = performOperation(4, '*', 6);
// Assert
TEST_ASSERT_EQUAL_INT(24, result);
}
// Test case for division
void test_performOperation_Division(void) {
// Arrange
int result;
// Act
result = performOperation(8, '/', 2);
// Assert
TEST_ASSERT_EQUAL_INT(4, result);
}
#endif // TEST
#ifdef TEST
#include "unity.h"
#include "calculator.h"
void setUp(void)
{
}
void tearDown(void)
{
}
void test_addition(void)
{
doulbe result = add(1, 2);
TEST_ASSERT_EQUAL(3, result);
}
void test_minus(void)
{
doulbe result = minus(3, 1);
TEST_ASSERT_EQUAL(2, result);
}
void test_multiply(void)
{
doulbe result = multiply(1, 2);
TEST_ASSERT_EQUAL(2, result);
}
void test_divide(void)
{
doulbe result = divide(4, 2);
TEST_ASSERT_EQUAL(2, result);
doulbe result1 = divide(4, 0);
TEST_ASSERT_EQUAL(0, result1);
}
void test_ConMeter(void) {//5 mm to cm
double result = ConMeter(5, 0, 1);
TEST_ASSERT_EQUAL(50, result);
}
void test_ConMeterToFoot(void) {//5 m to foot
double result = ConMeterToFoot(5, 0, 1);
TEST_ASSERT_EQUAL(16.4042, result);
}
void test_ConKilometerToMiles(void) {//5 miles to km
double result = ConKilometerToMiles(5, 0, 1);
TEST_ASSERT_EQUAL(3.10686, result);
}
void test_ConGram(void) {//5 mg to g
double result = ConGram(5, 0, 1);
TEST_ASSERT_EQUAL(5000, result);
}
void test_ConGramToPounds(void) {//5 kg to pounds
double result = ConGramToPounds(5, 0, 1);
TEST_ASSERT_EQUAL(11.0231, result);
}
void test_ConTemp(void) {//5 celsius to fahrenheit
double result = ConTemp(5, 0, 1);
TEST_ASSERT_EQUAL(41, result);
}
void test_ConSpeed(void) {//5 kmh to mph
double result = ConTemp(5, 0, 1);
TEST_ASSERT_EQUAL(3.10686, result);
}
void test_ConLiter(void) {//5 l to ml
double result = ConTemp(5, 1, 0);
TEST_ASSERT_EQUAL(5000, result);
}
void test_ConLiterToGallon(void) {//5 l to gallon
double result = ConTemp(5, 0, 1);
TEST_ASSERT_EQUAL(1.32086, result);
}
void test_ConData(void) {//5 b to kb
double result = ConData(5, 0, 1);
TEST_ASSERT_EQUAL(0.005, result);
}
void test_ConArea(void) {//5 mm to cm
double result = ConData(5, 0, 1);
TEST_ASSERT_EQUAL(0.05), result);
}
void test_ConVolume(void) {//5 mm to cm
double result = ConData(5, 0, 1);
TEST_ASSERT_EQUAL(0.005), result);
}
void test_ConClock(void) {//5:00 to 5AM
double result = ConData(5, 0, 1);
TEST_ASSERT_EQUAL(5), result);
}
void test_ConTime(void) {//5 ms to s
double result = ConData(5, 0, 1);
TEST_ASSERT_EQUAL(0.005), result);
}
// Square root function
void test_squareRootFunction(void) {
TEST_ASSERT_EQUAL_FLOAT(2.0, squareRootFunction(4.0));
}
// Sine function
void test_sineFunction(void) {
// Your test code here
TEST_ASSERT_EQUAL_FLOAT(0.0, sineFunction(0.0));
}
// Cosine function
void test_cosineFunction(void) {
// Your test code here
TEST_ASSERT_EQUAL_FLOAT(1.0, cosineFunction(0.0));
}
// Tangent function
void test_tangentFunction(void) {
// Your test code here
TEST_ASSERT_EQUAL_FLOAT(0.0, tangentFunction(0.0));
}
// Logarithm function
void test_logarithmFunction(void) {
// Your test code here
TEST_ASSERT_EQUAL_FLOAT(1.0, logarithmFunction(10.0));
}
// Natural logarithm function
void test_naturalLogarithmFunction(void) {
// Your test code here
TEST_ASSERT_EQUAL_FLOAT(0.0, naturalLogarithmFunction(1.0));
}
// Logarithm with base 2 function
void test_logarithmBase2Function(void) {
// Your test code here
TEST_ASSERT_EQUAL_FLOAT(3.0, logarithmBase2Function(8.0));
}
// Exponential function
void test_exponentialFunction(void) {
// Your test code here
TEST_ASSERT_EQUAL_FLOAT(1.0, exponentialFunction(0.0));
}
// Test case for subtraction
void test_performOperation_Subtraction(void) {
// Arrange
int result;
// Act
result = performOperation(10, '-', 3);
// Assert
TEST_ASSERT_EQUAL_INT(7, result);
}
// Test case for multiplication
void test_performOperation_Multiplication(void) {
// Arrange
int result;
// Act
result = performOperation(4, '*', 6);
// Assert
TEST_ASSERT_EQUAL_INT(24, result);
}
// Test case for division
void test_performOperation_Division(void) {
// Arrange
int result;
// Act
result = performOperation(8, '/', 2);
// Assert
TEST_ASSERT_EQUAL_INT(4, result);
}
#endif // TEST
Loading…
Cancel
Save