2 * Unit test suite for StringTable functions
4 * Copyright 2005 Steven Edwards for ReactOS
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * Add case sensitivity test for StringTableAddString/StringTableLookupString
23 * Add test for StringTableStringFromIdEx
35 #include "wine/test.h"
38 static DWORD (WINAPI
*pStringTableAddString
)(HSTRING_TABLE
, LPWSTR
, DWORD
);
39 static VOID (WINAPI
*pStringTableDestroy
)(HSTRING_TABLE
);
40 static HSTRING_TABLE (WINAPI
*pStringTableDuplicate
)(HSTRING_TABLE hStringTable
);
41 static HSTRING_TABLE (WINAPI
*pStringTableInitialize
)(VOID
);
42 static DWORD (WINAPI
*pStringTableLookUpString
)(HSTRING_TABLE
, LPWSTR
, DWORD
);
43 static LPWSTR (WINAPI
*pStringTableStringFromId
)(HSTRING_TABLE
, DWORD
);
45 static BOOL (WINAPI
*pStringTableStringFromIdEx
)(HSTRING_TABLE
, DWORD
, LPWSTR
, LPDWORD
);
46 static VOID (WINAPI
*pStringTableTrim
)(HSTRING_TABLE
);
50 static WCHAR string
[] = {'s','t','r','i','n','g',0};
51 HANDLE table
, table2
; /* Handles pointing to our tables */
53 static void load_it_up(void)
55 hdll
= LoadLibraryA("setupapi.dll");
59 pStringTableInitialize
= (void*)GetProcAddress(hdll
, "StringTableInitialize");
60 if (!pStringTableInitialize
)
61 pStringTableInitialize
= (void*)GetProcAddress(hdll
, "pSetupStringTableInitialize");
63 pStringTableAddString
= (void*)GetProcAddress(hdll
, "StringTableAddString");
64 if (!pStringTableAddString
)
65 pStringTableAddString
= (void*)GetProcAddress(hdll
, "pSetupStringTableAddString");
67 pStringTableDuplicate
= (void*)GetProcAddress(hdll
, "StringTableDuplicate");
68 if (!pStringTableDuplicate
)
69 pStringTableDuplicate
= (void*)GetProcAddress(hdll
, "pSetupStringTableDuplicate");
71 pStringTableDestroy
= (void*)GetProcAddress(hdll
, "StringTableDestroy");
72 if (!pStringTableDestroy
)
73 pStringTableDestroy
= (void*)GetProcAddress(hdll
, "pSetupStringTableDestroy");
75 pStringTableLookUpString
= (void*)GetProcAddress(hdll
, "StringTableLookUpString");
76 if (!pStringTableLookUpString
)
77 pStringTableLookUpString
= (void*)GetProcAddress(hdll
, "pSetupStringTableLookUpString");
79 pStringTableStringFromId
= (void*)GetProcAddress(hdll
, "StringTableStringFromId");
80 if (!pStringTableStringFromId
)
81 pStringTableStringFromId
= (void*)GetProcAddress(hdll
, "pSetupStringTableStringFromId");
84 static void test_StringTableInitialize(void)
86 table
=pStringTableInitialize();
87 ok(table
!=NULL
,"Failed to Initialize String Table\n");
90 static void test_StringTableAddString(void)
94 retval
=pStringTableAddString(table
,string
,0);
95 ok(retval
!=-1,"Failed to add string to String Table\n");
98 static void test_StringTableDuplicate(void)
100 table2
=pStringTableDuplicate(table
);
101 ok(table2
!=NULL
,"Failed to duplicate String Table\n");
104 static void test_StringTableLookUpString(void)
106 DWORD retval
, retval2
;
108 retval
=pStringTableLookUpString(table
,string
,0);
109 ok(retval
!=-1,"Failed find string in String Table 1\n");
111 retval2
=pStringTableLookUpString(table2
,string
,0);
112 ok(retval2
!=-1,"Failed find string in String Table 2\n");
115 static void test_StringTableStringFromId(void)
117 WCHAR
*string2
, *string3
;
121 string2
=pStringTableStringFromId(table
,pStringTableLookUpString(table
,string
,0));
122 ok(string2
!=NULL
,"Failed to look up string by ID from String Table\n");
124 result
=lstrcmpiW(string
, string2
);
125 ok(result
==0,"StringID %p does not match requested StringID %p\n",string
,string2
);
127 /* This should never work */
128 string3
=pStringTableStringFromId(table
,0);
129 ok(string3
!=NULL
,"Failed to look up string by ID from String Table\n");
131 result
=lstrcmpiW(string
, string3
);
132 ok(result
!=0,"StringID %p matches requested StringID %p\n",string
,string3
);
135 START_TEST(stringtable
)
139 test_StringTableInitialize();
140 test_StringTableAddString();
141 test_StringTableDuplicate();
142 test_StringTableLookUpString();
143 test_StringTableStringFromId();
145 /* assume we can always distroy */
146 pStringTableDestroy(table
);
147 pStringTableDestroy(table2
);