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
28 #include "wine/test.h"
32 DEFINE_GUID(CLSID_wb_neutral
, 0x369647e0,0x17b0,0x11ce,0x99,0x50,0x00,0xaa,0x00,0x4b,0xbb,0x1f);
33 DEFINE_GUID(_IID_IWordBreaker
, 0xD53552C8,0x77E3,0x101A,0xB5,0x52,0x08,0x00,0x2B,0x33,0xB0,0xE6);
35 static WCHAR teststring
[] = {
36 's','q','u','a','r','e',' ',
37 'c','i','r','c','l','e',' ',
38 't','r','i','a','n','g','l','e',' ',
50 static struct expected testres
[] = {
51 { 0, 6, {'s','q','u','a','r','e',0 }},
52 { 7, 6, {'c','i','r','c','l','e',0 }},
53 { 14, 8, {'t','r','i','a','n','g','l','e',0 }},
54 { 23, 3, {'b','o','x',0}},
57 static HRESULT WINAPI
ws_QueryInterface(IWordSink
*iface
, REFIID riid
, void **ppvObject
)
59 ok(0, "not expected\n");
63 static ULONG WINAPI
ws_AddRef(IWordSink
*iface
)
65 ok(0, "not expected\n");
69 static ULONG WINAPI
ws_Release(IWordSink
*iface
)
71 ok(0, "not expected\n");
75 static HRESULT WINAPI
ws_PutWord(IWordSink
*iface
, 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
*iface
, ULONG cwc
, const WCHAR
*pwcInBuf
,
86 ULONG cwcSrcLen
, ULONG cwcSrcPos
)
88 ok(0, "not expected\n");
92 static HRESULT WINAPI
ws_StartAltPhrase(IWordSink
*iface
)
94 ok(0, "not expected\n");
98 static HRESULT WINAPI
ws_EndAltPhrase(IWordSink
*iface
)
100 ok(0, "not expected\n");
104 static HRESULT WINAPI
ws_PutBreak(IWordSink
*iface
, WORDREP_BREAK_TYPE breakType
)
106 ok(0, "not expected\n");
110 static const IWordSinkVtbl wsvt
=
122 typedef struct _wordsink_impl
124 IWordSink IWordSink_iface
;
127 static wordsink_impl wordsink
= { { &wsvt
} };
129 static HRESULT WINAPI
fillbuf_none(TEXT_SOURCE
*ts
)
134 static HRESULT WINAPI
fillbuf_many(TEXT_SOURCE
*ts
)
138 if (ts
->awcBuffer
== NULL
)
139 ts
->awcBuffer
= teststring
;
141 ts
->awcBuffer
+= ts
->iCur
;
143 if (!ts
->awcBuffer
[0])
146 for( i
=0; ts
->awcBuffer
[i
] && ts
->awcBuffer
[i
] != ' '; i
++)
148 if (ts
->awcBuffer
[i
] == ' ')
161 IWordBreaker
*wb
= NULL
;
164 r
= CoInitialize(NULL
);
165 ok( r
== S_OK
, "failed\n");
167 r
= CoCreateInstance( &CLSID_wb_neutral
, NULL
, CLSCTX_INPROC_SERVER
,
168 &_IID_IWordBreaker
, (LPVOID
)&wb
);
173 r
= IWordBreaker_Init( wb
, FALSE
, 0x100, &license
);
174 ok( r
== S_OK
, "failed to init the wordbreaker\n");
175 /* ok( license == TRUE, "should be no license\n"); */
178 ts
.pfnFillTextBuffer
= fillbuf_none
;
179 ts
.awcBuffer
= teststring
;
180 ts
.iEnd
= lstrlenW(ts
.awcBuffer
);
182 r
= IWordBreaker_BreakText(wb
, &ts
, &wordsink
.IWordSink_iface
, NULL
);
183 ok( r
== S_OK
, "failed\n");
185 ok(wordnum
== 4, "words not processed\n");
188 ts
.pfnFillTextBuffer
= fillbuf_many
;
189 ts
.awcBuffer
= teststring
;
193 r
= fillbuf_many(&ts
);
194 ok( r
== S_OK
, "failed\n");
196 r
= IWordBreaker_BreakText(wb
, &ts
, &wordsink
.IWordSink_iface
, NULL
);
197 ok( r
== S_OK
, "failed\n");
199 ok(wordnum
== 4, "words not processed\n");
200 IWordBreaker_Release( wb
);