mirror of
https://github.com/CloverHackyColor/CloverBootloader.git
synced 2024-11-12 09:54:36 +01:00
Fix VS compilation.
This commit is contained in:
parent
d075078a48
commit
a71fe28d34
@ -1887,9 +1887,9 @@ NOOPT_VS2017_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
|
|||||||
RELEASE_VS2017_X64_NASM_FLAGS = -Ox -f win64
|
RELEASE_VS2017_X64_NASM_FLAGS = -Ox -f win64
|
||||||
NOOPT_VS2017_X64_NASM_FLAGS = -O0 -f win64 -g
|
NOOPT_VS2017_X64_NASM_FLAGS = -O0 -f win64 -g
|
||||||
|
|
||||||
DEBUG_VS2017_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
DEBUG_VS2017_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /IGNORE:4210 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
||||||
RELEASE_VS2017_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
|
RELEASE_VS2017_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /IGNORE:4254 /IGNORE:4210 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.rdata=.data
|
||||||
NOOPT_VS2017_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
NOOPT_VS2017_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4281 /OPT:REF /IGNORE:4210 /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:X64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
|
||||||
|
|
||||||
#################
|
#################
|
||||||
# ARM definitions
|
# ARM definitions
|
||||||
|
@ -9,6 +9,10 @@
|
|||||||
#ifndef Platform_h_h
|
#ifndef Platform_h_h
|
||||||
#define Platform_h_h
|
#define Platform_h_h
|
||||||
|
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#include <Windows.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
@ -34,9 +38,12 @@ typedef uint16_t char16_t;
|
|||||||
#define IN
|
#define IN
|
||||||
#define OUT
|
#define OUT
|
||||||
|
|
||||||
|
#ifndef TRUE
|
||||||
#define TRUE true
|
#define TRUE true
|
||||||
|
#endif
|
||||||
|
#ifndef FALSE
|
||||||
#define FALSE false
|
#define FALSE false
|
||||||
|
#endif
|
||||||
#define VA_LIST va_list
|
#define VA_LIST va_list
|
||||||
#define VA_START va_start
|
#define VA_START va_start
|
||||||
#define VA_END va_end
|
#define VA_END va_end
|
||||||
|
@ -6,7 +6,11 @@
|
|||||||
|
|
||||||
#define xsize size_t
|
#define xsize size_t
|
||||||
//#define xisize INTN
|
//#define xisize INTN
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
#define MAX_XSIZE SIZE_MAX
|
||||||
|
#else
|
||||||
#define MAX_XSIZE SIZE_T_MAX
|
#define MAX_XSIZE SIZE_T_MAX
|
||||||
|
#endif
|
||||||
//#define MAX_XISIZE MAX_INTN
|
//#define MAX_XISIZE MAX_INTN
|
||||||
|
|
||||||
#define XStringGrowByDefault 10
|
#define XStringGrowByDefault 10
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
#ifndef __cplusplus
|
#ifndef __cplusplus
|
||||||
#ifdef _MSC_VER
|
#ifdef _MSC_VER
|
||||||
typedef UINT16 wchar_t;
|
typedef uint16_t wchar_t;
|
||||||
#endif
|
#endif
|
||||||
typedef uint32_t char32_t;
|
typedef uint32_t char32_t;
|
||||||
typedef uint16_t char16_t;
|
typedef uint16_t char16_t;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
//
|
//
|
||||||
//#endif
|
//#endif
|
||||||
|
|
||||||
|
#if defined(CLOVER_BUILD) || !defined(_MSC_VER)
|
||||||
void abort(void)
|
void abort(void)
|
||||||
{
|
{
|
||||||
printf("A fatal error happened. System halted\n");
|
printf("A fatal error happened. System halted\n");
|
||||||
@ -27,7 +28,7 @@ void abort(void)
|
|||||||
CpuDeadLoop();
|
CpuDeadLoop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool stop_at_panic = true;
|
bool stop_at_panic = true;
|
||||||
bool i_have_panicked = false;
|
bool i_have_panicked = false;
|
||||||
|
@ -222,8 +222,8 @@ protected:
|
|||||||
size_t m_allocatedSize;
|
size_t m_allocatedSize;
|
||||||
|
|
||||||
// convenience method. Did it this way to avoid #define in header. They can have an impact on other headers
|
// convenience method. Did it this way to avoid #define in header. They can have an impact on other headers
|
||||||
size_t min(size_t x1, size_t x2) const { if ( x1 < x2 ) return x1; return x2; }
|
size_t Xmin(size_t x1, size_t x2) const { if ( x1 < x2 ) return x1; return x2; }
|
||||||
size_t max(size_t x1, size_t x2) const { if ( x1 > x2 ) return x1; return x2; }
|
size_t Xmax(size_t x1, size_t x2) const { if ( x1 > x2 ) return x1; return x2; }
|
||||||
|
|
||||||
// Methods _data is protected intentionally. They are const method returning non-const pointer. That's intentional, but dangerous. Do not expose to public.
|
// Methods _data is protected intentionally. They are const method returning non-const pointer. That's intentional, but dangerous. Do not expose to public.
|
||||||
// If you need a non-const pointer for low-level access, to use dataSized and have to specify the size
|
// If you need a non-const pointer for low-level access, to use dataSized and have to specify the size
|
||||||
@ -385,7 +385,7 @@ public:
|
|||||||
char32_t operator [](IntegralType i) const { return char32At(i); }
|
char32_t operator [](IntegralType i) const { return char32At(i); }
|
||||||
|
|
||||||
|
|
||||||
char32_t LastChar() const { if ( length() > 0 ) return char32At(length()-1); else return 0; }
|
char32_t lastChar() const { if ( length() > 0 ) return char32At(length()-1); else return 0; }
|
||||||
|
|
||||||
//--------------------------------------------------------------------- strcat, strcpy, operator =
|
//--------------------------------------------------------------------- strcat, strcpy, operator =
|
||||||
/* strncpy */
|
/* strncpy */
|
||||||
|
@ -809,8 +809,8 @@ SimpleString teststrcat_(const InitialValue& initialValue, const ValueToCat& val
|
|||||||
} \
|
} \
|
||||||
} \
|
} \
|
||||||
|
|
||||||
#define min(x,y) ( (x) < (y) ? (x) : (y) )
|
#define Xmin(x,y) ( (x) < (y) ? (x) : (y) )
|
||||||
#define max(x,y) ( (x) > (y) ? (x) : (y) )
|
#define Xmax(x,y) ( (x) > (y) ? (x) : (y) )
|
||||||
|
|
||||||
/***************************** strncat *****************************/
|
/***************************** strncat *****************************/
|
||||||
template<class XStringClass, class InitialValue, class ValueToCat>
|
template<class XStringClass, class InitialValue, class ValueToCat>
|
||||||
@ -1304,6 +1304,38 @@ SimpleString testindexOf_(const InitialValue& initialValue)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/***************************** lastChar *****************************/
|
||||||
|
template<class XStringClass, class InitialValue>
|
||||||
|
SimpleString testlastChar_(const InitialValue& initialValue)
|
||||||
|
{
|
||||||
|
TEST_TITLE(displayOnlyFailed, ssprintf("Test %s::lastChar(%s\"%s\"", XStringClassInfo<XStringClass>::xStringClassName, XStringClassInfo<InitialValue>::prefix, SimpleString(initialValue.cha).c_str()));
|
||||||
|
|
||||||
|
// typedef typename XStringClassInfo<XStringClass>::ch_t ch_t;
|
||||||
|
// ch_t c; // dummy for call utf function
|
||||||
|
|
||||||
|
XStringClass str;
|
||||||
|
str.takeValueFrom(initialValue.cha);
|
||||||
|
|
||||||
|
char32_t expectedChar = 0;
|
||||||
|
if ( initialValue.utf32_length > 0) expectedChar = initialValue.utf32[initialValue.utf32_length-1];
|
||||||
|
|
||||||
|
char32_t char32 = str.lastChar();
|
||||||
|
|
||||||
|
CHECK_RESULT(char32 == expectedChar,
|
||||||
|
ssprintf("char32 == expectedChar (%d)", expectedChar),
|
||||||
|
ssprintf("char32 == expectedChar (%d!=%d)", char32, expectedChar)
|
||||||
|
);
|
||||||
|
|
||||||
|
return SimpleString();
|
||||||
|
}
|
||||||
|
|
||||||
|
#define testlastChar(XStringClass, classEncoding) \
|
||||||
|
printf("Test %s::testlastChar\n", STRINGIFY(XStringClass)); \
|
||||||
|
for ( size_t i = 0 ; i < nbTestStringMultiCoded ; i++ ) { \
|
||||||
|
testlastChar_<XStringClass>(testStringMultiCodedArray[i].classEncoding); \
|
||||||
|
} \
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/***************************** *****************************/
|
/***************************** *****************************/
|
||||||
#undef realloc
|
#undef realloc
|
||||||
@ -1335,7 +1367,7 @@ XStringW xw1("c"_XS);
|
|||||||
|
|
||||||
char c = 1;
|
char c = 1;
|
||||||
int ii = sizeof(size_t);
|
int ii = sizeof(size_t);
|
||||||
unsigned long long ull = SIZE_T_MAX;
|
unsigned long long ull = 1;
|
||||||
unsigned long long ll = 3;
|
unsigned long long ll = 3;
|
||||||
xw1.dataSized(c);
|
xw1.dataSized(c);
|
||||||
xw1.dataSized(ii);
|
xw1.dataSized(ii);
|
||||||
@ -1374,6 +1406,22 @@ size_t utf32_size = sizeof(U"ギ") - 1; (void)utf32_size; // this char is 6 b
|
|||||||
//XString str = "ギꇉ伽楘"_XS;
|
//XString str = "ギꇉ伽楘"_XS;
|
||||||
//char* s = str.data(42);
|
//char* s = str.data(42);
|
||||||
|
|
||||||
|
//size_t size1 = sizeof("В")-1;
|
||||||
|
//size_t size2 = sizeof("ы")-1;
|
||||||
|
//size_t size3 = sizeof("х")-1;
|
||||||
|
//size_t size4 = sizeof("о")-1;
|
||||||
|
//size_t size5 = sizeof("д")-1;
|
||||||
|
#ifdef _MSC_VER
|
||||||
|
//SetConsoleOutputCP(65001);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
printf("%s", "Выход \n");
|
||||||
|
XString ddd = "Выход "_XS;
|
||||||
|
printf(" xstring %s, asize=%zu, sizeinbyte=%zu sizeof=%zu lastcharat=%zu\n", ddd.c_str(), ddd.allocatedSize(), ddd.sizeInBytes(), sizeof(ddd), ddd.indexOf(ddd.lastChar()));
|
||||||
|
|
||||||
|
TestString<char> ts1 = TestString<char>(nbchar("Выход "), "Выход ", nbchar(PREFIX_U("Выход ")), PREFIX_U("Выход "));
|
||||||
|
testlastChar_<XString>(ts1);
|
||||||
|
|
||||||
|
|
||||||
//teststrncpy_<XString>("utf8", testStringMultiCodedArray[1].utf8, testStringMultiCodedArray[1].wchar);
|
//teststrncpy_<XString>("utf8", testStringMultiCodedArray[1].utf8, testStringMultiCodedArray[1].wchar);
|
||||||
//testindexOf(XString, utf8, utf16);
|
//testindexOf(XString, utf8, utf16);
|
||||||
@ -1399,6 +1447,8 @@ testCompare(XString, utf8, utf16);
|
|||||||
TEST_ALL_CLASSES(testCompare, TEST_ALL_UTF);
|
TEST_ALL_CLASSES(testCompare, TEST_ALL_UTF);
|
||||||
TEST_ALL_CLASSES(testindexOf, TEST_ALL_UTF);
|
TEST_ALL_CLASSES(testindexOf, TEST_ALL_UTF);
|
||||||
|
|
||||||
|
TEST_ALL_CLASSES(testlastChar, __TEST0);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
//
|
||||||
|
8
rEFIt_UEFI/cpp_unit_test/poolprint-test.cpp
Normal file → Executable file
8
rEFIt_UEFI/cpp_unit_test/poolprint-test.cpp
Normal file → Executable file
@ -93,21 +93,21 @@ static int testWPrintf(const char* label, const wchar_t* expectResult, int expe
|
|||||||
|
|
||||||
#define Test1arg(expectResult,format,c) \
|
#define Test1arg(expectResult,format,c) \
|
||||||
{ \
|
{ \
|
||||||
char label[1024]; \
|
/* char label[1024]; // Visual studio generates __chkstk if declared here */\
|
||||||
snprintf(label, sizeof(label), F("Test swprintf(%s, %s)"), F(#format), F(#c)); \
|
snprintf(label, sizeof(label), F("Test swprintf(%s, %s)"), F(#format), F(#c)); \
|
||||||
testWPrintf(label,L##expectResult,(int)wcslen(L##expectResult),L##format,c); \
|
testWPrintf(label,L##expectResult,(int)wcslen(L##expectResult),L##format,c); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define Test2arg(expectResult,format,c,d) \
|
#define Test2arg(expectResult,format,c,d) \
|
||||||
{ \
|
{ \
|
||||||
char label[1024]; \
|
/* char label[1024]; // Visual studio generates __chkstk if declared here */\
|
||||||
snprintf(label, sizeof(label), F("Test swprintf(%s, %s, %s)"), F(#format), F(#c), F(#d)); \
|
snprintf(label, sizeof(label), F("Test swprintf(%s, %s, %s)"), F(#format), F(#c), F(#d)); \
|
||||||
testWPrintf(label,L##expectResult,(int)wcslen(L##expectResult),L##format,c,d); \
|
testWPrintf(label,L##expectResult,(int)wcslen(L##expectResult),L##format,c,d); \
|
||||||
}
|
}
|
||||||
|
|
||||||
#define Test5arg(expectResult,format,c,d,e,f,g) \
|
#define Test5arg(expectResult,format,c,d,e,f,g) \
|
||||||
{ \
|
{ \
|
||||||
char label[1024]; \
|
/* char label[1024]; // Visual studio generates __chkstk if declared here */\
|
||||||
snprintf(label, sizeof(label), F("Test swprintf(%s, %s, %s, %s, %s, %s)"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
snprintf(label, sizeof(label), F("Test swprintf(%s, %s, %s, %s, %s, %s)"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
||||||
testWPrintf(label,L##expectResult,(int)wcslen(L##expectResult),L##format,c,d,e,f,g); \
|
testWPrintf(label,L##expectResult,(int)wcslen(L##expectResult),L##format,c,d,e,f,g); \
|
||||||
}
|
}
|
||||||
@ -115,6 +115,8 @@ static int testWPrintf(const char* label, const wchar_t* expectResult, int expe
|
|||||||
|
|
||||||
int poolprint_tests(void)
|
int poolprint_tests(void)
|
||||||
{
|
{
|
||||||
|
char label[1024]; // to avoid __chkstk problem in Visual studio, label is declared here to be used in TestArg macros
|
||||||
|
|
||||||
#ifdef DISPLAY_START_INFO
|
#ifdef DISPLAY_START_INFO
|
||||||
loggf(F("\n"));
|
loggf(F("\n"));
|
||||||
loggf(F("Printf unit test\n"));
|
loggf(F("Printf unit test\n"));
|
||||||
|
@ -106,7 +106,7 @@ static int testWPrintf(const char* label, const wchar_t* expectResult, int expe
|
|||||||
|
|
||||||
#define Test1arg(expectResult,format,c) \
|
#define Test1arg(expectResult,format,c) \
|
||||||
{ \
|
{ \
|
||||||
char label[1024]; \
|
/* char label[1024]; // Visual studio generates __chkstk if declared here */\
|
||||||
snprintf(label, sizeof(label), F("Test sprintf(" PRIF ", " PRIF ")"), F(#format), F(#c)); \
|
snprintf(label, sizeof(label), F("Test sprintf(" PRIF ", " PRIF ")"), F(#format), F(#c)); \
|
||||||
testPrintf(label,expectResult,(int)strlen(expectResult),format,c); \
|
testPrintf(label,expectResult,(int)strlen(expectResult),format,c); \
|
||||||
snprintf(label, sizeof(label), F("Test swprintf(" PRIF ", " PRIF ")"), F(#format), F(#c)); \
|
snprintf(label, sizeof(label), F("Test swprintf(" PRIF ", " PRIF ")"), F(#format), F(#c)); \
|
||||||
@ -115,7 +115,7 @@ static int testWPrintf(const char* label, const wchar_t* expectResult, int expe
|
|||||||
|
|
||||||
#define Test2arg(expectResult,format,c,d) \
|
#define Test2arg(expectResult,format,c,d) \
|
||||||
{ \
|
{ \
|
||||||
char label[1024]; \
|
/* char label[1024]; // Visual studio generates __chkstk if declared here */\
|
||||||
snprintf(label, sizeof(label), F("Test sprintf(" PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d)); \
|
snprintf(label, sizeof(label), F("Test sprintf(" PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d)); \
|
||||||
testPrintf(label,expectResult,(int)strlen(expectResult),format,c,d); \
|
testPrintf(label,expectResult,(int)strlen(expectResult),format,c,d); \
|
||||||
snprintf(label, sizeof(label), F("Test swprintf(" PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d)); \
|
snprintf(label, sizeof(label), F("Test swprintf(" PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d)); \
|
||||||
@ -124,7 +124,7 @@ static int testWPrintf(const char* label, const wchar_t* expectResult, int expe
|
|||||||
|
|
||||||
#define Test5arg(expectResult,format,c,d,e,f,g) \
|
#define Test5arg(expectResult,format,c,d,e,f,g) \
|
||||||
{ \
|
{ \
|
||||||
char label[1024]; \
|
/* char label[1024]; // Visual studio generates __chkstk if declared here */\
|
||||||
snprintf(label, sizeof(label), F("Test sprintf(" PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
snprintf(label, sizeof(label), F("Test sprintf(" PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
||||||
testPrintf(label,expectResult,(int)strlen(expectResult),format,c,d,e,f,g); \
|
testPrintf(label,expectResult,(int)strlen(expectResult),format,c,d,e,f,g); \
|
||||||
snprintf(label, sizeof(label), F("Test swprintf(" PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
snprintf(label, sizeof(label), F("Test swprintf(" PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
||||||
@ -133,7 +133,7 @@ static int testWPrintf(const char* label, const wchar_t* expectResult, int expe
|
|||||||
|
|
||||||
#define TestLen5arg(expectResult,expectedRet,format,c,d,e,f,g) \
|
#define TestLen5arg(expectResult,expectedRet,format,c,d,e,f,g) \
|
||||||
{ \
|
{ \
|
||||||
char label[1024]; \
|
/* char label[1024]; // Visual studio generates __chkstk if declared here */\
|
||||||
snprintf(label, sizeof(label), F("Test sprintf(" PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
snprintf(label, sizeof(label), F("Test sprintf(" PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
||||||
testPrintf(label,expectResult,expectedRet,format,c,d,e,f,g); \
|
testPrintf(label,expectResult,expectedRet,format,c,d,e,f,g); \
|
||||||
snprintf(label, sizeof(label), F("Test swprintf(" PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
snprintf(label, sizeof(label), F("Test swprintf(" PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ", " PRIF ")"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
||||||
@ -143,6 +143,8 @@ static int testWPrintf(const char* label, const wchar_t* expectResult, int expe
|
|||||||
|
|
||||||
int printf_lite_tests(void)
|
int printf_lite_tests(void)
|
||||||
{
|
{
|
||||||
|
char label[1024]; // to avoid __chkstk problem in Visual studio, label is declared here to be used in TestArg macros
|
||||||
|
|
||||||
#ifdef DISPLAY_START_INFO
|
#ifdef DISPLAY_START_INFO
|
||||||
loggf(F("\n"));
|
loggf(F("\n"));
|
||||||
loggf(F("Printf unit test\n"));
|
loggf(F("Printf unit test\n"));
|
||||||
@ -198,7 +200,6 @@ int printf_lite_tests(void)
|
|||||||
//printf("%ls %r\n", "foo", 1);
|
//printf("%ls %r\n", "foo", 1);
|
||||||
|
|
||||||
//testWPrintf("", F(L"Āࠀ𐀀🧊Выход'utf16'из"), F("Āࠀ𐀀🧊Выход'%s'из"), "utf16");
|
//testWPrintf("", F(L"Āࠀ𐀀🧊Выход'utf16'из"), F("Āࠀ𐀀🧊Выход'%s'из"), "utf16");
|
||||||
|
|
||||||
Test1arg(F("'utf8-string'"), F("'%s'"), "utf8-string");
|
Test1arg(F("'utf8-string'"), F("'%s'"), "utf8-string");
|
||||||
Test1arg(F("'utf16-string'"), F("'%ls'"), L"utf16-string");
|
Test1arg(F("'utf16-string'"), F("'%ls'"), L"utf16-string");
|
||||||
Test1arg(F("Āࠀ𐀀🧊Выход'utf8'из"), F("Āࠀ𐀀🧊Выход'%s'из"), "utf8");
|
Test1arg(F("Āࠀ𐀀🧊Выход'utf8'из"), F("Āࠀ𐀀🧊Выход'%s'из"), "utf8");
|
||||||
@ -294,14 +295,13 @@ int printf_lite_tests(void)
|
|||||||
Test1arg(F("| -12|"), F("|%5d|"), -12);
|
Test1arg(F("| -12|"), F("|%5d|"), -12);
|
||||||
Test1arg(F("| -12|"), F("|%5ld|"), -12L);
|
Test1arg(F("| -12|"), F("|%5ld|"), -12L);
|
||||||
Test1arg(F("| -12|"), F("|%5lld|"), -12LL);
|
Test1arg(F("| -12|"), F("|%5lld|"), -12LL);
|
||||||
|
|
||||||
Test1arg(F("| 244|"), F("|%5hhu|"), (signed char)-12);
|
Test1arg(F("| 244|"), F("|%5hhu|"), (signed char)-12);
|
||||||
Test1arg(F("|4294967284|"), F("|%5u|"), (signed char)-12);
|
Test1arg(F("|4294967284|"), F("|%5u|"), (signed char)-12);
|
||||||
Test1arg(F("|65524|"), F("|%5hu|"), (short)-12);
|
Test1arg(F("|65524|"), F("|%5hu|"), (short)-12);
|
||||||
Test1arg(F("|4294967284|"), F("|%5u|"), -12);
|
Test1arg(F("|4294967284|"), F("|%5u|"), -12);
|
||||||
Test1arg(F("|18446744073709551604|"), F("|%5lu|"), -12L);
|
Test1arg(F("|18446744073709551604|"), F("|%5lu|"), -12L);
|
||||||
Test1arg(F("|18446744073709551604|"), F("|%5llu|"), -12LL);
|
Test1arg(F("|18446744073709551604|"), F("|%5llu|"), -12LL);
|
||||||
|
|
||||||
Test1arg(F("| f4|"), F("|%5hhx|"), (signed char)-12);
|
Test1arg(F("| f4|"), F("|%5hhx|"), (signed char)-12);
|
||||||
Test1arg(F("|fffffff4|"), F("|%5x|"), (signed char)-12);
|
Test1arg(F("|fffffff4|"), F("|%5x|"), (signed char)-12);
|
||||||
Test1arg(F("| fff4|"), F("|%5hx|"), (short)-12);
|
Test1arg(F("| fff4|"), F("|%5hx|"), (short)-12);
|
||||||
|
@ -108,7 +108,7 @@ static int testWPrintf(const char* label, const wchar_t* expectResult, int expe
|
|||||||
|
|
||||||
#define Test1arg(expectResult,format,c) \
|
#define Test1arg(expectResult,format,c) \
|
||||||
{ \
|
{ \
|
||||||
char label[1024]; \
|
/* char label[1024]; // Visual studio generates __chkstk if declared here */\
|
||||||
snprintf(label, sizeof(label), F("Test AsciiVSPrint(%s, %s)"), F(#format), F(#c)); \
|
snprintf(label, sizeof(label), F("Test AsciiVSPrint(%s, %s)"), F(#format), F(#c)); \
|
||||||
testPrintf(label,expectResult,(int)strlen(expectResult),format,c); \
|
testPrintf(label,expectResult,(int)strlen(expectResult),format,c); \
|
||||||
snprintf(label, sizeof(label), F("Test UnicodeVSPrint(%s, %s)"), F(#format), F(#c)); \
|
snprintf(label, sizeof(label), F("Test UnicodeVSPrint(%s, %s)"), F(#format), F(#c)); \
|
||||||
@ -117,7 +117,7 @@ static int testWPrintf(const char* label, const wchar_t* expectResult, int expe
|
|||||||
|
|
||||||
#define Test2arg(expectResult,format,c,d) \
|
#define Test2arg(expectResult,format,c,d) \
|
||||||
{ \
|
{ \
|
||||||
char label[1024]; \
|
/* char label[1024]; // Visual studio generates __chkstk if declared here */\
|
||||||
snprintf(label, sizeof(label), F("Test AsciiVSPrint(%s, %s, %s)"), F(#format), F(#c), F(#d)); \
|
snprintf(label, sizeof(label), F("Test AsciiVSPrint(%s, %s, %s)"), F(#format), F(#c), F(#d)); \
|
||||||
testPrintf(label,expectResult,(int)strlen(expectResult),format,c,d); \
|
testPrintf(label,expectResult,(int)strlen(expectResult),format,c,d); \
|
||||||
snprintf(label, sizeof(label), F("Test UnicodeVSPrint(%s, %s, %s)"), F(#format), F(#c), F(#d)); \
|
snprintf(label, sizeof(label), F("Test UnicodeVSPrint(%s, %s, %s)"), F(#format), F(#c), F(#d)); \
|
||||||
@ -126,7 +126,7 @@ static int testWPrintf(const char* label, const wchar_t* expectResult, int expe
|
|||||||
|
|
||||||
#define Test5arg(expectResult,format,c,d,e,f,g) \
|
#define Test5arg(expectResult,format,c,d,e,f,g) \
|
||||||
{ \
|
{ \
|
||||||
char label[1024]; \
|
/* char label[1024]; // Visual studio generates __chkstk if declared here */\
|
||||||
snprintf(label, sizeof(label), F("Test AsciiVSPrint(%s, %s, %s, %s, %s, %s)"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
snprintf(label, sizeof(label), F("Test AsciiVSPrint(%s, %s, %s, %s, %s, %s)"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
||||||
testPrintf(label,expectResult,(int)strlen(expectResult),format,c,d,e,f,g); \
|
testPrintf(label,expectResult,(int)strlen(expectResult),format,c,d,e,f,g); \
|
||||||
snprintf(label, sizeof(label), F("Test UnicodeVSPrint(%s, %s, %s, %s, %s, %s)"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
snprintf(label, sizeof(label), F("Test UnicodeVSPrint(%s, %s, %s, %s, %s, %s)"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
||||||
@ -135,7 +135,7 @@ static int testWPrintf(const char* label, const wchar_t* expectResult, int expe
|
|||||||
|
|
||||||
#define TestLen5arg(expectResult,expectedRet,format,c,d,e,f,g) \
|
#define TestLen5arg(expectResult,expectedRet,format,c,d,e,f,g) \
|
||||||
{ \
|
{ \
|
||||||
char label[1024]; \
|
/* char label[1024]; // Visual studio generates __chkstk if declared here */\
|
||||||
snprintf(label, sizeof(label), F("Test AsciiVSPrint(%s, %s, %s, %s, %s, %s)"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
snprintf(label, sizeof(label), F("Test AsciiVSPrint(%s, %s, %s, %s, %s, %s)"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
||||||
testPrintf(label,expectResult,expectedRet,format,c,d,e,f,g); \
|
testPrintf(label,expectResult,expectedRet,format,c,d,e,f,g); \
|
||||||
snprintf(label, sizeof(label), F("Test UnicodeVSPrint(%s, %s, %s, %s, %s, %s)"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
snprintf(label, sizeof(label), F("Test UnicodeVSPrint(%s, %s, %s, %s, %s, %s)"), F(#format), F(#c), F(#d), F(#e), F(#f), F(#g)); \
|
||||||
@ -146,6 +146,8 @@ static int testWPrintf(const char* label, const wchar_t* expectResult, int expe
|
|||||||
|
|
||||||
int printlib_tests(void)
|
int printlib_tests(void)
|
||||||
{
|
{
|
||||||
|
char label[1024]; // to avoid __chkstk problem in Visual studio, label is declared here to be used in TestArg macros
|
||||||
|
|
||||||
#ifdef DISPLAY_START_INFO
|
#ifdef DISPLAY_START_INFO
|
||||||
loggf(F("\n"));
|
loggf(F("\n"));
|
||||||
loggf(F("Printf unit test\n"));
|
loggf(F("Printf unit test\n"));
|
||||||
@ -234,8 +236,13 @@ int printlib_tests(void)
|
|||||||
Test1arg(F("|FFFFFFF6|"), F("|%0X|"), -10);
|
Test1arg(F("|FFFFFFF6|"), F("|%0X|"), -10);
|
||||||
Test1arg(F("| FFFFFFF6|"), F("|%20x|"), -10);
|
Test1arg(F("| FFFFFFF6|"), F("|%20x|"), -10);
|
||||||
Test1arg(F("|FFFFFFF6|"), F("|%lx|"), -10);
|
Test1arg(F("|FFFFFFF6|"), F("|%lx|"), -10);
|
||||||
|
#if LONG_MAX == UINT32_MAX
|
||||||
|
Test1arg(F("|FFFFFFF6|"), F("|%lX|"), -10L);
|
||||||
|
Test1arg(F("|000000000000FFFFFFF6|"), F("|%20lX|"), -10L);
|
||||||
|
#else
|
||||||
Test1arg(F("|FFFFFFFFFFFFFFF6|"), F("|%lX|"), -10L);
|
Test1arg(F("|FFFFFFFFFFFFFFF6|"), F("|%lX|"), -10L);
|
||||||
Test1arg(F("|0000FFFFFFFFFFFFFFF6|"), F("|%20lX|"), -10L);
|
Test1arg(F("|0000FFFFFFFFFFFFFFF6|"), F("|%20lX|"), -10L);
|
||||||
|
#endif
|
||||||
|
|
||||||
// test with specifier, space as pad char
|
// test with specifier, space as pad char
|
||||||
Test1arg(F("| 0|"), F("|%5d|"), 0);
|
Test1arg(F("| 0|"), F("|%5d|"), 0);
|
||||||
@ -274,7 +281,11 @@ int printlib_tests(void)
|
|||||||
Test1arg(F("|80123456|"), F("|%07X|"), 0xFFFFFFFF80123456);
|
Test1arg(F("|80123456|"), F("|%07X|"), 0xFFFFFFFF80123456);
|
||||||
Test1arg(F("|080123456|"), F("|%09X|"), 0xFFFFFFFF80123456);
|
Test1arg(F("|080123456|"), F("|%09X|"), 0xFFFFFFFF80123456);
|
||||||
Test1arg(F("|00000000000080123456|"), F("|%020X|"), 0xFFFFFFFF80123456);
|
Test1arg(F("|00000000000080123456|"), F("|%020X|"), 0xFFFFFFFF80123456);
|
||||||
Test1arg(F("|0000FFFFFFFF80123456|"), F("|%020lX|"), 0xFFFFFFFF80123456);
|
#if LONG_MAX == UINT32_MAX
|
||||||
|
Test1arg(F("|0000FFFFFFFF80123456|"), F("|%020lX|"), 0xFFFFFFFF80123456UL);
|
||||||
|
#else
|
||||||
|
Test1arg(F("|0000FFFFFFFF80123456|"), F("|%020lX|"), 0xFFFFFFFF80123456UL);
|
||||||
|
#endif
|
||||||
|
|
||||||
// test limits
|
// test limits
|
||||||
int16_t i;
|
int16_t i;
|
||||||
|
Loading…
Reference in New Issue
Block a user