2 * tests for the language neutral word breaker
4 * Copyright 2006 Mike McCormack for CodeWeavers
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., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
27 #include "wine/test.h"
31 DEFINE_GUID(CLSID_wb_neutral
, 0x369647e0,0x17b0,0x11ce,0x99,0x50,0x00,0xaa,0x00,0x4b,0xbb,0x1f);
32 DEFINE_GUID(_IID_IWordBreaker
, 0xD53552C8,0x77E3,0x101A,0xB5,0x52,0x08,0x00,0x2B,0x33,0xB0,0xE6);
34 static WCHAR teststring
[] = {
35 's','q','u','a','r','e',' ',
36 'c','i','r','c','l','e',' ',
37 't','r','i','a','n','g','l','e',' ',
49 static struct expected testres
[] = {
50 { 0, 6, {'s','q','u','a','r','e',0 }},
51 { 7, 6, {'c','i','r','c','l','e',0 }},
52 { 14, 8, {'t','r','i','a','n','g','l','e',0 }},
53 { 23, 3, {'b','o','x',0}},
56 static HRESULT WINAPI
ws_QueryInterface(IWordSink
*ws
, REFIID riid
, void **ppvObject
)
58 ok(0, "not expected\n");
62 static ULONG WINAPI
ws_AddRef(IWordSink
*ws
)
64 ok(0, "not expected\n");
68 static ULONG WINAPI
ws_Release(IWordSink
*ws
)
70 ok(0, "not expected\n");
74 static HRESULT WINAPI
ws_PutWord(IWordSink
*ws
,
75 ULONG cwc
, const WCHAR
* pwcInBuf
,
76 ULONG cwcSrcLen
, ULONG cwcSrcPos
)
78 ok(testres
[wordnum
].len
== cwcSrcLen
, "wrong length\n");
79 ok(!cwcSrcPos
||(testres
[wordnum
].ofs
== cwcSrcPos
), "wrong offset\n");
80 ok(!memcmp(testres
[wordnum
].data
, pwcInBuf
, cwcSrcLen
), "wrong data\n");
85 static HRESULT WINAPI
ws_PutAltWord(IWordSink
*ws
,
86 ULONG cwc
, const WCHAR
* pwcInBuf
,
87 ULONG cwcSrcLen
, ULONG cwcSrcPos
)
89 ok(0, "not expected\n");
93 static HRESULT WINAPI
ws_StartAltPhrase(IWordSink
*ws
)
95 ok(0, "not expected\n");
99 static HRESULT WINAPI
ws_EndAltPhrase(IWordSink
*ws
)
101 ok(0, "not expected\n");
105 static HRESULT WINAPI
ws_PutBreak(IWordSink
*ws
, WORDREP_BREAK_TYPE breakType
)
107 ok(0, "not expected\n");
111 static const IWordSinkVtbl wsvt
=
123 typedef struct _wordsink_impl
125 const IWordSinkVtbl
*vtbl
;
128 static wordsink_impl wordsink
= { &wsvt
};
130 static HRESULT WINAPI
fillbuf_none(TEXT_SOURCE
*ts
)
135 static HRESULT WINAPI
fillbuf_many(TEXT_SOURCE
*ts
)
139 if (ts
->awcBuffer
== NULL
)
140 ts
->awcBuffer
= teststring
;
142 ts
->awcBuffer
+= ts
->iCur
;
144 if (!ts
->awcBuffer
[0])
147 for( i
=0; ts
->awcBuffer
[i
] && ts
->awcBuffer
[i
] != ' '; i
++)
149 if (ts
->awcBuffer
[i
] == ' ')
162 IWordBreaker
*wb
= NULL
;
165 r
= CoInitialize(NULL
);
166 ok( r
== S_OK
, "failed\n");
168 r
= CoCreateInstance( &CLSID_wb_neutral
, NULL
, CLSCTX_INPROC_SERVER
,
169 &_IID_IWordBreaker
, (LPVOID
)&wb
);
174 r
= IWordBreaker_Init( wb
, FALSE
, 0x100, &license
);
175 ok( r
== S_OK
, "failed to init the wordbreaker\n");
176 /* ok( license == TRUE, "should be no license\n"); */
179 ts
.pfnFillTextBuffer
= fillbuf_none
;
180 ts
.awcBuffer
= teststring
;
181 ts
.iEnd
= lstrlenW(ts
.awcBuffer
);
183 r
= IWordBreaker_BreakText( wb
, &ts
, (IWordSink
*) &wordsink
, NULL
);
184 ok( r
== S_OK
, "failed\n");
186 ok(wordnum
== 4, "words not processed\n");
189 ts
.pfnFillTextBuffer
= fillbuf_many
;
190 ts
.awcBuffer
= teststring
;
194 r
= fillbuf_many(&ts
);
195 ok( r
== S_OK
, "failed\n");
197 r
= IWordBreaker_BreakText( wb
, &ts
, (IWordSink
*) &wordsink
, NULL
);
198 ok( r
== S_OK
, "failed\n");
200 ok(wordnum
== 4, "words not processed\n");
201 IWordBreaker_Release( wb
);