fdai7782
11 months ago
45 changed files with 4012 additions and 9 deletions
-
16.vscode/c_cpp_properties.json
-
24.vscode/launch.json
-
9.vscode/settings.json
-
1Unity
-
12project.yml
-
66src/main/c/BasicMode.c
-
10src/main/c/BasicMode.h
-
258src/main/c/ConvertMode.c
-
1358src/main/c/main_calculator.c
-
83src/main/c/main_calculator.h
-
99src/main/c/programmingMode.c
-
8src/main/c/programmingMode.h
-
156src/main/c/scientificMode.c
-
31src/main/c/testForNumber.c
-
7src/main/c/testForNumber.h
-
29src/main/c/testForOperator.c
-
7src/main/c/testForOperator.h
-
0src/test/c/support/.gitkeep
-
243src/test/c/test_calculator.c
-
9target/test/cache/defines_dependency.yml
-
243target/test/cache/input.yml
-
520target/test/cache/test_calculator.c
-
6target/test/dependencies/cmock.d
-
0target/test/dependencies/force_build
-
2target/test/dependencies/main_calculator.d
-
2target/test/dependencies/programmingMode.d
-
2target/test/dependencies/testForNumber.d
-
2target/test/dependencies/testForOperator.d
-
5target/test/dependencies/test_calculator.d
-
4target/test/dependencies/test_calculator_runner.d
-
4target/test/dependencies/unity.d
-
BINtarget/test/out/c/cmock.o
-
BINtarget/test/out/c/main_calculator.o
-
BINtarget/test/out/c/programmingMode.o
-
BINtarget/test/out/c/testForNumber.o
-
BINtarget/test/out/c/testForOperator.o
-
BINtarget/test/out/c/test_calculator.o
-
BINtarget/test/out/c/test_calculator_runner.o
-
BINtarget/test/out/c/unity.o
-
BINtarget/test/out/test_calculator.out
-
520target/test/preprocess/files/test_calculator.c
-
6target/test/preprocess/includes/test_calculator.c
-
134target/test/results/test_calculator.pass
-
139target/test/runners/test_calculator_runner.c
-
6teams.md
@ -0,0 +1,16 @@ |
|||
{ |
|||
"configurations": [ |
|||
{ |
|||
"name": "linux-gcc-x64", |
|||
"includePath": [ |
|||
"${workspaceFolder}/**" |
|||
], |
|||
"defines": [], |
|||
"compilerPath": "/usr/bin/gcc", |
|||
"cStandard": "${default}", |
|||
"cppStandard": "${default}", |
|||
"intelliSenseMode": "linux-gcc-x64" |
|||
} |
|||
], |
|||
"version": 4 |
|||
} |
@ -0,0 +1,24 @@ |
|||
{ |
|||
"version": "0.2.0", |
|||
"configurations": [ |
|||
{ |
|||
"name": "C/C++ Runner: Debug Session", |
|||
"type": "cppdbg", |
|||
"request": "launch", |
|||
"args": [], |
|||
"stopAtEntry": false, |
|||
"externalConsole": false, |
|||
"cwd": "/home/js/Desktop/caschenrechner/src/test/c", |
|||
"program": "/home/js/Desktop/caschenrechner/src/test/c/build/Debug/outDebug", |
|||
"MIMode": "gdb", |
|||
"miDebuggerPath": "gdb", |
|||
"setupCommands": [ |
|||
{ |
|||
"description": "Enable pretty-printing for gdb", |
|||
"text": "-enable-pretty-printing", |
|||
"ignoreFailures": true |
|||
} |
|||
] |
|||
} |
|||
] |
|||
} |
@ -0,0 +1,9 @@ |
|||
{ |
|||
"C_Cpp.errorSquiggles": "disabled", |
|||
"files.associations": { |
|||
"testforoperator.h": "c", |
|||
"testfornumber.h": "c", |
|||
"programmingmode.h": "c" |
|||
}, |
|||
"C_Cpp_Runner.msvcBatchPath": "" |
|||
} |
@ -0,0 +1,66 @@ |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
#include <math.h> |
|||
#include "BasicMode.h" |
|||
|
|||
|
|||
// convert decimal to binary |
|||
long long int DecToBin(long long int n) { |
|||
long long int bin = 0; |
|||
long long int rem, i = 1; |
|||
|
|||
while (n != 0) { |
|||
rem = n % 2; |
|||
bin += rem * i; |
|||
i *= 10; |
|||
n /= 2; |
|||
} |
|||
|
|||
return bin; |
|||
} |
|||
// convert binary to decimal |
|||
long long int BinToDec(long long int n) { |
|||
long long int dec = 0, i = 0, rem; |
|||
|
|||
while (n != 0) { |
|||
rem = n % 10; |
|||
dec += rem * pow(2, i); |
|||
i++; |
|||
n /= 10; |
|||
} |
|||
|
|||
return dec; |
|||
} |
|||
//addition |
|||
long long int additionbin(long long int a, long long int b) { |
|||
long long int dec1, dec2; |
|||
dec1 = BinToDec(a); |
|||
dec2 = BinToDec(b); |
|||
dec1 = dec1 + dec2; |
|||
dec2 = DecToBin(dec1); |
|||
|
|||
return dec2; |
|||
} |
|||
// multiplication |
|||
long long int multiplicationbin(long long int a, long long int b) { |
|||
long long int dec1, dec2; |
|||
dec1 = BinToDec(a); |
|||
dec2 = BinToDec(b); |
|||
dec1 = dec1 * dec2; |
|||
dec2 = DecToBin(dec1); |
|||
|
|||
return dec2; |
|||
} |
|||
//subtraction |
|||
long long int subtractionbin(long long int a, long long int b) { |
|||
long long int dec1, dec2; |
|||
dec1 = BinToDec(a); |
|||
dec2 = BinToDec(b); |
|||
dec1 = dec1 - dec2; |
|||
dec2 = DecToBin(dec1); |
|||
|
|||
return dec2; |
|||
} |
|||
|
|||
|
@ -0,0 +1,10 @@ |
|||
#ifndef BasicMode |
|||
#define BasicMode |
|||
|
|||
long long int DecToBin(long long int n); |
|||
long long int BinToDec(long long int n); |
|||
long long int additionbin(long long int a, long long int b); |
|||
long long int multiplicationbin(long long int a, long long int b); |
|||
long long int subtractionbin(long long int a, long long int b); |
|||
|
|||
#endif // BasicMode |
@ -0,0 +1,258 @@ |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
#include <math.h> |
|||
#include <stdbool.h> |
|||
|
|||
// Unit converter mode |
|||
|
|||
int choice, startingUnit, endingUnit; |
|||
double value, result; |
|||
|
|||
char Distance[] = { 'mm', 'cm', 'm', 'km', 'feet/inch', 'miles'}; |
|||
char Weight[] = { 'mg', 'g', 'kg', 't', 'pounds'}; |
|||
char Fluid[] = { 'ml', 'l' , 'gallon'}; |
|||
char Temp[] = { 'celsius', 'fahrenheit' }; |
|||
char Speed[] = { 'km/h','mp/h' }; |
|||
char Data[] = { 'B', 'KB', 'MB', 'GB', 'TB', 'PT' }; |
|||
char Time[] = { 'ms', 's', 'min', 'h', 'd', 'w', 'mon', 'y'}; |
|||
char currency[] = { 'E', 'D', 'R' }; |
|||
|
|||
|
|||
double getValue(int choice) { |
|||
printf("\nEnter the value to be converted: "); |
|||
scanf("%lf", &value); |
|||
|
|||
while (choice < 0 && choice >= 15) { |
|||
switch (choice) |
|||
{ |
|||
case 1: |
|||
printf("\nEnter what the Unit is starting with (0 mm, 1 cm, 2 m, 3 km): "); |
|||
scanf("%d", &startingUnit); |
|||
//1 10 1.000 1.000.000 |
|||
printf("\nEnter what the value should it be changed to (0 mm, 1 cm, 2 m, 3 km): "); |
|||
scanf("%d", &endingUnit); |
|||
|
|||
result = ConMeter(value, startingUnit,endingUnit); |
|||
|
|||
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); |
|||
break; |
|||
|
|||
case 2: |
|||
printf("\nEnter what the Unit is starting with (0 feet/Inch, 1 meter): "); |
|||
scanf("%d", &startingUnit); |
|||
|
|||
printf("\nEnter what the value should it be changed to (0 feet/Inch, 1 meter): "); |
|||
scanf("%d", &endingUnit); |
|||
|
|||
result = ConMeterToFoot(value, startingUnit, endingUnit); |
|||
|
|||
if (endingUnit == 0) { //if feet/inch change to 4. in array of Distance |
|||
endingUnit = 4; |
|||
} |
|||
|
|||
else if (endingUnit == 1) { //if meter change to 2. in array of Distance |
|||
endingUnit = 2; |
|||
} |
|||
|
|||
|
|||
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); |
|||
break; |
|||
|
|||
case 3: |
|||
printf("\nEnter what the Unit is starting with (0 miles, 1 kilometer): "); |
|||
scanf("%d", &startingUnit); |
|||
|
|||
printf("\nEnter what the value should it be changed to (0 miles, 1 kilometer): "); |
|||
scanf("%d", &endingUnit); |
|||
|
|||
result = ConKilometerToMiles(value, startingUnit, endingUnit); |
|||
|
|||
if (endingUnit == 0) { //if miles change to 5. in array of Distance |
|||
endingUnit = 5; |
|||
} |
|||
|
|||
else if (endingUnit == 1) { //if kilometer change to 2. in array of Distance |
|||
endingUnit = 3; |
|||
} |
|||
|
|||
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); |
|||
break; |
|||
|
|||
case 4://'mg', 'g', 'kg', 't' |
|||
printf("\nEnter what the Unit is starting with (0 mg, 1 g, 2 kg , 3 t): "); |
|||
scanf("%d", &startingUnit); |
|||
|
|||
printf("\nEnter what the value should it be changed to (0 mg, 1 g, 2 kg , 3 t): "); |
|||
scanf("%d", &endingUnit); |
|||
|
|||
result = ConGram(value, startingUnit, endingUnit); |
|||
|
|||
printf("\nThe convertet result is %dlf %d", result, Weight[endingUnit]); |
|||
break; |
|||
|
|||
case 5://'kg', 'pounds' |
|||
printf("\nEnter what the Unit is starting with (0 kg, 1 pounds): "); |
|||
scanf("%d", &startingUnit); |
|||
|
|||
printf("\nEnter what the value should it be changed to (0 kg, 1 pounds): "); |
|||
scanf("%d", &endingUnit); |
|||
|
|||
result = ConGramToPounds(value, startingUnit, endingUnit); |
|||
|
|||
printf("\nThe convertet result is %dlf %d", result, Weight[endingUnit]); |
|||
break; |
|||
|
|||
case 6://'celsius', 'fahrenheit' |
|||
printf("\nEnter what the Unit is starting with (0 celsius, 1 fahrenheit): "); |
|||
scanf("%d", &startingUnit); |
|||
|
|||
printf("\nEnter what the value should it be changed to (0 celsius, 1 fahrenheit): "); |
|||
scanf("%d", &endingUnit); |
|||
|
|||
result = ConTemp(value, startingUnit, endingUnit); |
|||
|
|||
printf("\nThe convertet result is %dlf %d", result, Temp[endingUnit]); |
|||
break; |
|||
|
|||
case 7://'km/h','mp/h' |
|||
printf("\nEnter what the Unit is starting with (0 km/h, 1 mp/h): "); |
|||
scanf("%d", &startingUnit); |
|||
|
|||
printf("\nEnter what the value should it be changed to (0 km/h, 1 mp/h): "); |
|||
scanf("%d", &endingUnit); |
|||
|
|||
result = ConSpeed(value, startingUnit, endingUnit); |
|||
|
|||
printf("\nThe convertet result is %dlf %d", result, Speed[endingUnit]); |
|||
break; |
|||
|
|||
case 8://'ml', 'l' |
|||
printf("\nEnter what the Unit is starting with (0 ml, 1 l): "); |
|||
scanf("%d", &startingUnit); |
|||
|
|||
printf("\nEnter what the value should it be changed to (0 ml, 1 l): "); |
|||
scanf("%d", &endingUnit); |
|||
|
|||
result = ConLiter(value, startingUnit, endingUnit); |
|||
|
|||
printf("\nThe convertet result is %dlf %d", result, Fluid[endingUnit]); |
|||
break; |
|||
|
|||
|
|||
case 9://'ml', 'l' |
|||
printf("\nEnter what the Unit is starting with (0 l, 1 gallon): "); |
|||
scanf("%d", &startingUnit); |
|||
|
|||
printf("\nEnter what the value should it be changed to (0 l, 1 gallon): "); |
|||
scanf("%d", &endingUnit); |
|||
|
|||
result = ConLiterToGallon(value, startingUnit, endingUnit); |
|||
|
|||
printf("\nThe convertet result is %dlf %d", result, Fluid[endingUnit]); |
|||
break; |
|||
|
|||
case 10://char Data[] = { 'B', 'KB', 'MB', 'GB', 'TB', 'PT' }; |
|||
printf("\nEnter what the Unit is starting with (0 B, 1 KB, 2 MB , 3 GB, 4 TB, 5 PT): "); |
|||
scanf("%d", &startingUnit); |
|||
|
|||
printf("\nEnter what the value should it be changed to (0 B, 1 KB, 2 MB , 3 GB, 4 TB, 5 PT): "); |
|||
scanf("%d", &endingUnit); |
|||
|
|||
result = ConData(value, startingUnit, endingUnit); |
|||
|
|||
printf("\nThe convertet result is %dlf %d", result, Data[endingUnit]); |
|||
break; |
|||
|
|||
case 11://char Distance[] = { 'mm', 'cm', 'm', 'km', 'feet/inch', 'miles'}; |
|||
printf("\nEnter what the Unit is starting with (0 mm, 1 cm, 2 m , 3 km,): "); |
|||
scanf("%d", &startingUnit); |
|||
|
|||
printf("\nEnter what the value should it be changed to (0 mm, 1 cm, 2 m , 3 km,): "); |
|||
scanf("%d", &endingUnit); |
|||
|
|||
result = ConArea(value, startingUnit, endingUnit); |
|||
|
|||
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); |
|||
break; |
|||
|
|||
case 12://char Distance[] = { 'mm', 'cm', 'm', 'km', 'feet/inch', 'miles'}; |
|||
printf("\nEnter what the Unit is starting with (0 mm, 1 cm, 2 m , 3 km,): "); |
|||
scanf("%d", &startingUnit); |
|||
|
|||
printf("\nEnter what the value should it be changed to (0 mm, 1 cm, 2 m , 3 km,): "); |
|||
scanf("%d", &endingUnit); |
|||
|
|||
result = ConArea(value, startingUnit, endingUnit); |
|||
|
|||
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); |
|||
break; |
|||
|
|||
case 13://char Time[] = { 'ms', 's', 'min', 'h', 'd', 'w', 'mon', 'y' }; |
|||
printf("\nEnter what the Unit is starting with (0 ms, 1 s, 2 min, 3 h, 4 d, 5 w, 6 mon, 7 y): "); |
|||
scanf("%d", &startingUnit); |
|||
|
|||
printf("\nEnter what the value should it be changed to (0 ms, 1 s, 2 min, 3 h, 4 d, 5 w, 6 mon, 7 y): "); |
|||
scanf("%d", &endingUnit); |
|||
|
|||
result = ConTime(value, startingUnit, endingUnit); |
|||
|
|||
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); |
|||
break; |
|||
|
|||
case 14: |
|||
printf("\nEnter what the Unit is starting with (0 (24h), 1 (12h)): "); |
|||
scanf("%d", &startingUnit); |
|||
|
|||
printf("\nEnter what the value should it be changed to (0 (24h), 1 (12h)): "); |
|||
scanf("%d", &endingUnit); |
|||
|
|||
result = ConClock(value, startingUnit, endingUnit); |
|||
|
|||
printf("\nThe convertet result is %dlf %d", result, Distance[endingUnit]); |
|||
break; |
|||
} |
|||
} |
|||
} |
|||
|
|||
void unitConverterMode() { |
|||
|
|||
printf("Unit Converter Mode:\n"); |
|||
|
|||
printf("Distance conversions:\n"); |
|||
printf("1. Convert Meter (cm, m, km)\n"); |
|||
printf("2. Meter to foot/inches\n"); |
|||
printf("3. Kilometer to Miles\n"); |
|||
|
|||
printf("Weight conversion:\n"); |
|||
printf("4. Convert Gram (mg, g, kg)\n"); |
|||
printf("5. Gram to Pounds \n"); |
|||
|
|||
printf("Temprature conversion:\n"); |
|||
printf("6. Celsius to Fahrenheit\n"); |
|||
|
|||
printf("Speed conversion:\n"); |
|||
printf("7. km/h to mph \n"); |
|||
|
|||
printf("Fluid conversion:\n"); |
|||
printf("8. Convert Liter (ml, l, kl) \n"); |
|||
printf("9. Liter to Gallon\n"); |
|||
|
|||
printf("Data conversions:\n"); |
|||
printf("10. Convert Data size (MB, GB, TB)\n"); |
|||
|
|||
printf("Area/Volume conversions \n"); |
|||
printf("11. Convert area (cm, m, km) \n"); |
|||
printf("12. Convert Volume (cm, m, km)\n"); |
|||
|
|||
printf("Time conversion \n"); |
|||
printf("13. Convert time (s, m, h, d, w, m, y) \n"); |
|||
printf("14. Convert Clock (12 Hour, 24 Hour) \n"); |
|||
|
|||
printf("Time conversion \n"); |
|||
printf("15. Convert currency (Euro, Dollar, Russian Rubel) \n"); |
|||
|
|||
printf("\nEnter your choice (Exit with 0): "); |
|||
scanf("%d", &choice); |
|||
getValue(choice); |
|||
} |
1358
src/main/c/main_calculator.c
File diff suppressed because it is too large
View File
File diff suppressed because it is too large
View File
@ -0,0 +1,83 @@ |
|||
#ifndef MAIN_CALCULATOR |
|||
#define MAIN_CALCULATOR |
|||
|
|||
// add function |
|||
double add(double a, double b); |
|||
|
|||
// minus function |
|||
double minus(double a, double b); |
|||
|
|||
// multiply function |
|||
double multiply(double a, double b); |
|||
|
|||
// divide function |
|||
double divide(double a, double b); |
|||
|
|||
// Square root function |
|||
double squareRootFunction(double x); |
|||
|
|||
//.. |
|||
// Trigonometric functions |
|||
double sineFunction(double angle); |
|||
|
|||
double cosineFunction(double angle); |
|||
|
|||
double tangentFunction(double angle); |
|||
|
|||
//.. |
|||
// Logarithmic functions |
|||
double logarithmFunction(double x); |
|||
|
|||
double naturalLogarithmFunction(double x); |
|||
|
|||
double logarithmBase2Function(double x); |
|||
|
|||
//.. |
|||
// Exponential function |
|||
double exponentialFunction(double x); |
|||
|
|||
// .. |
|||
// Bitwise AND function |
|||
int bitwiseAND(int num1, int num2); |
|||
|
|||
// Bitwise OR function |
|||
int bitwiseOR(int num1, int num2); |
|||
|
|||
// Bitwise XOR function |
|||
int bitwiseXOR(int num1, int num2); |
|||
|
|||
int mode(int userChoice); |
|||
|
|||
int displayMenu(); |
|||
|
|||
// Conversion Functions |
|||
double ConMeter(double meter, int startingUnit, int endingUnit); |
|||
|
|||
double ConMeterToFoot(double distance, int startingUnit, int endingUnit); |
|||
|
|||
double ConKilometerToMiles(double distance, int startingUnit, int endingUnit); |
|||
|
|||
double ConGram(double weight, int startingUnit, int endingUnit); |
|||
|
|||
double ConGramToPounds(double weight, int startingUnit, int endingUnit); |
|||
|
|||
double ConTemp(double temp, int startingUnit, int endingUnit); |
|||
|
|||
double ConSpeed(double speed, int startingUnit, int endingUnit); |
|||
|
|||
double ConLiter(double liter, int startingUnit, int endingUnit); |
|||
|
|||
double ConLiterToGallon(double fluid, int startingUnit, int endingUnit); |
|||
|
|||
double ConData(double data, int startingUnit, int endingUnit); |
|||
|
|||
double ConArea(double area, int startingUnit, int endingUnit); |
|||
|
|||
double ConVolume(double volum, int startingUnit, int endingUnit); |
|||
|
|||
double ConClock(double time, int startingUnit, int endingUnit); |
|||
|
|||
double ConTime(double time, int startingUnit, int endingUnit); |
|||
|
|||
|
|||
#endif // CALCULATOR |
@ -0,0 +1,99 @@ |
|||
// programmingMode |
|||
|
|||
#include <stdio.h> |
|||
#include <math.h> |
|||
|
|||
#include "programmingMode.h" |
|||
|
|||
|
|||
// Function to convert an integer to binary representation |
|||
char* binaryRepresentation(int num); |
|||
|
|||
// get the NUmbers from the user |
|||
int getIntegerInput(const char* prompt) { |
|||
int num; |
|||
printf("%s", prompt); |
|||
scanf("%d", &num); |
|||
return num; |
|||
} |
|||
|
|||
// Display the diffrent operations and scan them |
|||
char getOperatorInput() { |
|||
char operator; |
|||
printf("Enter operator (+, -, *, /): "); |
|||
scanf(" %c", &operator); |
|||
return operator; |
|||
} |
|||
|
|||
// Calculation |
|||
int performOperation(int num1, char operatorType, int num2) { |
|||
switch (operatorType) { |
|||
case '+': |
|||
return num1 + num2; |
|||
case '-': |
|||
return num1 - num2; |
|||
case '*': |
|||
return num1 * num2; |
|||
case '/': |
|||
if (num2 != 0) { |
|||
return num1 / num2; |
|||
} else { |
|||
return 0; |
|||
} |
|||
default: |
|||
printf("Invalid operator\n"); |
|||
return 0; |
|||
} |
|||
} |
|||
|
|||
void programmingMode() { |
|||
|
|||
char choice; |
|||
do { |
|||
int num1 = getIntegerInput("Enter first integer: "); |
|||
char operator = getOperatorInput(); |
|||
int num2 = getIntegerInput("Enter second integer: "); |
|||
|
|||
// Calculation |
|||
int result = performOperation(num1, operator, num2); |
|||
|
|||
// Display the result in different bases based on user choice |
|||
int base; |
|||
printf("Choose base to print the result (2 for binary, 8 for octal, 16 for hexadecimal): "); |
|||
scanf("%d", &base); |
|||
|
|||
switch (base) { |
|||
case 2: |
|||
printf("Result (Binary): %s\n", binaryRepresentation(result)); |
|||
break; |
|||
case 8: |
|||
printf("Result (Octal): %o\n", result); |
|||
break; |
|||
case 16: |
|||
printf("Result (Hexadecimal): %x\n", result); |
|||
break; |
|||
default: |
|||
printf("Invalid base choice\n"); |
|||
break; |
|||
} |
|||
|
|||
// Ask user if they want to continue |
|||
printf("Do you want to continue? (y/n): "); |
|||
scanf(" %c", &choice); |
|||
|
|||
} while (choice == 'y' || choice == 'Y'); |
|||
} |
|||
|
|||
|
|||
|
|||
// Function to convert an integer to binary representation |
|||
char* binaryRepresentation(int num) { |
|||
static char binary[32]; |
|||
for (int i = 31; i >= 0; i--) { |
|||
binary[i] = (num & 1) + '0'; |
|||
num >>= 1; |
|||
} |
|||
binary[32] = '\0'; |
|||
return binary; |
|||
} |
|||
|
@ -0,0 +1,8 @@ |
|||
#ifndef PROGRAMMINGMODE |
|||
#define PROGRAMMINGMODE |
|||
|
|||
// to test some calculations |
|||
int performOperation(int num1, char operatorType, int num2); |
|||
|
|||
|
|||
#endif // PROGRAMMINGMODE |
@ -0,0 +1,156 @@ |
|||
// scientificMode |
|||
|
|||
#include <stdio.h> |
|||
#include <math.h> |
|||
|
|||
// get the number which has to be calculated |
|||
double getNumberFromUser() { |
|||
double num; |
|||
printf("Enter a number: "); |
|||
scanf("%lf", &num); |
|||
return num; |
|||
} |
|||
|
|||
// Choice for ScientificMode |
|||
int getScientificModeChoice() { |
|||
int choice; |
|||
printf("Scientific mode Options:\n"); |
|||
printf("1: Square root\n"); |
|||
printf("2: Exponential\n"); |
|||
printf("3: Logarithm\n"); |
|||
printf("4: Trigonometric\n"); |
|||
printf("0: Exit\n"); |
|||
scanf("%d", &choice); |
|||
return choice; |
|||
} |
|||
|
|||
// Choice for Logarithm |
|||
int getLogarithmChoice() { |
|||
int logChoice; |
|||
printf("Logarithm Options:\n"); |
|||
printf("1: Logarithm (base 10)\n"); |
|||
printf("2: Natural Logarithm (ln)\n"); |
|||
printf("3: Logarithm (base 2)\n"); |
|||
printf("0: Exit Logarithm Menu\n"); |
|||
scanf("%d", &logChoice); |
|||
return logChoice; |
|||
} |
|||
|
|||
// Choice for Trigonomtri |
|||
int getTrigonometricChoice() { |
|||
int trigChoice; |
|||
printf("Trigonometric functions:\n"); |
|||
printf("1: Sine\n"); |
|||
printf("2: Cosine\n"); |
|||
printf("3: Tangent\n"); |
|||
printf("0: Exit Trigonometric Menu\n"); |
|||
scanf("%d", &trigChoice); |
|||
return trigChoice; |
|||
} |
|||
|
|||
|
|||
// Logarithm |
|||
void executeLogarithmFunction(double num) { |
|||
int logChoice; |
|||
|
|||
do { |
|||
|
|||
logChoice = getLogarithmChoice(); |
|||
|
|||
switch (logChoice) { |
|||
case 1: // Logarithm (base 10) |
|||
printf("Result: %lf\n", logarithmFunction(num)); |
|||
break; |
|||
|
|||
case 2: // Natural Logarithm (ln) |
|||
printf("Result: %lf\n", naturalLogarithmFunction(num)); |
|||
break; |
|||
|
|||
case 3: // Logarithm (base 2) |
|||
printf("Result: %lf\n", logarithmBase2Function(num)); |
|||
break; |
|||
|
|||
case 0: // Exit the logarithm menu |
|||
break; |
|||
|
|||
default: |
|||
printf("Invalid logarithm function choice. Please try again.\n"); |
|||
} |
|||
} while (logChoice != 0); |
|||
} |
|||
|
|||
// Trigonometric |
|||
void executeTrigonometricFunction(double num) { |
|||
int trigChoice; |
|||
|
|||
do { |
|||
|
|||
trigChoice = getTrigonometricChoice(); |
|||
|
|||
switch (trigChoice) { |
|||
case 1: // Sine |
|||
printf("Result: %lf\n", sineFunction(num)); |
|||
break; |
|||
|
|||
case 2: // Cosine |
|||
printf("Result: %lf\n", cosineFunction(num)); |
|||
break; |
|||
|
|||
case 3: // Tangent |
|||
printf("Result: %lf\n", tangentFunction(num)); |
|||
break; |
|||
|
|||
case 0: // Exit the trigonometric menu |
|||
break; |
|||
|
|||
default: |
|||
printf("Invalid trigonometric function choice. Please try again.\n"); |
|||
} |
|||
} while (trigChoice != 0); |
|||
} |
|||
|
|||
|
|||
void executeScientificFunction(double num, int choice) { |
|||
double result; |
|||
|
|||
switch (choice) { |
|||
case 1: // Square root |
|||
result = squareRootFunction(num); |
|||
printf("Result: %lf\n", result); |
|||
break; |
|||
|
|||
case 2: // Exponential |
|||
result = exponentialFunction(num); |
|||
printf("Result: %lf\n", result); |
|||
break; |
|||
|
|||
case 3: // Logarithm |
|||
executeLogarithmFunction(num); |
|||
break; |
|||
|
|||
case 4: // Trigonometric |
|||
executeTrigonometricFunction(num); |
|||
break; |
|||
|
|||
case 0: // Exit the loop |
|||
break; |
|||
|
|||
default: |
|||
printf("Invalid choice. Please try again.\n"); |
|||
} |
|||
} |
|||
|
|||
|
|||
// scientificMode |
|||
double scientificMode() { |
|||
double result; |
|||
int choice; |
|||
|
|||
do { |
|||
double num = getNumberFromUser(); |
|||
choice = getScientificModeChoice(); |
|||
executeScientificFunction(num, choice); |
|||
} while (choice != 0); |
|||
|
|||
return result; |
|||
} |
@ -0,0 +1,31 @@ |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
#include <math.h> |
|||
#include <ctype.h> |
|||
|
|||
#include "testForNumber.h" |
|||
|
|||
double testForNumber() { |
|||
double num; |
|||
char storage[25]; |
|||
char* notANumber; |
|||
|
|||
do { |
|||
//Emptys the standart output buffer to ensure that this function works in loops |
|||
//and returns the value of num after every loop |
|||
fflush(stdout); |
|||
|
|||
//fgets() reads the user input into the buffer storage (storage) |
|||
//the if condition is true as long as the input isn't empty |
|||
if (fgets(storage, sizeof storage, stdin) != NULL) { |
|||
//strtod() tries to convert the input into a double |
|||
//if there is anything but a number at any point of the array the pointer notANumber will point to this position |
|||
num = strtod(storage, ¬ANumber); |
|||
} |
|||
//isspace makes sure that notANumber doesn't point to an empty space |
|||
//the secount part makes sure that notANumber isn't pointing at 0 |
|||
} while (!isspace(*notANumber) && *notANumber != 0); |
|||
|
|||
return num; |
|||
} |
@ -0,0 +1,7 @@ |
|||
#ifndef TESTFORNUMBER |
|||
#define TESTFORNUMBER |
|||
|
|||
// get input and check if its a number |
|||
double testForNumber(); |
|||
|
|||
#endif // TESTFORNUMBER |
@ -0,0 +1,29 @@ |
|||
#include <stdio.h> |
|||
#include <string.h> |
|||
#include <stdlib.h> |
|||
#include <math.h> |
|||
#include <stdbool.h> |
|||
|
|||
#include "testForOperator.h" |
|||
|
|||
char testForOperator() { |
|||
//saving the number of operators in a variable so it only needs to be changed in one location |
|||
int numberOfOperators = 5; |
|||
//array where all valid Operators are saved, can be esily expanded |
|||
char oppArray[] = { '+','-','*','/','=' }; |
|||
char input; |
|||
bool validInput = false; |
|||
|
|||
//Loops as long as input isn't valid, enters at least one time |
|||
while (!validInput) { |
|||
scanf("%c\n", &input); |
|||
//checks every position of the array if a position is equal to input returns the input, which also stopps the function |
|||
for (int i = 0; i <= numberOfOperators; i++) { |
|||
if (input == oppArray[i]) { |
|||
return input; |
|||
} |
|||
} |
|||
//if the input was deemed invalid it asks for new input and goes to the top of the while loop |
|||
printf("The input was not allowed. Please try again!\n"); |
|||
} |
|||
} |
@ -0,0 +1,7 @@ |
|||
#ifndef TESTFOROPERATOR |
|||
#define TESTFOROPERATOR |
|||
|
|||
// get input and check if its a operator |
|||
char testForOperator(); |
|||
|
|||
#endif // TESTFOROPERATOR |
@ -0,0 +1,9 @@ |
|||
--- |
|||
src/main/c/main_calculator.c: |
|||
- TEST |
|||
src/main/c/testForOperator.c: |
|||
- TEST |
|||
src/main/c/testForNumber.c: |
|||
- TEST |
|||
src/main/c/programmingMode.c: |
|||
- TEST |
@ -0,0 +1,243 @@ |
|||
--- |
|||
:project: |
|||
:use_exceptions: false |
|||
:use_mocks: true |
|||
:compile_threads: 1 |
|||
:test_threads: 1 |
|||
:use_test_preprocessor: true |
|||
:use_preprocessor_directives: false |
|||
:use_deep_dependencies: false |
|||
:generate_deep_dependencies: true |
|||
:auto_link_deep_dependencies: false |
|||
:test_file_prefix: test_ |
|||
:options_paths: [] |
|||
:release_build: false |
|||
:use_auxiliary_dependencies: true |
|||
:build_root: target |
|||
:which_ceedling: gem |
|||
:ceedling_version: 0.31.1 |
|||
:default_tasks: |
|||
- test:all |
|||
:release_build: |
|||
:use_assembly: false |
|||
:artifacts: [] |
|||
:paths: |
|||
:test: |
|||
- "+:src/test/c/**" |
|||
- "-:src/test/c/support" |
|||
:source: |
|||
- "+:src/main/c/**" |
|||
:support: |
|||
- src/test/c/support |
|||
:include: [] |
|||
:libraries: [] |
|||
:test_toolchain_include: [] |
|||
:release_toolchain_include: [] |
|||
:files: |
|||
:test: [] |
|||
:source: [] |
|||
:assembly: [] |
|||
:support: [] |
|||
:include: [] |
|||
:environment: |
|||
- :rake_columns: '120' |
|||
:defines: |
|||
:test: |
|||
- &1 [] |
|||
- TEST |
|||
:test_preprocess: |
|||
- *1 |
|||
- TEST |
|||
:release: [] |
|||
:release_preprocess: [] |
|||
:use_test_definition: false |
|||
:common: [] |
|||
:libraries: |
|||
:flag: "-l${1}" |
|||
:path_flag: "-L ${1}" |
|||
:test: [] |
|||
:test_preprocess: [] |
|||
:release: [] |
|||
:release_preprocess: [] |
|||
:placement: :end |
|||
:system: |
|||
- m |
|||
:flags: {} |
|||
:extension: |
|||
:header: ".h" |
|||
:source: ".c" |
|||
:assembly: ".s" |
|||
:object: ".o" |
|||
:libraries: |
|||
- ".a" |
|||
- ".so" |
|||
:executable: ".out" |
|||
:map: ".map" |
|||
:list: ".lst" |
|||
:testpass: ".pass" |
|||
:testfail: ".fail" |
|||
:dependencies: ".d" |
|||
:unity: |
|||
:vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor" |
|||
:defines: [] |
|||
:cmock: |
|||
:vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor" |
|||
:defines: [] |
|||
:includes: [] |
|||
:mock_prefix: mock_ |
|||
:when_no_prototypes: :warn |
|||
:enforce_strict_ordering: true |
|||
:plugins: |
|||
- :ignore |
|||
- :callback |
|||
:treat_as: |
|||
uint8: HEX8 |
|||
uint16: HEX16 |
|||
uint32: UINT32 |
|||
int8: INT8 |
|||
bool: UINT8 |
|||
:mock_path: target/test/mocks |
|||
:verbosity: 3 |
|||
:unity_helper: false |
|||
:cexception: |
|||
:vendor_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor" |
|||
:defines: [] |
|||
:test_runner: |
|||
:includes: [] |
|||
:file_suffix: _runner |
|||
:tools: |
|||
:test_compiler: |
|||
:executable: gcc |
|||
:name: default_test_compiler |
|||
:stderr_redirect: :none |
|||
:background_exec: :none |
|||
:optional: false |
|||
:arguments: |
|||
- '' |
|||
- '' |
|||
- -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR |
|||
- -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE |
|||
- "-D$": COLLECTION_DEFINES_TEST_AND_VENDOR |
|||
- "-DGNU_COMPILER" |
|||
- "-g" |
|||
- '' |
|||
- -c "${1}" |
|||
- -o "${2}" |
|||
- "-MMD" |
|||
- -MF "${4}" |
|||
:test_fixture: |
|||
:executable: "${1}" |
|||
:name: default_test_fixture |
|||
:stderr_redirect: :auto |
|||
:background_exec: :none |
|||
:optional: false |
|||
:arguments: [] |
|||
:test_linker: |
|||
:executable: gcc |
|||
:name: default_test_linker |
|||
:stderr_redirect: :none |
|||
:background_exec: :none |
|||
:optional: false |
|||
:arguments: |
|||
- '' |
|||
- '' |
|||
- '' |
|||
- '"${1}"' |
|||
- "${5}" |
|||
- -o "${2}" |
|||
- '' |
|||
- "${4}" |
|||
- '' |
|||
:test_file_preprocessor: |
|||
:executable: gcc |
|||
:name: default_test_file_preprocessor |
|||
:stderr_redirect: :none |
|||
:background_exec: :none |
|||
:optional: false |
|||
:arguments: |
|||
- '' |
|||
- '' |
|||
- "-E" |
|||
- -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR |
|||
- -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE |
|||
- "-D$": COLLECTION_DEFINES_TEST_AND_VENDOR |
|||
- "-D$": DEFINES_TEST_PREPROCESS |
|||
- "-DGNU_COMPILER" |
|||
- '"${1}"' |
|||
- -o "${2}" |
|||
:test_file_preprocessor_directives: |
|||
:executable: gcc |
|||
:name: default_test_file_preprocessor_directives |
|||
:stderr_redirect: :none |
|||
:background_exec: :none |
|||
:optional: false |
|||
:arguments: |
|||
- "-E" |
|||
- -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR |
|||
- -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE |
|||
- "-D$": COLLECTION_DEFINES_TEST_AND_VENDOR |
|||
- "-D$": DEFINES_TEST_PREPROCESS |
|||
- "-DGNU_COMPILER" |
|||
- "-fdirectives-only" |
|||
- '"${1}"' |
|||
- -o "${2}" |
|||
:test_includes_preprocessor: |
|||
:executable: gcc |
|||
:name: default_test_includes_preprocessor |
|||
:stderr_redirect: :none |
|||
:background_exec: :none |
|||
:optional: false |
|||
:arguments: |
|||
- '' |
|||
- '' |
|||
- "-E" |
|||
- "-MM" |
|||
- "-MG" |
|||
- -I"$": COLLECTION_PATHS_TEST_SUPPORT_SOURCE_INCLUDE_VENDOR |
|||
- -I"$": COLLECTION_PATHS_TEST_TOOLCHAIN_INCLUDE |
|||
- "-D$": COLLECTION_DEFINES_TEST_AND_VENDOR |
|||
- "-D$": DEFINES_TEST_PREPROCESS |
|||
- "-DGNU_COMPILER" |
|||
- '"${1}"' |
|||
:test_compiler: |
|||
:arguments: [] |
|||
:test_linker: |
|||
:arguments: [] |
|||
:test_fixture: |
|||
:arguments: [] |
|||
:link_objects: [] |
|||
:test_includes_preprocessor: |
|||
:arguments: [] |
|||
:test_file_preprocessor: |
|||
:arguments: [] |
|||
:test_file_preprocessor_directives: |
|||
:arguments: [] |
|||
:test_dependencies_generator: |
|||
:arguments: [] |
|||
:release_compiler: |
|||
:arguments: [] |
|||
:release_linker: |
|||
:arguments: [] |
|||
:release_assembler: |
|||
:arguments: [] |
|||
:release_dependencies_generator: |
|||
:arguments: [] |
|||
:plugins: |
|||
:load_paths: |
|||
- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins" |
|||
:enabled: |
|||
- stdout_pretty_tests_report |
|||
- module_generator |
|||
:display_raw_test_results: false |
|||
:stdout_pretty_tests_report_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/stdout_pretty_tests_report" |
|||
:module_generator_path: "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/lib/../plugins/module_generator" |
|||
:gcov: |
|||
:reports: |
|||
- HtmlDetailed |
|||
:gcovr: |
|||
:html_medium_threshold: 75 |
|||
:html_high_threshold: 90 |
|||
:module_generator: |
|||
:project_root: "./" |
|||
:source_root: src/ |
|||
:test_root: test/ |
@ -0,0 +1,520 @@ |
|||
#include "src/main/c/programmingMode.h" |
|||
#include "src/main/c/testForNumber.h" |
|||
#include "src/main/c/testForOperator.h" |
|||
#include "src/main/c/main_calculator.h" |
|||
#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
|
|||
|
|||
|
|||
|
|||
void setUp(void) |
|||
|
|||
{ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void tearDown(void) |
|||
|
|||
{ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_addition(void) |
|||
|
|||
{ |
|||
|
|||
double result = add(1, 2); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((3)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(19), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_minus(void) |
|||
|
|||
{ |
|||
|
|||
double result = minus(3, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(25), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_multiply(void) |
|||
|
|||
{ |
|||
|
|||
double result = multiply(1, 2); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(31), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_divide(void) |
|||
|
|||
{ |
|||
|
|||
double result = divide(4, 2); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(37), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
|
|||
|
|||
double result1 = divide(4, 0); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result1)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(40), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConMeter(void) { |
|||
|
|||
double result = ConMeter(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0.5)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(45), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConMeterToFoot(void) { |
|||
|
|||
double result = ConMeterToFoot(5, 1, 0); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((16.4042)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(50), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
void test_ConKilometerToMiles(void) { |
|||
|
|||
double result = ConKilometerToMiles(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((8.04672)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(54), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConGram(void) { |
|||
|
|||
double result = ConGram(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0.005)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(59), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConGramToPounds(void) { |
|||
|
|||
double result = ConGramToPounds(5, 0, 0); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((11.0231)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(64), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConTemp(void) { |
|||
|
|||
double result = ConTemp(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((41)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(69), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConSpeed(void) { |
|||
|
|||
double result = ConSpeed(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((3.10686)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(74), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConLiter(void) { |
|||
|
|||
double result = ConLiter(5, 1, 0); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((5000)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(79), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConLiterToGallon(void) { |
|||
|
|||
double result = ConLiterToGallon(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((1.32086)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(84), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConData(void) { |
|||
|
|||
double result = ConData(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0.005)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(89), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConArea(void) { |
|||
|
|||
double result = ConData(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0.05)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(94), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConVolume(void) { |
|||
|
|||
double result = ConData(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0.005)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(99), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConClock(void) { |
|||
|
|||
double result = ConClock(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((5)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(104), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConTime(void) { |
|||
|
|||
double result = ConData(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0.005)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(109), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_squareRootFunction(void) { |
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((2.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((2.0))), (UNITY_FLOAT)((UNITY_FLOAT)((squareRootFunction(4.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(115))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_sineFunction(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((0.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((0.0))), (UNITY_FLOAT)((UNITY_FLOAT)((sineFunction(0.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(121))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_cosineFunction(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((1.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((1.0))), (UNITY_FLOAT)((UNITY_FLOAT)((cosineFunction(0.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(127))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_tangentFunction(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((0.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((0.0))), (UNITY_FLOAT)((UNITY_FLOAT)((tangentFunction(0.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(133))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_logarithmFunction(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((1.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((1.0))), (UNITY_FLOAT)((UNITY_FLOAT)((logarithmFunction(10.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(139))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_naturalLogarithmFunction(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((0.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((0.0))), (UNITY_FLOAT)((UNITY_FLOAT)((naturalLogarithmFunction(1.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(145))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_logarithmBase2Function(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((3.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((3.0))), (UNITY_FLOAT)((UNITY_FLOAT)((logarithmBase2Function(8.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(151))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_exponentialFunction(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((1.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((1.0))), (UNITY_FLOAT)((UNITY_FLOAT)((exponentialFunction(0.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(157))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_performOperation_Subtraction(void) { |
|||
|
|||
|
|||
|
|||
int result; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = performOperation(10, '-', 3); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((7)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(169), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_performOperation_Multiplication(void) { |
|||
|
|||
|
|||
|
|||
int result; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = performOperation(4, '*', 6); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((24)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(181), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_performOperation_Division(void) { |
|||
|
|||
|
|||
|
|||
int result; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = performOperation(8, '/', 2); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((4)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(193), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_performOperation_division_by_zero(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((performOperation(10, '/', 0))), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(199), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,6 @@ |
|||
target/test/out/c/cmock.o: \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.c \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock.h \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/cmock/src/cmock_internals.h \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
@ -0,0 +1,2 @@ |
|||
target/test/out/c/main_calculator.o: src/main/c/main_calculator.c \ |
|||
src/main/c/main_calculator.h |
@ -0,0 +1,2 @@ |
|||
target/test/out/c/programmingMode.o: src/main/c/programmingMode.c \ |
|||
src/main/c/programmingMode.h |
@ -0,0 +1,2 @@ |
|||
target/test/out/c/testForNumber.o: src/main/c/testForNumber.c \ |
|||
src/main/c/testForNumber.h |
@ -0,0 +1,2 @@ |
|||
target/test/out/c/testForOperator.o: src/main/c/testForOperator.c \ |
|||
src/main/c/testForOperator.h |
@ -0,0 +1,5 @@ |
|||
target/test/out/c/test_calculator.o: src/test/c/test_calculator.c \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ |
|||
src/main/c/main_calculator.h src/main/c/testForOperator.h \ |
|||
src/main/c/testForNumber.h src/main/c/programmingMode.h |
@ -0,0 +1,4 @@ |
|||
target/test/out/c/test_calculator_runner.o: \ |
|||
target/test/runners/test_calculator_runner.c \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
@ -0,0 +1,4 @@ |
|||
target/test/out/c/unity.o: \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.c \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|||
/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
@ -0,0 +1,520 @@ |
|||
#include "src/main/c/programmingMode.h" |
|||
#include "src/main/c/testForNumber.h" |
|||
#include "src/main/c/testForOperator.h" |
|||
#include "src/main/c/main_calculator.h" |
|||
#include "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
|
|||
|
|||
|
|||
|
|||
void setUp(void) |
|||
|
|||
{ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void tearDown(void) |
|||
|
|||
{ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_addition(void) |
|||
|
|||
{ |
|||
|
|||
double result = add(1, 2); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((3)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(19), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_minus(void) |
|||
|
|||
{ |
|||
|
|||
double result = minus(3, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(25), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_multiply(void) |
|||
|
|||
{ |
|||
|
|||
double result = multiply(1, 2); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(31), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_divide(void) |
|||
|
|||
{ |
|||
|
|||
double result = divide(4, 2); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((2)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(37), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
|
|||
|
|||
double result1 = divide(4, 0); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((result1)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(40), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConMeter(void) { |
|||
|
|||
double result = ConMeter(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0.5)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(45), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConMeterToFoot(void) { |
|||
|
|||
double result = ConMeterToFoot(5, 1, 0); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((16.4042)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(50), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
void test_ConKilometerToMiles(void) { |
|||
|
|||
double result = ConKilometerToMiles(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((8.04672)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(54), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConGram(void) { |
|||
|
|||
double result = ConGram(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0.005)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(59), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConGramToPounds(void) { |
|||
|
|||
double result = ConGramToPounds(5, 0, 0); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((11.0231)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(64), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConTemp(void) { |
|||
|
|||
double result = ConTemp(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((41)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(69), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConSpeed(void) { |
|||
|
|||
double result = ConSpeed(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((3.10686)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(74), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConLiter(void) { |
|||
|
|||
double result = ConLiter(5, 1, 0); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((5000)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(79), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConLiterToGallon(void) { |
|||
|
|||
double result = ConLiterToGallon(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((1.32086)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(84), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConData(void) { |
|||
|
|||
double result = ConData(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0.005)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(89), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConArea(void) { |
|||
|
|||
double result = ConData(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0.05)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(94), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConVolume(void) { |
|||
|
|||
double result = ConData(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0.005)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(99), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConClock(void) { |
|||
|
|||
double result = ConClock(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((5)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(104), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_ConTime(void) { |
|||
|
|||
double result = ConData(5, 0, 1); |
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0.005)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(109), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_squareRootFunction(void) { |
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((2.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((2.0))), (UNITY_FLOAT)((UNITY_FLOAT)((squareRootFunction(4.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(115))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_sineFunction(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((0.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((0.0))), (UNITY_FLOAT)((UNITY_FLOAT)((sineFunction(0.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(121))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_cosineFunction(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((1.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((1.0))), (UNITY_FLOAT)((UNITY_FLOAT)((cosineFunction(0.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(127))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_tangentFunction(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((0.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((0.0))), (UNITY_FLOAT)((UNITY_FLOAT)((tangentFunction(0.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(133))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_logarithmFunction(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((1.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((1.0))), (UNITY_FLOAT)((UNITY_FLOAT)((logarithmFunction(10.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(139))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_naturalLogarithmFunction(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((0.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((0.0))), (UNITY_FLOAT)((UNITY_FLOAT)((naturalLogarithmFunction(1.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(145))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_logarithmBase2Function(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((3.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((3.0))), (UNITY_FLOAT)((UNITY_FLOAT)((logarithmBase2Function(8.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(151))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_exponentialFunction(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((1.0)) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((1.0))), (UNITY_FLOAT)((UNITY_FLOAT)((exponentialFunction(0.0)))), (( |
|||
|
|||
((void *)0) |
|||
|
|||
)), (UNITY_UINT)((UNITY_UINT)(157))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_performOperation_Subtraction(void) { |
|||
|
|||
|
|||
|
|||
int result; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = performOperation(10, '-', 3); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((7)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(169), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_performOperation_Multiplication(void) { |
|||
|
|||
|
|||
|
|||
int result; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = performOperation(4, '*', 6); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((24)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(181), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_performOperation_Division(void) { |
|||
|
|||
|
|||
|
|||
int result; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
result = performOperation(8, '/', 2); |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((4)), (UNITY_INT)((result)), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(193), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_performOperation_division_by_zero(void) { |
|||
|
|||
|
|||
|
|||
UnityAssertEqualNumber((UNITY_INT)((0)), (UNITY_INT)((performOperation(10, '/', 0))), ( |
|||
|
|||
((void *)0) |
|||
|
|||
), (UNITY_UINT)(199), UNITY_DISPLAY_STYLE_INT); |
|||
|
|||
|
|||
|
|||
} |
@ -0,0 +1,6 @@ |
|||
--- |
|||
- "/var/lib/gems/3.0.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
- src/main/c/main_calculator.h |
|||
- src/main/c/testForOperator.h |
|||
- src/main/c/testForNumber.h |
|||
- src/main/c/programmingMode.h |
@ -0,0 +1,134 @@ |
|||
--- |
|||
:source: |
|||
:path: src/test/c |
|||
:file: test_calculator.c |
|||
:successes: |
|||
- :test: test_addition |
|||
:line: 16 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_minus |
|||
:line: 22 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_multiply |
|||
:line: 28 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_divide |
|||
:line: 34 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_ConMeter |
|||
:line: 43 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_ConMeterToFoot |
|||
:line: 48 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_ConKilometerToMiles |
|||
:line: 52 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_ConGram |
|||
:line: 57 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_ConGramToPounds |
|||
:line: 62 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_ConTemp |
|||
:line: 67 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_ConSpeed |
|||
:line: 72 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_ConLiter |
|||
:line: 77 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_ConLiterToGallon |
|||
:line: 82 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_ConData |
|||
:line: 87 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_ConArea |
|||
:line: 92 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_ConVolume |
|||
:line: 97 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_ConClock |
|||
:line: 102 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_ConTime |
|||
:line: 107 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_squareRootFunction |
|||
:line: 114 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_sineFunction |
|||
:line: 119 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_cosineFunction |
|||
:line: 125 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_tangentFunction |
|||
:line: 131 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_logarithmFunction |
|||
:line: 137 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_naturalLogarithmFunction |
|||
:line: 143 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_logarithmBase2Function |
|||
:line: 149 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_exponentialFunction |
|||
:line: 155 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_performOperation_Subtraction |
|||
:line: 161 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_performOperation_Multiplication |
|||
:line: 173 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_performOperation_Division |
|||
:line: 185 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_performOperation_division_by_zero |
|||
:line: 197 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
:failures: [] |
|||
:ignores: [] |
|||
:counts: |
|||
:total: 30 |
|||
:passed: 30 |
|||
:failed: 0 |
|||
:ignored: 0 |
|||
:stdout: [] |
|||
:time: 0.0015222660003928468 |
@ -0,0 +1,139 @@ |
|||
/* AUTOGENERATED FILE. DO NOT EDIT. */ |
|||
|
|||
/*=======Automagically Detected Files To Include=====*/ |
|||
#include "unity.h" |
|||
|
|||
int GlobalExpectCount; |
|||
int GlobalVerifyOrder; |
|||
char* GlobalOrderError; |
|||
|
|||
/*=======External Functions This Runner Calls=====*/ |
|||
extern void setUp(void); |
|||
extern void tearDown(void); |
|||
extern void test_addition(void); |
|||
extern void test_minus(void); |
|||
extern void test_multiply(void); |
|||
extern void test_divide(void); |
|||
extern void test_ConMeter(void); |
|||
extern void test_ConMeterToFoot(void); |
|||
extern void test_ConKilometerToMiles(void); |
|||
extern void test_ConGram(void); |
|||
extern void test_ConGramToPounds(void); |
|||
extern void test_ConTemp(void); |
|||
extern void test_ConSpeed(void); |
|||
extern void test_ConLiter(void); |
|||
extern void test_ConLiterToGallon(void); |
|||
extern void test_ConData(void); |
|||
extern void test_ConArea(void); |
|||
extern void test_ConVolume(void); |
|||
extern void test_ConClock(void); |
|||
extern void test_ConTime(void); |
|||
extern void test_squareRootFunction(void); |
|||
extern void test_sineFunction(void); |
|||
extern void test_cosineFunction(void); |
|||
extern void test_tangentFunction(void); |
|||
extern void test_logarithmFunction(void); |
|||
extern void test_naturalLogarithmFunction(void); |
|||
extern void test_logarithmBase2Function(void); |
|||
extern void test_exponentialFunction(void); |
|||
extern void test_performOperation_Subtraction(void); |
|||
extern void test_performOperation_Multiplication(void); |
|||
extern void test_performOperation_Division(void); |
|||
extern void test_performOperation_division_by_zero(void); |
|||
|
|||
|
|||
/*=======Mock Management=====*/ |
|||
static void CMock_Init(void) |
|||
{ |
|||
GlobalExpectCount = 0; |
|||
GlobalVerifyOrder = 0; |
|||
GlobalOrderError = NULL; |
|||
} |
|||
static void CMock_Verify(void) |
|||
{ |
|||
} |
|||
static void CMock_Destroy(void) |
|||
{ |
|||
} |
|||
|
|||
/*=======Test Reset Options=====*/ |
|||
void resetTest(void); |
|||
void resetTest(void) |
|||
{ |
|||
tearDown(); |
|||
CMock_Verify(); |
|||
CMock_Destroy(); |
|||
CMock_Init(); |
|||
setUp(); |
|||
} |
|||
void verifyTest(void); |
|||
void verifyTest(void) |
|||
{ |
|||
CMock_Verify(); |
|||
} |
|||
|
|||
/*=======Test Runner Used To Run Each Test=====*/ |
|||
static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num) |
|||
{ |
|||
Unity.CurrentTestName = name; |
|||
Unity.CurrentTestLineNumber = line_num; |
|||
#ifdef UNITY_USE_COMMAND_LINE_ARGS |
|||
if (!UnityTestMatches()) |
|||
return; |
|||
#endif |
|||
Unity.NumberOfTests++; |
|||
UNITY_CLR_DETAILS(); |
|||
UNITY_EXEC_TIME_START(); |
|||
CMock_Init(); |
|||
if (TEST_PROTECT()) |
|||
{ |
|||
setUp(); |
|||
func(); |
|||
} |
|||
if (TEST_PROTECT()) |
|||
{ |
|||
tearDown(); |
|||
CMock_Verify(); |
|||
} |
|||
CMock_Destroy(); |
|||
UNITY_EXEC_TIME_STOP(); |
|||
UnityConcludeTest(); |
|||
} |
|||
|
|||
/*=======MAIN=====*/ |
|||
int main(void) |
|||
{ |
|||
UnityBegin("test_calculator.c"); |
|||
run_test(test_addition, "test_addition", 16); |
|||
run_test(test_minus, "test_minus", 22); |
|||
run_test(test_multiply, "test_multiply", 28); |
|||
run_test(test_divide, "test_divide", 34); |
|||
run_test(test_ConMeter, "test_ConMeter", 43); |
|||
run_test(test_ConMeterToFoot, "test_ConMeterToFoot", 48); |
|||
run_test(test_ConKilometerToMiles, "test_ConKilometerToMiles", 52); |
|||
run_test(test_ConGram, "test_ConGram", 57); |
|||
run_test(test_ConGramToPounds, "test_ConGramToPounds", 62); |
|||
run_test(test_ConTemp, "test_ConTemp", 67); |
|||
run_test(test_ConSpeed, "test_ConSpeed", 72); |
|||
run_test(test_ConLiter, "test_ConLiter", 77); |
|||
run_test(test_ConLiterToGallon, "test_ConLiterToGallon", 82); |
|||
run_test(test_ConData, "test_ConData", 87); |
|||
run_test(test_ConArea, "test_ConArea", 92); |
|||
run_test(test_ConVolume, "test_ConVolume", 97); |
|||
run_test(test_ConClock, "test_ConClock", 102); |
|||
run_test(test_ConTime, "test_ConTime", 107); |
|||
run_test(test_squareRootFunction, "test_squareRootFunction", 114); |
|||
run_test(test_sineFunction, "test_sineFunction", 119); |
|||
run_test(test_cosineFunction, "test_cosineFunction", 125); |
|||
run_test(test_tangentFunction, "test_tangentFunction", 131); |
|||
run_test(test_logarithmFunction, "test_logarithmFunction", 137); |
|||
run_test(test_naturalLogarithmFunction, "test_naturalLogarithmFunction", 143); |
|||
run_test(test_logarithmBase2Function, "test_logarithmBase2Function", 149); |
|||
run_test(test_exponentialFunction, "test_exponentialFunction", 155); |
|||
run_test(test_performOperation_Subtraction, "test_performOperation_Subtraction", 161); |
|||
run_test(test_performOperation_Multiplication, "test_performOperation_Multiplication", 173); |
|||
run_test(test_performOperation_Division, "test_performOperation_Division", 185); |
|||
run_test(test_performOperation_division_by_zero, "test_performOperation_division_by_zero", 197); |
|||
|
|||
return UnityEnd(); |
|||
} |
@ -0,0 +1,6 @@ |
|||
- COMMITTER-NAME, FD-NUMMER |
|||
- Thomas Papendieck, fdai0127 |
|||
- fdai7782 (Jatin Saroay), fdai7782 |
|||
- Enrico Schellenberger, fdai7766 |
|||
- lukazieg, fdai7814 |
|||
- Kabrel, fdai7801 |
Write
Preview
Loading…
Cancel
Save
Reference in new issue