[oleaut32 2/2] Resend: Conformance test for varformat:VarWeekdayName
Benjamin Arai
me at benjaminarai.com
Tue Jul 25 21:10:29 CDT 2006
Skipped content of type multipart/alternative-------------- next part --------------
From db528321a1b2e400f5e01c0d8359e25b19637dd7 Mon Sep 17 00:00:00 2001
From: Benjamin Arai <me at benjaminarai.com>
Date: Tue, 25 Jul 2006 11:21:25 -0700
Subject: [PATCH] [oleaut32 2/2] Resend: Conformance test for varformat:VarWeekdayName
Requires 1/2 to build.
Changelog:
- Conformance test for VarWeekdayName
---
dlls/oleaut32/tests/vartest.c | 122 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 122 insertions(+), 0 deletions(-)
diff --git a/dlls/oleaut32/tests/vartest.c b/dlls/oleaut32/tests/vartest.c
index 3a14482..3185fb8 100644
--- a/dlls/oleaut32/tests/vartest.c
+++ b/dlls/oleaut32/tests/vartest.c
@@ -5665,6 +5665,127 @@ static void test_VarCmp(void)
SysFreeString(bstr1few);
}
+void test_VarWeekdayName(void)
+{
+ WCHAR day_LongFormat[][10] =
+ {
+ {'S','u','n','d','a','y',0},
+ {'M','o','n','d','a','y',0},
+ {'T','u','e','s','d','a','y',0},
+ {'W','e','d','n','e','s','d','a','y',0},
+ {'T','h','u','r','s','d','a','y',0},
+ {'F','r','i','d','a','y',0},
+ {'S','a','t','u','r','d','a','y',0}
+ };
+
+ WCHAR day_ShortFormat[][4] =
+ {
+ {'S','u','n',0},
+ {'M','o','n',0},
+ {'T','u','e',0},
+ {'W','e','d',0},
+ {'T','h','u',0},
+ {'F','r','i',0},
+ {'S','a','t',0}
+ };
+
+ HRESULT hres,expectedhres;
+ BSTR pbstrOut = NULL;
+ int iFirstDay,iWeekday,expectedDay;
+ static char expectedBuff[10];
+ static char resultBuff[10];
+
+ /* check all possible start days */
+ for (iFirstDay = 0; iFirstDay < 9; iFirstDay++)
+ {
+ /* Check all possible days */
+ for (iWeekday = 0; iWeekday < 9; iWeekday++)
+ {
+ expectedDay = (iFirstDay + iWeekday - 2) % 7;
+ if (iFirstDay == 0)
+ {
+ expectedDay += 1;
+ }
+
+ if ((iWeekday < 1) || (iWeekday > 7) ||
+ (iFirstDay < 0) || (iFirstDay > 7))
+ {
+ expectedhres = E_INVALIDARG;
+ }
+ else
+ {
+ expectedhres = S_OK;
+ }
+
+ /* Test long format day */
+ hres = VarWeekdayName(iWeekday, 0, iFirstDay, 0, &pbstrOut);
+
+ ok (hres == expectedhres,
+ "VarWeekdayName: Weekday=%d,Abbrev=0,FirstDay=%d, expected 0x%08lx, got 0x%08lx\n",
+ iWeekday,iFirstDay,expectedhres,hres);
+
+ /* if the hres is not S_OK then we don't care about the result */
+ if (hres == S_OK && expectedhres == S_OK)
+ {
+ WideCharToMultiByte(CP_ACP, 0, day_LongFormat[expectedDay],
+ -1,expectedBuff, sizeof(expectedBuff), NULL, NULL);
+ WideCharToMultiByte(CP_ACP,0,(WCHAR *)pbstrOut,-1,resultBuff,
+ sizeof(resultBuff), NULL, NULL);
+ ok(strcmpW(pbstrOut,day_LongFormat[expectedDay]) == 0,
+ "VarWeekdayName: Weekday=%d,Abbrev=0,FirstDay=%d, expected \"%s\" got \"%s\"\n",
+ iWeekday,iFirstDay,expectedBuff,resultBuff);
+ }
+ SysFreeString(pbstrOut);
+ pbstrOut = NULL;
+
+ /* Test short format day */
+ hres = VarWeekdayName(iWeekday, 1, iFirstDay,0, &pbstrOut);
+
+ ok (hres == expectedhres,
+ "VarWeekdayName: Weekday=%d,Abbrev=1,FirstDay=%d expected 0x%08lx, got 0x%08lx\n",
+ iWeekday,iFirstDay,expectedhres,hres);
+
+ /* if the hres is not S_OK then we don't care about the result */
+ if (hres == S_OK && expectedhres == S_OK)
+ {
+ WideCharToMultiByte(CP_ACP, 0, day_ShortFormat[expectedDay],
+ -1,expectedBuff, sizeof(expectedBuff), NULL, NULL);
+ WideCharToMultiByte(CP_ACP,0,(WCHAR *)pbstrOut,-1,resultBuff,
+ sizeof(resultBuff), NULL, NULL);
+ ok(strcmpW(pbstrOut,day_ShortFormat[expectedDay]) == 0,
+ "VarWeekdayName: Weekday=%d,Abbrev=1,FirstDay=%d, expected \"%s\" got \"%s\"\n",
+ iWeekday,iFirstDay,expectedBuff,resultBuff);
+ }
+ SysFreeString(pbstrOut);
+ pbstrOut = NULL;
+ }
+ }
+
+ /* test bad value for weekday */
+ hres = VarWeekdayName(-1, 0, 1, 0, &pbstrOut);
+ ok (hres == E_INVALIDARG,
+ "VarWeekdayName: Weekday=-1,Abbrev=0,FirstDay=1, expected 0x%08lx, got 0x%08lx\n",
+ E_INVALIDARG,hres);
+
+ SysFreeString(pbstrOut);
+ pbstrOut = NULL;
+
+ /* test bad value for first day */
+ hres = VarWeekdayName(1, 0, -1, 0, &pbstrOut);
+ ok (hres == E_INVALIDARG,
+ "VarWeekdayName: Weekday=1,Abbrev=0,FirstDay=-1, expected 0x%08lx, got 0x%08lx\n",
+ E_INVALIDARG,hres);
+
+ SysFreeString(pbstrOut);
+ pbstrOut = NULL;
+
+ /* test bad bstr */
+ hres = VarWeekdayName(1, 0, 1, 0, NULL);
+ ok (hres == E_INVALIDARG,
+ "VarWeekdayName: pbstrOut=NULL, expected 0x%08lx, got 0x%08lx\n",
+ E_INVALIDARG,hres);
+}
+
START_TEST(vartest)
{
hOleaut32 = LoadLibraryA("oleaut32.dll");
@@ -5698,4 +5819,5 @@ START_TEST(vartest)
test_VarAdd();
test_VarCat();
test_VarCmp();
+ test_VarWeekdayName();
}
--
1.4.0
More information about the wine-patches
mailing list