* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
-#include <stdarg.h>
-#include <stdio.h>
-#include <math.h>
-#include <float.h>
-
-#include "windef.h"
-#include "winbase.h"
-#include "winsock.h"
-#include "wine/test.h"
-#include "winuser.h"
-#include "wingdi.h"
-#include "winnls.h"
-#include "winerror.h"
-#include "winnt.h"
-
-#include "wtypes.h"
-#include "oleauto.h"
+#define WIN32_NO_STATUS
+#define _INC_WINDOWS
+#define COM_NO_WINDOWS_H
+
+//#include <stdarg.h>
+//#include <stdio.h>
+//#include <math.h>
+//#include <float.h>
+
+//#include "windef.h"
+//#include "winbase.h"
+//#include "winsock.h"
+#include <wine/test.h>
+//#include "winuser.h"
+//#include "wingdi.h"
+#include <winnls.h>
+//#include "winerror.h"
+//#include "winnt.h"
+#include <objbase.h>
+//#include "wtypes.h"
+#include <oleauto.h>
static HMODULE hOleaut32;
static HRESULT (WINAPI *pVarFormat)(LPVARIANT,LPOLESTR,int,int,ULONG,BSTR*);
static HRESULT (WINAPI *pVarWeekdayName)(int,int,int,ULONG,BSTR*);
-/* Have I8/UI8 data type? */
-#define HAVE_OLEAUT32_I8 HAVE_FUNC(VarI8FromI1)
-
-/* Is a given function exported from oleaut32? */
-#define HAVE_FUNC(func) ((void*)GetProcAddress(hOleaut32, #func) != NULL)
+/* Has I8/UI8 data type? */
+static BOOL has_i8;
/* Get a conversion function ptr, return if function not available */
#define CHECKPTR(func) p##func = (void*)GetProcAddress(hOleaut32, #func); \
FMT_NUMBER(VT_UI2, V_UI2);
FMT_NUMBER(VT_I4, V_I4);
FMT_NUMBER(VT_UI4, V_UI4);
- if (HAVE_OLEAUT32_I8)
+ if (has_i8)
{
FMT_NUMBER(VT_I8, V_I8);
FMT_NUMBER(VT_UI8, V_UI8);
VNUMFMT(VT_I1,V_I1);
VNUMFMT(VT_I2,V_I2);
VNUMFMT(VT_I4,V_I4);
- if (HAVE_OLEAUT32_I8)
+ if (has_i8)
{
VNUMFMT(VT_I8,V_I8);
}
VNUMFMT(VT_UI1,V_UI1);
VNUMFMT(VT_UI2,V_UI2);
VNUMFMT(VT_UI4,V_UI4);
- if (HAVE_OLEAUT32_I8)
+ if (has_i8)
{
VNUMFMT(VT_UI8,V_UI8);
}
}
}
+static void test_VarFormatFromTokens(void)
+{
+ static WCHAR number_fmt[] = {'#','#','#',',','#','#','0','.','0','0',0};
+ static const WCHAR number[] = {'6',',','9','0',0};
+ static const WCHAR number_us[] = {'6','9','0','.','0','0',0};
+
+ static WCHAR date_fmt[] = {'d','d','-','m','m',0};
+ static const WCHAR date[] = {'1','2','-','1','1',0};
+ static const WCHAR date_us[] = {'1','1','-','1','2',0};
+
+ static WCHAR string_fmt[] = {'@',0};
+ static const WCHAR string_de[] = {'1',',','5',0};
+ static const WCHAR string_us[] = {'1','.','5',0};
+
+ BYTE buff[256];
+ LCID lcid;
+ VARIANT var;
+ BSTR bstr;
+ HRESULT hres;
+
+ V_VT(&var) = VT_BSTR;
+ V_BSTR(&var) = SysAllocString(number);
+
+ lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
+ hres = VarTokenizeFormatString(number_fmt, buff, sizeof(buff), 1, 1, lcid, NULL);
+ ok(hres == S_OK, "VarTokenizeFormatString failed: %x\n", hres);
+ hres = VarFormatFromTokens(&var, number_fmt, buff, 0, &bstr, lcid);
+ ok(hres == S_OK, "VarFormatFromTokens failed: %x\n", hres);
+ ok(!strcmpW(bstr, number_us), "incorrectly formatted number: %s\n", wine_dbgstr_w(bstr));
+ SysFreeString(bstr);
+
+ lcid = MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT);
+ hres = VarTokenizeFormatString(number_fmt, buff, sizeof(buff), 1, 1, lcid, NULL);
+ ok(hres == S_OK, "VarTokenizeFormatString failed: %x\n", hres);
+ hres = VarFormatFromTokens(&var, number_fmt, buff, 0, &bstr, lcid);
+ ok(hres == S_OK, "VarFormatFromTokens failed: %x\n", hres);
+ ok(!strcmpW(bstr, number), "incorrectly formatted number: %s\n", wine_dbgstr_w(bstr));
+ SysFreeString(bstr);
+
+ VariantClear(&var);
+
+ V_VT(&var) = VT_BSTR;
+ V_BSTR(&var) = SysAllocString(date);
+
+ lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
+ hres = VarTokenizeFormatString(date_fmt, buff, sizeof(buff), 1, 1, lcid, NULL);
+ ok(hres == S_OK, "VarTokenizeFormatString failed: %x\n", hres);
+ hres = VarFormatFromTokens(&var, date_fmt, buff, 0, &bstr, lcid);
+ ok(hres == S_OK, "VarFormatFromTokens failed: %x\n", hres);
+ ok(!strcmpW(bstr, date_us), "incorrectly formatted date: %s\n", wine_dbgstr_w(bstr));
+ SysFreeString(bstr);
+
+ lcid = MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT);
+ hres = VarTokenizeFormatString(date_fmt, buff, sizeof(buff), 1, 1, lcid, NULL);
+ ok(hres == S_OK, "VarTokenizeFormatString failed: %x\n", hres);
+ hres = VarFormatFromTokens(&var, date_fmt, buff, 0, &bstr, lcid);
+ ok(hres == S_OK, "VarFormatFromTokens failed: %x\n", hres);
+ ok(!strcmpW(bstr, date), "incorrectly formatted date: %s\n", wine_dbgstr_w(bstr));
+ SysFreeString(bstr);
+
+ VariantClear(&var);
+
+ V_VT(&var) = VT_R4;
+ V_R4(&var) = 1.5;
+
+ lcid = MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT);
+ hres = VarTokenizeFormatString(string_fmt, buff, sizeof(buff), 1, 1, lcid, NULL);
+ ok(hres == S_OK, "VarTokenizeFormatString failed: %x\n", hres);
+ hres = VarFormatFromTokens(&var, string_fmt, buff, 0, &bstr, lcid);
+ ok(hres == S_OK, "VarFormatFromTokens failed: %x\n", hres);
+ ok(!strcmpW(bstr, string_us), "incorrectly formatted string: %s\n", wine_dbgstr_w(bstr));
+ SysFreeString(bstr);
+
+ lcid = MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_GERMAN), SORT_DEFAULT);
+ hres = VarTokenizeFormatString(string_fmt, buff, sizeof(buff), 1, 1, lcid, NULL);
+ ok(hres == S_OK, "VarTokenizeFormatString failed: %x\n", hres);
+ hres = VarFormatFromTokens(&var, string_fmt, buff, 0, &bstr, lcid);
+ ok(hres == S_OK, "VarFormatFromTokens failed: %x\n", hres);
+ ok(!strcmpW(bstr, string_de), "incorrectly formatted string: %s\n", wine_dbgstr_w(bstr));
+ SysFreeString(bstr);
+}
+
+static void test_GetAltMonthNames(void)
+{
+ LPOLESTR *str, *str2;
+ HRESULT hr;
+
+ str = (void *)0xdeadbeef;
+ hr = GetAltMonthNames(0, &str);
+ ok(hr == S_OK, "Unexpected return value %08x\n", hr);
+ ok(str == NULL, "Got %p\n", str);
+
+ str = (void *)0xdeadbeef;
+ hr = GetAltMonthNames(MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US), SORT_DEFAULT), &str);
+ ok(hr == S_OK, "Unexpected return value %08x\n", hr);
+ ok(str == NULL, "Got %p\n", str);
+
+ str = NULL;
+ hr = GetAltMonthNames(MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_EGYPT), SORT_DEFAULT), &str);
+ ok(hr == S_OK, "Unexpected return value %08x\n", hr);
+ ok(str != NULL, "Got %p\n", str);
+
+ str2 = NULL;
+ hr = GetAltMonthNames(MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_ARABIC_EGYPT), SORT_DEFAULT), &str2);
+ ok(hr == S_OK, "Unexpected return value %08x\n", hr);
+ ok(str2 == str, "Got %p\n", str2);
+
+ str = NULL;
+ hr = GetAltMonthNames(MAKELCID(MAKELANGID(LANG_RUSSIAN, SUBLANG_DEFAULT), SORT_DEFAULT), &str);
+ ok(hr == S_OK, "Unexpected return value %08x\n", hr);
+ ok(str != NULL, "Got %p\n", str);
+
+ str = NULL;
+ hr = GetAltMonthNames(MAKELCID(MAKELANGID(LANG_POLISH, SUBLANG_DEFAULT), SORT_DEFAULT), &str);
+ ok(hr == S_OK, "Unexpected return value %08x\n", hr);
+ ok(str != NULL, "Got %p\n", str);
+}
+
START_TEST(varformat)
{
hOleaut32 = GetModuleHandleA("oleaut32.dll");
+ has_i8 = GetProcAddress(hOleaut32, "VarI8FromI1") != NULL;
+
test_VarFormatNumber();
test_VarFormat();
test_VarWeekdayName();
+ test_VarFormatFromTokens();
+ test_GetAltMonthNames();
}