Provide compile time defines to initialize const variables
This commit is contained in:
@@ -311,6 +311,7 @@ STATIC int8_t createStubExpected(char *aNoSuffix, FILE *aFile, FILE *aHeader, cf
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
STATIC int8_t createStubGlobals(char *aNoSuffix, FILE *aFile, FILE *aHeader, cfile_variableList_t *aList)
|
||||
{
|
||||
cfile_variable_t *work = NULL;
|
||||
@@ -332,6 +333,16 @@ STATIC int8_t createStubGlobals(char *aNoSuffix, FILE *aFile, FILE *aHeader, cfi
|
||||
fprintf(aFile, "%s (%s)%s;"NEWLINES, work->dataType, work->name, (work->array ? work->array : ""));
|
||||
fprintf(aHeader, "extern %s (%s)%s;"NEWLINES, work->dataType, work->name, (work->array ? work->array : ""));
|
||||
}
|
||||
else if (CVARIABLE_CHECK_TYPE(work->type, CVARIABLE_TYPE_CONST))
|
||||
{
|
||||
fprintf(aFile, "%s %s%s = "STUBVARIABLE_INIT_S1";"NEWLINES, work->dataType, work->name, (work->array ? work->array : ""), work->name);
|
||||
fprintf(aHeader, "extern %s %s%s;"NEWLINES, work->dataType, work->name, (work->array ? work->array : ""));
|
||||
fprintf(aHeader, "#ifndef "STUBVARIABLE_INIT_S1""NEWLINES, work->name);
|
||||
// using zero-initialization rule {0} with any amount of dimensions for arrays
|
||||
fprintf(aHeader, "\t#define "STUBVARIABLE_INIT_S1" %s"NEWLINES, work->name,
|
||||
(work->array ? "{0}" : "("STUBDEFAULT_VALUE_VARIABLE_S")"));
|
||||
fprintf(aHeader, "#endif"NEWLINES NEWLINES);
|
||||
}
|
||||
else
|
||||
{
|
||||
fprintf(aFile, "%s %s%s;"NEWLINES, work->dataType, work->name, (work->array ? work->array : ""));
|
||||
@@ -885,8 +896,8 @@ STATIC void createUserFiles(char *aOutput, char *aNoSuffix, bool aVaList)
|
||||
{
|
||||
|
||||
fprintf(fileDesc, "/*! @file %s"NEWLINES, gnu_basename(cHeaderName));
|
||||
fprintf(fileDesc, " * @details"NEWLINES" * This is a user defined stub header.\\n"NEWLINES);
|
||||
fprintf(fileDesc, " * Define subject header needed for compilation of stub (e.g. typedefs, structures, ...).\\n"NEWLINES);
|
||||
fprintf(fileDesc, " * @details"NEWLINES" * This is a user defined stub header."NEWLINES);
|
||||
fprintf(fileDesc, " * Define subject header needed for compilation of stub (e.g. typedefs, structures, ...)."NEWLINES);
|
||||
fprintf(fileDesc, " * - generated by stubser %s -"NEWLINES" */" NEWLINES NEWLINES, GITVERSION);
|
||||
|
||||
fprintf(fileDesc, "#ifndef _STUB_%s_USER_H"NEWLINES, aNoSuffix);
|
||||
@@ -919,8 +930,8 @@ STATIC void createUserFiles(char *aOutput, char *aNoSuffix, bool aVaList)
|
||||
{
|
||||
|
||||
fprintf(fileDesc, "/*! @file %s"NEWLINES, gnu_basename(cFileName));
|
||||
fprintf(fileDesc, " * @details"NEWLINES" * This is a user defined stub.\\n"NEWLINES);
|
||||
fprintf(fileDesc, " * Define additional elements which need to be tested, or helper functions.\\n"NEWLINES);
|
||||
fprintf(fileDesc, " * @details"NEWLINES" * This is a user defined stub."NEWLINES);
|
||||
fprintf(fileDesc, " * Define additional elements which need to be tested, or helper functions."NEWLINES);
|
||||
fprintf(fileDesc, " * - generated by stubser %s -"NEWLINES" */" NEWLINES NEWLINES, GITVERSION);
|
||||
|
||||
fprintf(fileDesc, "#include <CUnit/CUnit.h>"NEWLINES);
|
||||
@@ -980,7 +991,7 @@ STATIC int8_t createStub(char *aOutput, char *aNoSuffix, cfile_t *aCfile)
|
||||
createUserFiles(aOutput, aNoSuffix, vaListAvailable);
|
||||
|
||||
fprintf(cfile, "/*! @file %s"NEWLINES, gnu_basename(cFileName));
|
||||
fprintf(cfile, " * @details"NEWLINES" * This is a stub for CUnit.\\n"NEWLINES);
|
||||
fprintf(cfile, " * @details"NEWLINES" * This is a stub for CUnit."NEWLINES);
|
||||
fprintf(cfile, " * - generated by stubser %s -"NEWLINES" */" NEWLINES NEWLINES, GITVERSION);
|
||||
fprintf(cfile, "#include <CUnit/CUnit.h>"NEWLINES);
|
||||
fprintf(cfile, "#include <stdint.h>"NEWLINES);
|
||||
@@ -998,7 +1009,7 @@ STATIC int8_t createStub(char *aOutput, char *aNoSuffix, cfile_t *aCfile)
|
||||
}
|
||||
|
||||
fprintf(cheader, "/*! @file %s"NEWLINES, gnu_basename(cHeaderName));
|
||||
fprintf(cheader, " * @details"NEWLINES" * This is a stub header.\\n"NEWLINES);
|
||||
fprintf(cheader, " * @details"NEWLINES" * This is a stub header."NEWLINES);
|
||||
fprintf(cheader, " * - generated by stubser %s -"NEWLINES" */" NEWLINES NEWLINES, GITVERSION);
|
||||
|
||||
fprintf(cheader, "#ifndef _STUB_%s_H"NEWLINES, aNoSuffix);
|
||||
|
||||
@@ -60,6 +60,7 @@
|
||||
#define STUBFUNCTION_CHECK_S1 "stub_%s_checkGlobals" // stub_testfunction_checkGlobals
|
||||
#define STUBFUNCTION_INIT_S1 "stub_%s_init" // stub_testfunction_init
|
||||
#define STUBVARIABLE_EXPECTED_S1 "%s_expected" // variable_expected
|
||||
#define STUBVARIABLE_INIT_S1 "%s_INIT" // variable_init (used for const variables)
|
||||
|
||||
#define STUB_CONSOLE_GOBACK "\033[2K\r"
|
||||
#define STUB_CONSOLE_RUN "[ ]"
|
||||
|
||||
Reference in New Issue
Block a user