[GDI32] Do not 'hard-assert' during the font-unit-test.
authorHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 13 Apr 2019 23:17:15 +0000 (01:17 +0200)
committerHermès Bélusca-Maïto <hermes.belusca-maito@reactos.org>
Sat, 13 Apr 2019 23:17:15 +0000 (01:17 +0200)
win32ss/gdi/gdi32/objects/font.c

index 1b6cfa7..7a7c23b 100644 (file)
@@ -1340,7 +1340,7 @@ GetOutlineTextMetricsA(
     else
         output->otmpFullName = 0;
 
     else
         output->otmpFullName = 0;
 
-    assert(left == 0);
+    ASSERT(left == 0);
 
     if(output != lpOTM)
     {
 
     if(output != lpOTM)
     {
@@ -1730,6 +1730,13 @@ VOID DumpFamilyInfo(const FONTFAMILYINFO *Info, LONG Count)
 
 VOID DoFontSystemUnittest(VOID)
 {
 
 VOID DoFontSystemUnittest(VOID)
 {
+#ifndef RTL_SOFT_ASSERT
+#define RTL_SOFT_ASSERT(exp) \
+  (void)((!(exp)) ? \
+    DbgPrint("%s(%d): Soft assertion failed\n Expression: %s\n", __FILE__, __LINE__, #exp), FALSE : TRUE)
+#define RTL_SOFT_ASSERT_defined
+#endif
+
     LOGFONTW LogFont;
     FONTFAMILYINFO Info[4];
     UNICODE_STRING Str1, Str2;
     LOGFONTW LogFont;
     FONTFAMILYINFO Info[4];
     UNICODE_STRING Str1, Str2;
@@ -1744,8 +1751,8 @@ VOID DoFontSystemUnittest(VOID)
     ret = NtGdiGetFontFamilyInfo(NULL, &LogFont, Info, &InfoCount);
     DPRINT1("ret: %ld, InfoCount: %ld\n", ret, InfoCount);
     DumpFamilyInfo(Info, ret);
     ret = NtGdiGetFontFamilyInfo(NULL, &LogFont, Info, &InfoCount);
     DPRINT1("ret: %ld, InfoCount: %ld\n", ret, InfoCount);
     DumpFamilyInfo(Info, ret);
-    ASSERT(ret == RTL_NUMBER_OF(Info));
-    ASSERT(InfoCount > 32);
+    RTL_SOFT_ASSERT(ret == RTL_NUMBER_OF(Info));
+    RTL_SOFT_ASSERT(InfoCount > 32);
 
     /* L"Microsoft Sans Serif" ANSI_CHARSET */
     RtlZeroMemory(&LogFont, sizeof(LogFont));
 
     /* L"Microsoft Sans Serif" ANSI_CHARSET */
     RtlZeroMemory(&LogFont, sizeof(LogFont));
@@ -1755,19 +1762,19 @@ VOID DoFontSystemUnittest(VOID)
     ret = NtGdiGetFontFamilyInfo(NULL, &LogFont, Info, &InfoCount);
     DPRINT1("ret: %ld, InfoCount: %ld\n", ret, InfoCount);
     DumpFamilyInfo(Info, ret);
     ret = NtGdiGetFontFamilyInfo(NULL, &LogFont, Info, &InfoCount);
     DPRINT1("ret: %ld, InfoCount: %ld\n", ret, InfoCount);
     DumpFamilyInfo(Info, ret);
-    ASSERT(ret != -1);
-    ASSERT(InfoCount > 0);
-    ASSERT(InfoCount < 16);
+    RTL_SOFT_ASSERT(ret != -1);
+    RTL_SOFT_ASSERT(InfoCount > 0);
+    RTL_SOFT_ASSERT(InfoCount < 16);
 
     RtlInitUnicodeString(&Str1, Info[0].EnumLogFontEx.elfLogFont.lfFaceName);
     RtlInitUnicodeString(&Str2, L"Microsoft Sans Serif");
     ret = RtlCompareUnicodeString(&Str1, &Str2, TRUE);
 
     RtlInitUnicodeString(&Str1, Info[0].EnumLogFontEx.elfLogFont.lfFaceName);
     RtlInitUnicodeString(&Str2, L"Microsoft Sans Serif");
     ret = RtlCompareUnicodeString(&Str1, &Str2, TRUE);
-    ASSERT(ret == 0);
+    RTL_SOFT_ASSERT(ret == 0);
 
     RtlInitUnicodeString(&Str1, Info[0].EnumLogFontEx.elfFullName);
     RtlInitUnicodeString(&Str2, L"Tahoma");
     ret = RtlCompareUnicodeString(&Str1, &Str2, TRUE);
 
     RtlInitUnicodeString(&Str1, Info[0].EnumLogFontEx.elfFullName);
     RtlInitUnicodeString(&Str2, L"Tahoma");
     ret = RtlCompareUnicodeString(&Str1, &Str2, TRUE);
-    ASSERT(ret == 0);
+    RTL_SOFT_ASSERT(ret == 0);
 
     /* L"Non-Existent" DEFAULT_CHARSET */
     RtlZeroMemory(&LogFont, sizeof(LogFont));
 
     /* L"Non-Existent" DEFAULT_CHARSET */
     RtlZeroMemory(&LogFont, sizeof(LogFont));
@@ -1777,8 +1784,13 @@ VOID DoFontSystemUnittest(VOID)
     ret = NtGdiGetFontFamilyInfo(NULL, &LogFont, Info, &InfoCount);
     DPRINT1("ret: %ld, InfoCount: %ld\n", ret, InfoCount);
     DumpFamilyInfo(Info, ret);
     ret = NtGdiGetFontFamilyInfo(NULL, &LogFont, Info, &InfoCount);
     DPRINT1("ret: %ld, InfoCount: %ld\n", ret, InfoCount);
     DumpFamilyInfo(Info, ret);
-    ASSERT(ret == 0);
-    ASSERT(InfoCount == 0);
+    RTL_SOFT_ASSERT(ret == 0);
+    RTL_SOFT_ASSERT(InfoCount == 0);
+
+#ifdef RTL_SOFT_ASSERT_defined
+#undef RTL_SOFT_ASSERT_defined
+#undef RTL_SOFT_ASSERT
+#endif
 }
 #endif
 
 }
 #endif
 
@@ -1796,8 +1808,8 @@ CreateFontIndirectW(
     static BOOL bDidTest = FALSE;
     if (!bDidTest)
     {
     static BOOL bDidTest = FALSE;
     if (!bDidTest)
     {
-        DoFontSystemUnittest();
         bDidTest = TRUE;
         bDidTest = TRUE;
+        DoFontSystemUnittest();
     }
 #endif
     if (lplf)
     }
 #endif
     if (lplf)