Browse Source

Merge branch 'develop' with master

master
fdai7782 11 months ago
parent
commit
6b5bc058dd
  1. 16
      .vscode/c_cpp_properties.json
  2. 24
      .vscode/launch.json
  3. 9
      .vscode/settings.json
  4. 1
      Unity
  5. 12
      project.yml
  6. 66
      src/main/c/BasicMode.c
  7. 10
      src/main/c/BasicMode.h
  8. 258
      src/main/c/ConvertMode.c
  9. 1358
      src/main/c/main_calculator.c
  10. 83
      src/main/c/main_calculator.h
  11. 99
      src/main/c/programmingMode.c
  12. 8
      src/main/c/programmingMode.h
  13. 156
      src/main/c/scientificMode.c
  14. 31
      src/main/c/testForNumber.c
  15. 7
      src/main/c/testForNumber.h
  16. 29
      src/main/c/testForOperator.c
  17. 7
      src/main/c/testForOperator.h
  18. 0
      src/test/c/support/.gitkeep
  19. 243
      src/test/c/test_calculator.c
  20. 9
      target/test/cache/defines_dependency.yml
  21. 243
      target/test/cache/input.yml
  22. 520
      target/test/cache/test_calculator.c
  23. 6
      target/test/dependencies/cmock.d
  24. 0
      target/test/dependencies/force_build
  25. 2
      target/test/dependencies/main_calculator.d
  26. 2
      target/test/dependencies/programmingMode.d
  27. 2
      target/test/dependencies/testForNumber.d
  28. 2
      target/test/dependencies/testForOperator.d
  29. 5
      target/test/dependencies/test_calculator.d
  30. 4
      target/test/dependencies/test_calculator_runner.d
  31. 4
      target/test/dependencies/unity.d
  32. BIN
      target/test/out/c/cmock.o
  33. BIN
      target/test/out/c/main_calculator.o
  34. BIN
      target/test/out/c/programmingMode.o
  35. BIN
      target/test/out/c/testForNumber.o
  36. BIN
      target/test/out/c/testForOperator.o
  37. BIN
      target/test/out/c/test_calculator.o
  38. BIN
      target/test/out/c/test_calculator_runner.o
  39. BIN
      target/test/out/c/unity.o
  40. BIN
      target/test/out/test_calculator.out
  41. 520
      target/test/preprocess/files/test_calculator.c
  42. 6
      target/test/preprocess/includes/test_calculator.c
  43. 134
      target/test/results/test_calculator.pass
  44. 139
      target/test/runners/test_calculator_runner.c
  45. 6
      teams.md

16
.vscode/c_cpp_properties.json

@ -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
}

24
.vscode/launch.json

@ -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
}
]
}
]
}

9
.vscode/settings.json

@ -0,0 +1,9 @@
{
"C_Cpp.errorSquiggles": "disabled",
"files.associations": {
"testforoperator.h": "c",
"testfornumber.h": "c",
"programmingmode.h": "c"
},
"C_Cpp_Runner.msvcBatchPath": ""
}

1
Unity

@ -0,0 +1 @@
Subproject commit 134496c6c0c34b463d58daef1904a12abdc5c8e0

12
project.yml

@ -91,6 +91,7 @@
:system:
- m # Example: add 'm' to use the math library
:test:
<<<<<<< HEAD
- stdio
- string
- stdlib
@ -100,6 +101,17 @@
- string
- stdlib
- m # Example: add 'm' to use the math library in release builds
=======
#- stdio
#- string
#- stdlib
#- m # Example: add 'm' to use the math library in tests
:release:
#- stdio
#- string
#- stdlib
#- m # Example: add 'm' to use the math library in release builds
>>>>>>> develop
:plugins:
:load_paths:

66
src/main/c/BasicMode.c

@ -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;
}

10
src/main/c/BasicMode.h

@ -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

258
src/main/c/ConvertMode.c

@ -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

83
src/main/c/main_calculator.h

@ -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

99
src/main/c/programmingMode.c

@ -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;
}

8
src/main/c/programmingMode.h

@ -0,0 +1,8 @@
#ifndef PROGRAMMINGMODE
#define PROGRAMMINGMODE
// to test some calculations
int performOperation(int num1, char operatorType, int num2);
#endif // PROGRAMMINGMODE

156
src/main/c/scientificMode.c

@ -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;
}

31
src/main/c/testForNumber.c

@ -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, &notANumber);
}
//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;
}

7
src/main/c/testForNumber.h

@ -0,0 +1,7 @@
#ifndef TESTFORNUMBER
#define TESTFORNUMBER
// get input and check if its a number
double testForNumber();
#endif // TESTFORNUMBER

29
src/main/c/testForOperator.c

@ -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");
}
}

7
src/main/c/testForOperator.h

@ -0,0 +1,7 @@
#ifndef TESTFOROPERATOR
#define TESTFOROPERATOR
// get input and check if its a operator
char testForOperator();
#endif // TESTFOROPERATOR

0
src/test/c/support/.gitkeep

243
src/test/c/test_calculator.c

