fdlt3817
2 years ago
28 changed files with 35 additions and 659 deletions
-
6build/test/cache/defines_dependency.yml
-
159build/test/cache/test_currentCustomerAccountBalance.c
-
76build/test/cache/test_updateCustomerAccountBalance.c
-
3build/test/dependencies/currentCustomerAccountBalance.d
-
5build/test/dependencies/test_currentCustomerAccountBalance.d
-
4build/test/dependencies/test_currentCustomerAccountBalance_runner.d
-
5build/test/dependencies/test_updateCustomerAccountBalance.d
-
5build/test/dependencies/updateCustomerAccountBalance.d
-
BINbuild/test/out/c/currentCustomerAccountBalance.o
-
BINbuild/test/out/c/test_currentCustomerAccountBalance.o
-
BINbuild/test/out/c/test_currentCustomerAccountBalance_runner.o
-
BINbuild/test/out/c/test_updateCustomerAccountBalance.o
-
BINbuild/test/out/c/test_updateCustomerAccountBalance_runner.o
-
BINbuild/test/out/c/updateCustomerAccountBalance.o
-
BINbuild/test/out/test_currentCustomerAccountBalance.out
-
BINbuild/test/out/test_updateCustomerAccountBalance.out
-
159build/test/preprocess/files/test_currentCustomerAccountBalance.c
-
76build/test/preprocess/files/test_updateCustomerAccountBalance.c
-
3build/test/preprocess/includes/test_currentCustomerAccountBalance.c
-
4build/test/preprocess/includes/test_updateCustomerAccountBalance.c
-
30build/test/results/test_currentCustomerAccountBalance.pass
-
14build/test/results/test_updateCustomerAccountBalance.pass
-
87build/test/runners/test_currentCustomerAccountBalance_runner.c
-
36build/test/runners/test_updateCustomerAccountBalance_runner.c
-
2src/currentCustomerAccountBalance.h
-
8src/updateCustomerAccountBalance.c
-
2src/updateCustomerAccountBalance.h
-
10tests/test_updateCustomerAccountBalance.c
@ -1,5 +1 @@ |
|||
--- |
|||
src/currentCustomerAccountBalance.c: |
|||
- TEST |
|||
src/updateCustomerAccountBalance.c: |
|||
- TEST |
|||
--- {} |
@ -1,159 +0,0 @@ |
|||
#include "src/currentCustomerAccountBalance.h" |
|||
#include "/Library/Ruby/Gems/2.6.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void setUp(void) |
|||
|
|||
{ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void tearDown(void) |
|||
|
|||
{ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_fetchBalanceFromBalanceString(void) { |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
char balanceString[5][100] = { |
|||
|
|||
"balance=0", |
|||
|
|||
"balance=100", |
|||
|
|||
"balance=200", |
|||
|
|||
"balance=300", |
|||
|
|||
"balance=400" |
|||
|
|||
}; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
float balance = 0; |
|||
|
|||
float result[5]; |
|||
|
|||
float expected[5]; |
|||
|
|||
|
|||
|
|||
for (int i = 0; i < 5; i++) { |
|||
|
|||
result[i] = fetchBalanceFromBalanceString(balanceString[i]); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
for (int i = 0; i < 5; i++) { |
|||
|
|||
expected[i] = balance; |
|||
|
|||
balance += 100; |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
for (int i =0; i < 5; i++) { |
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((expected[i])) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((expected[i]))), (UNITY_FLOAT)((UNITY_FLOAT)((result[i]))), ((((void*)0))), (UNITY_UINT)((UNITY_UINT)(45))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_checkFileOpen(void) { |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
FILE *file = fopen("src/CustomerData.txt", "r"); |
|||
|
|||
|
|||
|
|||
do {if ((file)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(58)));}} while(0); |
|||
|
|||
|
|||
|
|||
fclose(file); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_failOpenFile(void) { |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
FILE *file = fopen("false_file_name", "r"); |
|||
|
|||
|
|||
|
|||
do {if (!(file)) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(69)));}} while(0); |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_getAvailableAccountBalance(void) { |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
int user_id = 1234; |
|||
|
|||
float max = 3.40282347e+38F; |
|||
|
|||
int result = getAvailableAccountBalance(user_id); |
|||
|
|||
|
|||
|
|||
do {if ((result < max)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(81)));}} while(0); |
|||
|
|||
} |
@ -1,77 +1 @@ |
|||
#include "src/updateCustomerAccountBalance.h" |
|||
#include "/Library/Ruby/Gems/2.6.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void setUp(void) |
|||
|
|||
{ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void tearDown(void) |
|||
|
|||
{ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_updateAvailableAccountBalanceSuccess(void){ |
|||
|
|||
int length = 10; |
|||
|
|||
|
|||
|
|||
float amountToUpdate[] = {200.5, 340, 244.5, 340, 1200, 3232, 1123, 460.5, 900, 1005}; |
|||
|
|||
float userIDs[] = {1001,1002,1003,1004,1005,1006,1007,1008,1009}; |
|||
|
|||
|
|||
|
|||
float expectedValue[length]; |
|||
|
|||
float result[length]; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
for (int i = 0; i < length; i++) { |
|||
|
|||
result[i] = updateAvailableAccountBalance(userIDs[i],amountToUpdate[i]); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
for (int i = 0; i < length; i++) { |
|||
|
|||
expectedValue[i] = 0; |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
for (int i = 0; i < length; i++) { |
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((expectedValue[i])) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((expectedValue[i]))), (UNITY_FLOAT)((UNITY_FLOAT)((result[i]))), ((((void*)0))), (UNITY_UINT)((UNITY_UINT)(58))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
} |
@ -1,3 +0,0 @@ |
|||
build/test/out/c/currentCustomerAccountBalance.o: \ |
|||
src/currentCustomerAccountBalance.c \ |
|||
src/currentCustomerAccountBalance.h src/_file_information.h |
@ -1,5 +0,0 @@ |
|||
build/test/out/c/test_currentCustomerAccountBalance.o: \ |
|||
tests/test_currentCustomerAccountBalance.c \ |
|||
/Library/Ruby/Gems/2.6.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|||
/Library/Ruby/Gems/2.6.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ |
|||
src/currentCustomerAccountBalance.h src/_file_information.h |
@ -1,4 +0,0 @@ |
|||
build/test/out/c/test_currentCustomerAccountBalance_runner.o: \ |
|||
build/test/runners/test_currentCustomerAccountBalance_runner.c \ |
|||
/Library/Ruby/Gems/2.6.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|||
/Library/Ruby/Gems/2.6.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h |
@ -1,5 +1,2 @@ |
|||
build/test/out/c/test_updateCustomerAccountBalance.o: \ |
|||
tests/test_updateCustomerAccountBalance.c \ |
|||
/Library/Ruby/Gems/2.6.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h \ |
|||
/Library/Ruby/Gems/2.6.0/gems/ceedling-0.31.1/vendor/unity/src/unity_internals.h \ |
|||
src/updateCustomerAccountBalance.h |
|||
tests/test_updateCustomerAccountBalance.c |
@ -1,5 +0,0 @@ |
|||
build/test/out/c/updateCustomerAccountBalance.o: \ |
|||
src/updateCustomerAccountBalance.c src/updateCustomerAccountBalance.h \ |
|||
src/currentCustomerAccountBalance.c \ |
|||
src/currentCustomerAccountBalance.h src/_file_information.h \ |
|||
src/lineReplacer.h |
@ -1,159 +0,0 @@ |
|||
#include "src/currentCustomerAccountBalance.h" |
|||
#include "/Library/Ruby/Gems/2.6.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void setUp(void) |
|||
|
|||
{ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void tearDown(void) |
|||
|
|||
{ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_fetchBalanceFromBalanceString(void) { |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
char balanceString[5][100] = { |
|||
|
|||
"balance=0", |
|||
|
|||
"balance=100", |
|||
|
|||
"balance=200", |
|||
|
|||
"balance=300", |
|||
|
|||
"balance=400" |
|||
|
|||
}; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
float balance = 0; |
|||
|
|||
float result[5]; |
|||
|
|||
float expected[5]; |
|||
|
|||
|
|||
|
|||
for (int i = 0; i < 5; i++) { |
|||
|
|||
result[i] = fetchBalanceFromBalanceString(balanceString[i]); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
for (int i = 0; i < 5; i++) { |
|||
|
|||
expected[i] = balance; |
|||
|
|||
balance += 100; |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
for (int i =0; i < 5; i++) { |
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((expected[i])) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((expected[i]))), (UNITY_FLOAT)((UNITY_FLOAT)((result[i]))), ((((void*)0))), (UNITY_UINT)((UNITY_UINT)(45))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void test_checkFileOpen(void) { |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
FILE *file = fopen("src/CustomerData.txt", "r"); |
|||
|
|||
|
|||
|
|||
do {if ((file)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(58)));}} while(0); |
|||
|
|||
|
|||
|
|||
fclose(file); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_failOpenFile(void) { |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
FILE *file = fopen("false_file_name", "r"); |
|||
|
|||
|
|||
|
|||
do {if (!(file)) {} else {UnityFail( ((" Expected FALSE Was TRUE")), (UNITY_UINT)((UNITY_UINT)(69)));}} while(0); |
|||
|
|||
|
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_getAvailableAccountBalance(void) { |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
int user_id = 1234; |
|||
|
|||
float max = 3.40282347e+38F; |
|||
|
|||
int result = getAvailableAccountBalance(user_id); |
|||
|
|||
|
|||
|
|||
do {if ((result < max)) {} else {UnityFail( ((" Expected TRUE Was FALSE")), (UNITY_UINT)((UNITY_UINT)(81)));}} while(0); |
|||
|
|||
} |
@ -1,77 +1 @@ |
|||
#include "src/updateCustomerAccountBalance.h" |
|||
#include "/Library/Ruby/Gems/2.6.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
void setUp(void) |
|||
|
|||
{ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void tearDown(void) |
|||
|
|||
{ |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
void test_updateAvailableAccountBalanceSuccess(void){ |
|||
|
|||
int length = 10; |
|||
|
|||
|
|||
|
|||
float amountToUpdate[] = {200.5, 340, 244.5, 340, 1200, 3232, 1123, 460.5, 900, 1005}; |
|||
|
|||
float userIDs[] = {1001,1002,1003,1004,1005,1006,1007,1008,1009}; |
|||
|
|||
|
|||
|
|||
float expectedValue[length]; |
|||
|
|||
float result[length]; |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
for (int i = 0; i < length; i++) { |
|||
|
|||
result[i] = updateAvailableAccountBalance(userIDs[i],amountToUpdate[i]); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
|
|||
for (int i = 0; i < length; i++) { |
|||
|
|||
expectedValue[i] = 0; |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
for (int i = 0; i < length; i++) { |
|||
|
|||
UnityAssertFloatsWithin((UNITY_FLOAT)((UNITY_FLOAT)((expectedValue[i])) * (UNITY_FLOAT)(0.00001f)), (UNITY_FLOAT)((UNITY_FLOAT)((expectedValue[i]))), (UNITY_FLOAT)((UNITY_FLOAT)((result[i]))), ((((void*)0))), (UNITY_UINT)((UNITY_UINT)(58))); |
|||
|
|||
} |
|||
|
|||
|
|||
|
|||
} |
@ -1,3 +0,0 @@ |
|||
--- |
|||
- "/Library/Ruby/Gems/2.6.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
- src/currentCustomerAccountBalance.h |
@ -1,3 +1 @@ |
|||
--- |
|||
- "/Library/Ruby/Gems/2.6.0/gems/ceedling-0.31.1/vendor/unity/src/unity.h" |
|||
- src/updateCustomerAccountBalance.h |
|||
--- [] |
@ -1,30 +0,0 @@ |
|||
--- |
|||
:source: |
|||
:path: tests |
|||
:file: test_currentCustomerAccountBalance.c |
|||
:successes: |
|||
- :test: test_fetchBalanceFromBalanceString |
|||
:line: 15 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_checkFileOpen |
|||
:line: 52 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_failOpenFile |
|||
:line: 63 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
- :test: test_getAvailableAccountBalance |
|||
:line: 73 |
|||
:message: '' |
|||
:unity_test_time: 0 |
|||
:failures: [] |
|||
:ignores: [] |
|||
:counts: |
|||
:total: 4 |
|||
:passed: 4 |
|||
:failed: 0 |
|||
:ignored: 0 |
|||
:stdout: [] |
|||
:time: 0.006680999998934567 |
@ -0,0 +1,14 @@ |
|||
--- |
|||
:source: |
|||
:path: tests |
|||
:file: test_updateCustomerAccountBalance.c |
|||
:successes: [] |
|||
:failures: [] |
|||
:ignores: [] |
|||
:counts: |
|||
:total: 0 |
|||
:passed: 0 |
|||
:failed: 0 |
|||
:ignored: 0 |
|||
:stdout: [] |
|||
:time: 0.006540999980643392 |
@ -1,87 +0,0 @@ |
|||
/* 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_fetchBalanceFromBalanceString(void); |
|||
extern void test_checkFileOpen(void); |
|||
extern void test_failOpenFile(void); |
|||
extern void test_getAvailableAccountBalance(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_currentCustomerAccountBalance.c"); |
|||
run_test(test_fetchBalanceFromBalanceString, "test_fetchBalanceFromBalanceString", 15); |
|||
run_test(test_checkFileOpen, "test_checkFileOpen", 52); |
|||
run_test(test_failOpenFile, "test_failOpenFile", 63); |
|||
run_test(test_getAvailableAccountBalance, "test_getAvailableAccountBalance", 73); |
|||
|
|||
return UnityEnd(); |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue