PageRenderTime 7ms CodeModel.GetById 3ms app.highlight 64ms RepoModel.GetById 1ms app.codeStats 0ms

/registry/test/testmerge.cxx

https://bitbucket.org/markjenkins/libreoffice_ubuntu-debian-fixes
C++ | 414 lines | 304 code | 86 blank | 24 comment | 57 complexity | 9b9afa4abdd686dd9a201f10e56405bf MD5 | raw file
  1/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
  2/*
  3 * This file is part of the LibreOffice project.
  4 *
  5 * This Source Code Form is subject to the terms of the Mozilla Public
  6 * License, v. 2.0. If a copy of the MPL was not distributed with this
  7 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  8 *
  9 * This file incorporates work covered by the following license notice:
 10 *
 11 *   Licensed to the Apache Software Foundation (ASF) under one or more
 12 *   contributor license agreements. See the NOTICE file distributed
 13 *   with this work for additional information regarding copyright
 14 *   ownership. The ASF licenses this file to you under the Apache
 15 *   License, Version 2.0 (the "License"); you may not use this file
 16 *   except in compliance with the License. You may obtain a copy of
 17 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 18 */
 19
 20
 21#include <iostream>
 22#include <stdio.h>
 23#include <string.h>
 24
 25#include "registry/registry.hxx"
 26#include "registry/reflread.hxx"
 27#include "registry/reflwrit.hxx"
 28#include "regdiagnose.h"
 29#include <rtl/alloc.h>
 30#include <rtl/ustring.hxx>
 31
 32
 33using namespace std;
 34
 35using ::rtl::OUString;
 36
 37sal_Int32 lValue1   = 123456789;
 38sal_Int32 lValue2   = 54321;
 39sal_Int32 lValue3   = 111333111;
 40sal_Int32 lValue4   = 333111333;
 41sal_Char* sValue    = (sal_Char*)"string Value";
 42OUString wValue("unicode Value");
 43
 44
 45void test_generateMerge1()
 46{
 47    Registry *myRegistry = new Registry();
 48
 49    RegistryKey rootKey, key1, key2, key3, key4, key5, key6, key7, key8, key9;
 50
 51    REG_ENSURE(!myRegistry->create(OUString("merge1.rdb")), "testGenerateMerge1 error 1");
 52    REG_ENSURE(!myRegistry->openRootKey(rootKey), "testGenerateMerge1 error 2");
 53
 54    REG_ENSURE(!rootKey.createKey(OUString("MergeKey1"), key1), "testGenerateMerge1 error 3");
 55    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey1"), key2), "testGenerateMerge1 error 4");
 56    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey1/KeyWithLongValue"), key3), "testGenerateMerge1 error 5");
 57    REG_ENSURE(!key3.setValue(OUString(), RG_VALUETYPE_LONG, &lValue1, sizeof(sal_Int32)), "testGenerateMerge1 error 5a");
 58    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey2"), key4), "testGenerateMerge1 error 6");
 59    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey2/KeyWithStringValue"), key5), "testGenerateMerge1 error 7");
 60    REG_ENSURE(!key5.setValue(OUString(), RG_VALUETYPE_STRING, sValue, strlen(sValue)+1), "testGenerateMerge1 error 7a");
 61    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey3"), key6), "testGenerateMerge1 error 8");
 62    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue"), key7), "testGenerateMerge1 error 9");
 63    REG_ENSURE(!key7.setValue(OUString(), RG_VALUETYPE_UNICODE, (void*)wValue.getStr(), ((wValue.getLength()+1)*sizeof(sal_Unicode))), "testGenerateMerge1 error 9a");
 64    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey4"), key8), "testGenerateMerge1 error 10");
 65    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey4/KeyWithBinaryValue"), key9), "testGenerateMerge1 error 11");
 66    REG_ENSURE(!key9.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)"abcdefghijklmnopqrstuvwxyz", 27), "testGenerateMerge1 error 11a");
 67
 68
 69    REG_ENSURE(!key1.closeKey() &&
 70                !key2.closeKey() &&
 71                !key3.closeKey() &&
 72                !key4.closeKey() &&
 73                !key5.closeKey() &&
 74                !key6.closeKey() &&
 75                !key7.closeKey() &&
 76                !key8.closeKey() &&
 77                !key9.closeKey(), "testGenerateMerge1 error 12");
 78
 79    REG_ENSURE(!rootKey.createKey(OUString("MergeKey1u2"), key1), "testGenerateMerge1 error 13");
 80    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK1SubKey11"), key2), "testGenerateMerge1 error 14");
 81    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK1SubKey11/KeyWithLongValue"), key3), "testGenerateMerge1 error 15");
 82    REG_ENSURE(!key3.setValue(OUString(), RG_VALUETYPE_LONG, &lValue2, sizeof(sal_Int32)), "testGenerateMerge1 error 15a");
 83    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK1SubKey12"), key4), "testGenerateMerge1 error 16");
 84    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK1SubKey12/KeyWithStringValue"), key5), "testGenerateMerge1 error 17");
 85    REG_ENSURE(!key5.setValue(OUString(), RG_VALUETYPE_STRING, sValue, strlen(sValue)+1), "testGenerateMerge1 error 17a");
 86    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK1SubKey13"), key6), "testGenerateMerge1 error 18");
 87    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue"), key7), "testGenerateMerge1 error 19");
 88    REG_ENSURE(!key7.setValue(OUString(), RG_VALUETYPE_UNICODE, (void*)wValue.getStr(), ((wValue.getLength()+1)*sizeof(sal_Unicode))), "testGenerateMerge1 error 19a");
 89    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK12SubKey1u2"), key8), "testGenerateMerge1 error 20");
 90    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), key9), "testGenerateMerge1 error 21");
 91    REG_ENSURE(!key9.setValue(OUString(), RG_VALUETYPE_LONG, &lValue3, sizeof(sal_Int32)), "testGenerateMerge1 error 21a");
 92
 93    REG_ENSURE(!rootKey.closeKey() &&
 94                !key1.closeKey() &&
 95                !key2.closeKey() &&
 96                !key3.closeKey() &&
 97                !key4.closeKey() &&
 98                !key5.closeKey() &&
 99                !key6.closeKey() &&
100                !key7.closeKey() &&
101                !key8.closeKey() &&
102                !key9.closeKey(), "testGenerateMerge1 error 22");
103
104
105    delete myRegistry;
106
107    cout << "test_generateMerge1() Ok!\n";
108    return;
109}
110
111void test_generateMerge2()
112{
113    Registry *myRegistry = new Registry();
114
115    RegistryKey rootKey, key1, key2, key3, key4, key5, key6, key7, key8, key9;
116
117    REG_ENSURE(!myRegistry->create(OUString("merge2.rdb")), "testGenerateMerge2 error 1");
118    REG_ENSURE(!myRegistry->openRootKey(rootKey), "testGenerateMerge2 error 2");
119
120    REG_ENSURE(!rootKey.createKey(OUString("MergeKey2"), key1), "testGenerateMerge2 error 3");
121    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey1"), key2), "testGenerateMerge2 error 4");
122    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey1/KeyWithBinaryValue"), key3), "testGenerateMerge2 error 5");
123    REG_ENSURE(!key3.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)"1234567890", 11), "testGenerateMerge1 error 5a");
124    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey2"), key4), "testGenerateMerge2 error 6");
125    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue"), key5), "testGenerateMerge2 error 7");
126    REG_ENSURE(!key5.setValue(OUString(), RG_VALUETYPE_UNICODE, (void*)wValue.getStr(), ((wValue.getLength()+1)*sizeof(sal_Unicode))), "testGenerateMerge1 error 7a");
127    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey3"), key6), "testGenerateMerge2 error 8");
128    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey3/KeyWithStringValue"), key7), "testGenerateMerge2 error 9");
129    REG_ENSURE(!key7.setValue(OUString(), RG_VALUETYPE_STRING, sValue, strlen(sValue)+1), "testGenerateMerge1 error 9a");
130    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey4"), key8), "testGenerateMerge2 error 10");
131    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey4/KeyWithLongValue"), key9), "testGenerateMerge2 error 11");
132    REG_ENSURE(!key9.setValue(OUString(), RG_VALUETYPE_LONG, &lValue1, sizeof(sal_Int32)), "testGenerateMerge1 error 11a");
133
134    REG_ENSURE(!key1.closeKey() &&
135                !key2.closeKey() &&
136                !key3.closeKey() &&
137                !key4.closeKey() &&
138                !key5.closeKey() &&
139                !key6.closeKey() &&
140                !key7.closeKey() &&
141                !key8.closeKey() &&
142                !key9.closeKey(), "testGenerateMerge2 error 12");
143
144    REG_ENSURE(!rootKey.createKey(OUString("MergeKey1u2"), key1), "testGenerateMerge2 error 13");
145    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK2SubKey21"), key2), "testGenerateMerge2 error 14");
146    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue"), key3), "testGenerateMerge2 error 15");
147    REG_ENSURE(!key3.setValue(OUString(), RG_VALUETYPE_BINARY, (void*)"a1b2c3d4e5f6g7h8i9", 19), "testGenerateMerge1 error 15a");
148    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK2SubKey22"), key4), "testGenerateMerge2 error 16");
149    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK2SubKey22/KeyWithLongValue"), key5), "testGenerateMerge2 error 17");
150    REG_ENSURE(!key5.setValue(OUString(), RG_VALUETYPE_LONG, &lValue2, sizeof(sal_Int32)), "testGenerateMerge1 error 17a");
151    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK2SubKey23"), key6), "testGenerateMerge2 error 18");
152    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK2SubKey23/KeyWithStringValue"), key7), "testGenerateMerge2 error 19");
153    REG_ENSURE(!key7.setValue(OUString(), RG_VALUETYPE_STRING, sValue, strlen(sValue)+1), "testGenerateMerge1 error 19a");
154    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK12SubKey1u2"), key8), "testGenerateMerge2 error 20");
155    REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), key9), "testGenerateMerge2 error 21");
156    REG_ENSURE(!key9.setValue(OUString(), RG_VALUETYPE_LONG, &lValue4, sizeof(sal_Int32)), "testGenerateMerge1 error 21a");
157
158    REG_ENSURE(!rootKey.closeKey() &&
159                !key1.closeKey() &&
160                !key2.closeKey() &&
161                !key3.closeKey() &&
162                !key4.closeKey() &&
163                !key5.closeKey() &&
164                !key6.closeKey() &&
165                !key7.closeKey() &&
166                !key8.closeKey() &&
167                !key9.closeKey(), "testGenerateMerge2 error 22");
168
169
170    delete myRegistry;
171
172    cout << "test_generateMerge2() Ok!\n";
173    return;
174}
175
176void test_merge()
177{
178    Registry *myRegistry = new Registry();
179
180    RegistryKey rootKey, key1, mkey1, key2, mkey2, key1u2, mkey1u2;
181
182    REG_ENSURE(!myRegistry->create(OUString("mergetest.rdb")), "testMerge error 1");
183    REG_ENSURE(myRegistry->getName() == "mergetest.rdb", "testMerge error 1.a)");
184    REG_ENSURE(!myRegistry->openRootKey(rootKey), "testMerge error 2");
185    REG_ENSURE(!myRegistry->loadKey(rootKey, OUString("/stardiv/IchbineinMergeKey"),
186                OUString("merge1.rdb")), "testMerge error 3");
187    REG_ENSURE(!myRegistry->mergeKey(rootKey, OUString("/stardiv/IchbineinMergeKey"),
188                OUString("merge2.rdb")), "testMerge error 4");
189
190    ///////////////////////////////////////////////////////////////////////////
191
192    REG_ENSURE(!rootKey.openKey(OUString("/stardiv/IchbineinMergeKey"), key1), "testMerge error 5");
193
194    REG_ENSURE(!key1.openKey(OUString("MergeKey1"), mkey1), "testMerge error 6");
195    REG_ENSURE(!mkey1.closeKey(), "testMerge error 7");
196
197    REG_ENSURE(!key1.openKey(OUString("/MergeKey1/MK1SubKey1"), mkey1), "testMerge error 8");
198    REG_ENSURE(!mkey1.closeKey(), "testMerge error 9");
199    REG_ENSURE(!key1.openKey(OUString("/MergeKey1/MK1SubKey1/KeyWithLongValue"), mkey1), "testMerge error 10");
200    REG_ENSURE(!mkey1.closeKey(), "testMerge error 11");
201
202    REG_ENSURE(!key1.openKey(OUString("/MergeKey1/MK1SubKey2"), mkey1), "testMerge error 12");
203    REG_ENSURE(!mkey1.closeKey(), "testMerge error 13");
204    REG_ENSURE(!key1.openKey(OUString("/MergeKey1/MK1SubKey2/KeyWithStringValue"), mkey1), "testMerge error 14");
205    REG_ENSURE(!mkey1.closeKey(), "testMerge error 15");
206
207    REG_ENSURE(!key1.openKey(OUString("/MergeKey1/MK1SubKey3"), mkey1), "testMerge error 16");
208    REG_ENSURE(!mkey1.closeKey(), "testMerge error 17");
209    REG_ENSURE(!key1.openKey(OUString("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue"), mkey1), "testMerge error 18");
210    REG_ENSURE(!mkey1.closeKey(), "testMerge error 19");
211
212    REG_ENSURE(!key1.openKey(OUString("/MergeKey1/MK1SubKey4"), mkey1), "testMerge error 20");
213    REG_ENSURE(!mkey1.closeKey(), "testMerge error 21");
214    REG_ENSURE(!key1.openKey(OUString("/MergeKey1/MK1SubKey4/KeyWithBinaryValue"), mkey1), "testMerge error 22");
215    REG_ENSURE(!mkey1.closeKey(), "testMerge error 23");
216
217    REG_ENSURE(!key1.closeKey(), "testMerge error 24");
218
219    ///////////////////////////////////////////////////////////////////////////
220
221    REG_ENSURE(!rootKey.openKey(OUString("/stardiv/IchbineinMergeKey"), key2), "testMerge error 25");
222
223    REG_ENSURE(!key2.openKey(OUString("MergeKey2"), mkey2), "testMerge error 26");
224    REG_ENSURE(!mkey2.closeKey(), "testMerge error 27");
225
226    REG_ENSURE(!key2.openKey(OUString("/MergeKey2/MK2SubKey1"), mkey2), "testMerge error 28");
227    REG_ENSURE(!mkey2.closeKey(), "testMerge error 29");
228    REG_ENSURE(!key2.openKey(OUString("/MergeKey2/MK2SubKey1/KeyWithBinaryValue"), mkey2), "testMerge error 30");
229    REG_ENSURE(!mkey2.closeKey(), "testMerge error 31");
230
231    REG_ENSURE(!key2.openKey(OUString("/MergeKey2/MK2SubKey2"), mkey2), "testMerge error 31");
232    REG_ENSURE(!mkey2.closeKey(), "testMerge error 33");
233    REG_ENSURE(!key2.openKey(OUString("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue"), mkey2), "testMerge error 34");
234    REG_ENSURE(!mkey2.closeKey(), "testMerge error 35");
235
236    REG_ENSURE(!key2.openKey(OUString("/MergeKey2/MK2SubKey3"), mkey2), "testMerge error 36");
237    REG_ENSURE(!mkey2.closeKey(), "testMerge error 37");
238    REG_ENSURE(!key2.openKey(OUString("/MergeKey2/MK2SubKey3/KeyWithStringValue"), mkey2), "testMerge error 38");
239    REG_ENSURE(!mkey2.closeKey(), "testMerge error 39");
240
241    REG_ENSURE(!key2.openKey(OUString("/MergeKey2/MK2SubKey4"), mkey2), "testMerge error 40");
242    REG_ENSURE(!mkey2.closeKey(), "testMerge error 41");
243    REG_ENSURE(!key2.openKey(OUString("/MergeKey2/MK2SubKey4/KeyWithLongValue"), mkey2), "testMerge error 42");
244    REG_ENSURE(!mkey2.closeKey(), "testMerge error 43");
245
246    REG_ENSURE(!key2.closeKey(), "testMerge error 44");
247
248    ///////////////////////////////////////////////////////////////////////////
249
250    REG_ENSURE(!rootKey.openKey(OUString("/stardiv/IchbineinMergeKey"), key1u2), "testMerge error 40");
251
252    REG_ENSURE(!key1u2.openKey(OUString("MergeKey1u2"), mkey1u2), "testMerge error 41");
253    REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 42");
254
255    REG_ENSURE(!key1u2.openKey(OUString("/MergeKey1u2/MK1SubKey11"), mkey1u2), "testMerge error 43");
256    REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 44");
257    REG_ENSURE(!key1u2.openKey(OUString("/MergeKey1u2/MK1SubKey11/KeyWithLongValue"), mkey1u2), "testMerge error 45");
258    REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 46");
259
260    REG_ENSURE(!key1u2.openKey(OUString("/MergeKey1u2/MK1SubKey12"), mkey1u2), "testMerge error 47");
261    REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 48");
262    REG_ENSURE(!key1u2.openKey(OUString("/MergeKey1u2/MK1SubKey12/KeyWithStringValue"), mkey1u2), "testMerge error 49");
263    REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 50");
264
265    REG_ENSURE(!key1u2.openKey(OUString("/MergeKey1u2/MK1SubKey13"), mkey1u2), "testMerge error 51");
266    REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 52");
267    REG_ENSURE(!key1u2.openKey(OUString("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue"), mkey1u2), "testMerge error 53");
268    REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 54");
269
270    REG_ENSURE(!key1u2.openKey(OUString("/MergeKey1u2/MK2SubKey21"), mkey1u2), "testMerge error 55");
271    REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 56");
272    REG_ENSURE(!key1u2.openKey(OUString("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue"), mkey1u2), "testMerge error 57");
273    REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 58");
274
275    REG_ENSURE(!key1u2.openKey(OUString("/MergeKey1u2/MK2SubKey22"), mkey1u2), "testMerge error 59");
276    REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 60");
277    REG_ENSURE(!key1u2.openKey(OUString("/MergeKey1u2/MK2SubKey22/KeyWithLongValue"), mkey1u2), "testMerge error 61");
278    REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 62");
279
280    REG_ENSURE(!key1u2.openKey(OUString("/MergeKey1u2/MK2SubKey23"), mkey1u2), "testMerge error 63");
281    REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 64");
282    REG_ENSURE(!key1u2.openKey(OUString("/MergeKey1u2/MK2SubKey23/KeyWithStringValue"), mkey1u2), "testMerge error 65");
283    REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 66");
284
285    REG_ENSURE(!key1u2.openKey(OUString("/MergeKey1u2/MK12SubKey1u2"), mkey1u2), "testMerge error 67");
286    REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 68");
287    REG_ENSURE(!key1u2.openKey(OUString("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), mkey1u2), "testMerge error 69");
288    REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 70");
289
290    REG_ENSURE(!key1u2.closeKey(), "testMerge error 71");
291
292    ///////////////////////////////////////////////////////////////////////////
293
294    RegValueType    valueType;
295    sal_uInt32          valueSize;
296    sal_Int32           int32Value;
297    sal_uInt8           *Value;
298
299    REG_ENSURE(!rootKey.openKey(OUString("/stardiv/IchbineinMergeKey"), key1), "testMerge error 72");
300
301    REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1/MK1SubKey1/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 73");
302    REG_ENSURE(valueType == RG_VALUETYPE_LONG && valueSize == sizeof(sal_Int32), "testMerge error 74");
303    REG_ENSURE(!key1.getValue(OUString("/MergeKey1/MK1SubKey1/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 74.a)");
304    REG_ENSURE(int32Value == lValue1, "testMerge error 74.b)");
305
306    REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1/MK1SubKey2/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 75");
307    REG_ENSURE(valueType == RG_VALUETYPE_STRING && valueSize == strlen(sValue)+1, "testMerge error 76");
308    Value = new sal_uInt8[valueSize];
309    REG_ENSURE(!key1.getValue(OUString("/MergeKey1/MK1SubKey2/KeyWithStringValue"), (RegValue)Value), "testMerge error 76.a)");
310    REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 76.b)");
311    delete [] Value;
312
313    REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue"), &valueType, &valueSize), "testMerge error 77");
314    REG_ENSURE(valueType == RG_VALUETYPE_UNICODE && valueSize == (wValue.getLength()+1)*sizeof(sal_Unicode), "testMerge error 78");
315    Value = new sal_uInt8[valueSize];
316    REG_ENSURE(!key1.getValue(OUString("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue"), (RegValue)Value), "testMerge error 78.a)");
317    REG_ENSURE(wValue.equals( (const sal_Unicode*)Value ), "testMerge error 78.b)");
318    delete [] Value;
319
320    REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1/MK1SubKey4/KeyWithBinaryValue"), &valueType, &valueSize), "testMerge error 79");
321    REG_ENSURE(valueType == RG_VALUETYPE_BINARY && valueSize == 27, "testMerge error 80");
322    Value = new sal_uInt8[valueSize];
323    REG_ENSURE(!key1.getValue(OUString("/MergeKey1/MK1SubKey4/KeyWithBinaryValue"), (RegValue)Value), "testMerge error 80.a)");
324    REG_ENSURE(strcmp((const sal_Char*)Value, "abcdefghijklmnopqrstuvwxyz") == 0, "testMerge error 80.b)");
325    delete [] Value;
326
327    REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey2/MK2SubKey1/KeyWithBinaryValue"), &valueType, &valueSize), "testMerge error 81");
328    REG_ENSURE(valueType == RG_VALUETYPE_BINARY && valueSize == 11, "testMerge error 82");
329    Value = new sal_uInt8[valueSize];
330    REG_ENSURE(!key1.getValue(OUString("/MergeKey2/MK2SubKey1/KeyWithBinaryValue"), (RegValue)Value), "testMerge error 82.a)");
331    REG_ENSURE(strcmp((const sal_Char*)Value, "1234567890") == 0, "testMerge error 82.b)");
332    delete [] Value;
333
334    REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue"), &valueType, &valueSize), "testMerge error 83");
335    REG_ENSURE(valueType == RG_VALUETYPE_UNICODE&& valueSize == (wValue.getLength()+1)*sizeof(sal_Unicode), "testMerge error 84");
336    Value = new sal_uInt8[valueSize];
337    REG_ENSURE(!key1.getValue(OUString("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue"), (RegValue)Value), "testMerge error 84.a)");
338    REG_ENSURE(wValue.equals( (const sal_Unicode*)Value ), "testMerge error 84.b)");
339    delete [] Value;
340
341    REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey2/MK2SubKey3/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 85");
342    REG_ENSURE(valueType == RG_VALUETYPE_STRING && valueSize == strlen(sValue)+1, "testMerge error 86");
343    Value = new sal_uInt8[valueSize];
344    REG_ENSURE(!key1.getValue(OUString("/MergeKey2/MK2SubKey3/KeyWithStringValue"), (RegValue)Value), "testMerge error 86.a)");
345    REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 86.b)");
346    delete [] Value;
347
348    REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey2/MK2SubKey4/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 87");
349    REG_ENSURE(valueType == RG_VALUETYPE_LONG && valueSize == sizeof(sal_Int32), "testMerge error 88");
350    REG_ENSURE(!key1.getValue(OUString("/MergeKey2/MK2SubKey4/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 88.a)");
351    REG_ENSURE(int32Value == lValue1, "testMerge error 88.b)");
352
353    REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK1SubKey11/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 89");
354    REG_ENSURE(valueType == RG_VALUETYPE_LONG && valueSize == sizeof(sal_Int32), "testMerge error 90");
355    REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK1SubKey11/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 90.a)");
356    REG_ENSURE(int32Value == lValue2, "testMerge error 90.b)");
357
358    REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK1SubKey12/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 91");
359    REG_ENSURE(valueType == RG_VALUETYPE_STRING && valueSize == strlen(sValue)+1, "testMerge error 92");
360    Value = new sal_uInt8[valueSize];
361    REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK1SubKey12/KeyWithStringValue"), (RegValue)Value), "testMerge error 92.a)");
362    REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 92.b)");
363    delete [] Value;
364
365    REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue"), &valueType, &valueSize), "testMerge error 93");
366    REG_ENSURE(valueType == RG_VALUETYPE_UNICODE && valueSize == (wValue.getLength()+1)*sizeof(sal_Unicode), "testMerge error 94");
367    Value = new sal_uInt8[valueSize];
368    REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue"), (RegValue)Value), "testMerge error 94.a)");
369    REG_ENSURE(wValue.equals( (const sal_Unicode*)Value ), "testMerge error 94.b)");
370    delete [] Value;
371
372    REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue"), &valueType, &valueSize), "testMerge error 95");
373    REG_ENSURE(valueType == RG_VALUETYPE_BINARY && valueSize == 19, "testMerge error 96");
374    Value = new sal_uInt8[valueSize];
375    REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue"), (RegValue)Value), "testMerge error 96.a)");
376    REG_ENSURE(strcmp((const sal_Char*)Value, "a1b2c3d4e5f6g7h8i9") == 0, "testMerge error 96.b)");
377    delete [] Value;
378
379    REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK2SubKey22/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 97");
380    REG_ENSURE(valueType == RG_VALUETYPE_LONG && valueSize == sizeof(sal_Int32), "testMerge error 98");
381    REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK2SubKey22/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 98.a)");
382    REG_ENSURE(int32Value == lValue2, "testMerge error 98.b)");
383
384    REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK2SubKey23/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 99");
385    REG_ENSURE(valueType == RG_VALUETYPE_STRING && valueSize == strlen(sValue)+1, "testMerge error 100");
386    Value = new sal_uInt8[valueSize];
387    REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK2SubKey23/KeyWithStringValue"), (RegValue)Value), "testMerge error 100.a)");
388    REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 100.b)");
389    delete [] Value;
390
391    REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 101");
392    REG_ENSURE(valueType == RG_VALUETYPE_LONG && valueSize == sizeof(sal_Int32), "testMerge error 102");
393    REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 102.a)");
394    REG_ENSURE(int32Value == lValue4, "testMerge error 102.b)");
395
396
397    REG_ENSURE(!key1.closeKey(), "testMerge error 24");
398
399    ///////////////////////////////////////////////////////////////////////////
400
401    REG_ENSURE(!rootKey.closeKey(), "testMerge error 10");
402
403    REG_ENSURE(!myRegistry->destroy( OUString("merge1.rdb") ), "test_registry_CppApi error 11");
404    REG_ENSURE(!myRegistry->destroy( OUString("merge2.rdb") ), "test_registry_CppApi error 12");
405    REG_ENSURE(!myRegistry->destroy( OUString() ), "test_registry_CppApi error 13");
406
407    delete myRegistry;
408
409    cout << "test_merge() Ok!\n";
410    return;
411}
412
413
414/* vim:set shiftwidth=4 softtabstop=4 expandtab: */