@ -1,8 +1,11 @@
#ifdef TEST
#include "unity.h"
#include "BasicMode.h"
#include "main_calculator.h"
#include "testForOperator.h"
#include "testForNumber.h"
#include "programmingMode.h"
#include "calculator.h"
void setUp(void)
{
@ -25,3 +28,239 @@ void test_addition(void)
}
#endif // TEST
double result = add(1, 2);
TEST_ASSERT_EQUAL(3, result);
}
void test_minus(void)
{
double result = minus(3, 1);
TEST_ASSERT_EQUAL(2, result);
}
void test_multiply(void)
{
double result = multiply(1, 2);
TEST_ASSERT_EQUAL(2, result);
}
void test_divide(void)
{
double result = divide(4, 2);
TEST_ASSERT_EQUAL(2, result);
double 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(0.5, result);
}
void test_ConMeterToFoot(void) {//5 m to foot
double result = ConMeterToFoot(5, 1, 0);
TEST_ASSERT_EQUAL(16.4042, result);
}
void test_ConKilometerToMiles(void) {//5 miles to km
double result = ConKilometerToMiles(5, 0, 1);
TEST_ASSERT_EQUAL(8.04672, result);
}
void test_ConGram(void) {//5 mg to g
double result = ConGram(5, 0, 1);
TEST_ASSERT_EQUAL(0.005, result);
}
void test_ConGramToPounds(void) {//5 kg to pounds
double result = ConGramToPounds(5, 0, 0);
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 = ConSpeed(5, 0, 1);
TEST_ASSERT_EQUAL(3.10686, result);
}
void test_ConLiter(void) {//5 l to ml
double result = ConLiter(5, 1, 0);
TEST_ASSERT_EQUAL(5000, result);
}
void test_ConLiterToGallon(void) {//5 l to gallon
double result = ConLiterToGallon(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 = ConClock(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);
}
// Test case for dividing by zero
void test_performOperation_division_by_zero(void) {
TEST_ASSERT_EQUAL_INT(0, performOperation(10, '/', 0));
}
void test_DecToBin(void) {
// Arrange
long long int result;
// Act
result = DecToBin(8);
// Assert
TEST_ASSERT_EQUAL_INT64(100, result);
}
void test_BinToDec(void) {
// Arrange
long long int result;
// Act
result = BinToDec(100);
// Assert
TEST_ASSERT_EQUAL_INT64(8, result);
}
void test_additionbin(void) {
// Arrange
long long int result;
// Act
result = additionbin(1,1);
// Assert
TEST_ASSERT_EQUAL_INT64(10, result);
}
void test_multiplicationbin(void) {
// Arrange
long long int result;
// Act
result = multiplicationbin(1,10);
// Assert
TEST_ASSERT_EQUAL_INT64(10, result);
}
void test_subtractionbin(void) {
// Arrange
long long int result;
// Act
result = subtractionbin(100,10);
// Assert
TEST_ASSERT_EQUAL_INT64(10, result);
}

9
target/test/cache/defines_dependency.yml

@ -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

243
target/test/cache/input.yml

@ -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/

520
target/test/cache/test_calculator.c

@ -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);
}

6
target/test/dependencies/cmock.d

@ -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
target/test/dependencies/force_build

2
target/test/dependencies/main_calculator.d

@ -0,0 +1,2 @@
target/test/out/c/main_calculator.o: src/main/c/main_calculator.c \
src/main/c/main_calculator.h

2
target/test/dependencies/programmingMode.d

@ -0,0 +1,2 @@
target/test/out/c/programmingMode.o: src/main/c/programmingMode.c \
src/main/c/programmingMode.h

2
target/test/dependencies/testForNumber.d

@ -0,0 +1,2 @@
target/test/out/c/testForNumber.o: src/main/c/testForNumber.c \
src/main/c/testForNumber.h

2
target/test/dependencies/testForOperator.d

@ -0,0 +1,2 @@
target/test/out/c/testForOperator.o: src/main/c/testForOperator.c \
src/main/c/testForOperator.h

5
target/test/dependencies/test_calculator.d

@ -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

4
target/test/dependencies/test_calculator_runner.d

@ -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

4
target/test/dependencies/unity.d

@ -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

BIN
target/test/out/c/cmock.o

BIN
target/test/out/c/main_calculator.o

BIN
target/test/out/c/programmingMode.o

BIN
target/test/out/c/testForNumber.o

BIN
target/test/out/c/testForOperator.o

BIN
target/test/out/c/test_calculator.o

BIN
target/test/out/c/test_calculator_runner.o

BIN
target/test/out/c/unity.o

BIN
target/test/out/test_calculator.out

520
target/test/preprocess/files/test_calculator.c

@ -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);
}

6
target/test/preprocess/includes/test_calculator.c

@ -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

134
target/test/results/test_calculator.pass

@ -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

139
target/test/runners/test_calculator_runner.c

@ -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();
}

6
teams.md

@ -0,0 +1,6 @@
- COMMITTER-NAME, FD-NUMMER
- Thomas Papendieck, fdai0127
- fdai7782 (Jatin Saroay), fdai7782
- Enrico Schellenberger, fdai7766
- lukazieg, fdai7814
- Kabrel, fdai7801
Loading…
Cancel
Save