Version 5.2.6.1, tag libreoffice-5.2.6.1
[LibreOffice.git] / registry / test / testmerge.cxx
blobcd480534abc5b203751100a80db7d31b927293de
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
21 #include <iostream>
22 #include <stdio.h>
23 #include <string.h>
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>
33 using namespace std;
36 sal_Int32 lValue1 = 123456789;
37 sal_Int32 lValue2 = 54321;
38 sal_Int32 lValue3 = 111333111;
39 sal_Int32 lValue4 = 333111333;
40 sal_Char* sValue = (sal_Char*)"string Value";
41 OUString wValue("unicode Value");
44 void test_generateMerge1()
46 Registry *myRegistry = new Registry();
48 RegistryKey rootKey, key1, key2, key3, key4, key5, key6, key7, key8, key9;
50 REG_ENSURE(!myRegistry->create(OUString("merge1.rdb")), "testGenerateMerge1 error 1");
51 REG_ENSURE(!myRegistry->openRootKey(rootKey), "testGenerateMerge1 error 2");
53 REG_ENSURE(!rootKey.createKey(OUString("MergeKey1"), key1), "testGenerateMerge1 error 3");
54 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey1"), key2), "testGenerateMerge1 error 4");
55 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey1/KeyWithLongValue"), key3), "testGenerateMerge1 error 5");
56 REG_ENSURE(!key3.setValue(OUString(), RegValueType::LONG, &lValue1, sizeof(sal_Int32)), "testGenerateMerge1 error 5a");
57 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey2"), key4), "testGenerateMerge1 error 6");
58 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey2/KeyWithStringValue"), key5), "testGenerateMerge1 error 7");
59 REG_ENSURE(!key5.setValue(OUString(), RegValueType::STRING, sValue, strlen(sValue)+1), "testGenerateMerge1 error 7a");
60 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey3"), key6), "testGenerateMerge1 error 8");
61 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue"), key7), "testGenerateMerge1 error 9");
62 REG_ENSURE(!key7.setValue(OUString(), RegValueType::UNICODE, (void*)wValue.getStr(), ((wValue.getLength()+1)*sizeof(sal_Unicode))), "testGenerateMerge1 error 9a");
63 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey4"), key8), "testGenerateMerge1 error 10");
64 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1/MK1SubKey4/KeyWithBinaryValue"), key9), "testGenerateMerge1 error 11");
65 REG_ENSURE(!key9.setValue(OUString(), RegValueType::BINARY, (void*)"abcdefghijklmnopqrstuvwxyz", 27), "testGenerateMerge1 error 11a");
68 REG_ENSURE(!key1.closeKey() &&
69 !key2.closeKey() &&
70 !key3.closeKey() &&
71 !key4.closeKey() &&
72 !key5.closeKey() &&
73 !key6.closeKey() &&
74 !key7.closeKey() &&
75 !key8.closeKey() &&
76 !key9.closeKey(), "testGenerateMerge1 error 12");
78 REG_ENSURE(!rootKey.createKey(OUString("MergeKey1u2"), key1), "testGenerateMerge1 error 13");
79 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK1SubKey11"), key2), "testGenerateMerge1 error 14");
80 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK1SubKey11/KeyWithLongValue"), key3), "testGenerateMerge1 error 15");
81 REG_ENSURE(!key3.setValue(OUString(), RegValueType::LONG, &lValue2, sizeof(sal_Int32)), "testGenerateMerge1 error 15a");
82 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK1SubKey12"), key4), "testGenerateMerge1 error 16");
83 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK1SubKey12/KeyWithStringValue"), key5), "testGenerateMerge1 error 17");
84 REG_ENSURE(!key5.setValue(OUString(), RegValueType::STRING, sValue, strlen(sValue)+1), "testGenerateMerge1 error 17a");
85 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK1SubKey13"), key6), "testGenerateMerge1 error 18");
86 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue"), key7), "testGenerateMerge1 error 19");
87 REG_ENSURE(!key7.setValue(OUString(), RegValueType::UNICODE, (void*)wValue.getStr(), ((wValue.getLength()+1)*sizeof(sal_Unicode))), "testGenerateMerge1 error 19a");
88 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK12SubKey1u2"), key8), "testGenerateMerge1 error 20");
89 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), key9), "testGenerateMerge1 error 21");
90 REG_ENSURE(!key9.setValue(OUString(), RegValueType::LONG, &lValue3, sizeof(sal_Int32)), "testGenerateMerge1 error 21a");
92 REG_ENSURE(!rootKey.closeKey() &&
93 !key1.closeKey() &&
94 !key2.closeKey() &&
95 !key3.closeKey() &&
96 !key4.closeKey() &&
97 !key5.closeKey() &&
98 !key6.closeKey() &&
99 !key7.closeKey() &&
100 !key8.closeKey() &&
101 !key9.closeKey(), "testGenerateMerge1 error 22");
104 delete myRegistry;
106 cout << "test_generateMerge1() Ok!\n";
107 return;
110 void test_generateMerge2()
112 Registry *myRegistry = new Registry();
114 RegistryKey rootKey, key1, key2, key3, key4, key5, key6, key7, key8, key9;
116 REG_ENSURE(!myRegistry->create(OUString("merge2.rdb")), "testGenerateMerge2 error 1");
117 REG_ENSURE(!myRegistry->openRootKey(rootKey), "testGenerateMerge2 error 2");
119 REG_ENSURE(!rootKey.createKey(OUString("MergeKey2"), key1), "testGenerateMerge2 error 3");
120 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey1"), key2), "testGenerateMerge2 error 4");
121 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey1/KeyWithBinaryValue"), key3), "testGenerateMerge2 error 5");
122 REG_ENSURE(!key3.setValue(OUString(), RegValueType::BINARY, (void*)"1234567890", 11), "testGenerateMerge1 error 5a");
123 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey2"), key4), "testGenerateMerge2 error 6");
124 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue"), key5), "testGenerateMerge2 error 7");
125 REG_ENSURE(!key5.setValue(OUString(), RegValueType::UNICODE, (void*)wValue.getStr(), ((wValue.getLength()+1)*sizeof(sal_Unicode))), "testGenerateMerge1 error 7a");
126 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey3"), key6), "testGenerateMerge2 error 8");
127 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey3/KeyWithStringValue"), key7), "testGenerateMerge2 error 9");
128 REG_ENSURE(!key7.setValue(OUString(), RegValueType::STRING, sValue, strlen(sValue)+1), "testGenerateMerge1 error 9a");
129 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey4"), key8), "testGenerateMerge2 error 10");
130 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey2/MK2SubKey4/KeyWithLongValue"), key9), "testGenerateMerge2 error 11");
131 REG_ENSURE(!key9.setValue(OUString(), RegValueType::LONG, &lValue1, sizeof(sal_Int32)), "testGenerateMerge1 error 11a");
133 REG_ENSURE(!key1.closeKey() &&
134 !key2.closeKey() &&
135 !key3.closeKey() &&
136 !key4.closeKey() &&
137 !key5.closeKey() &&
138 !key6.closeKey() &&
139 !key7.closeKey() &&
140 !key8.closeKey() &&
141 !key9.closeKey(), "testGenerateMerge2 error 12");
143 REG_ENSURE(!rootKey.createKey(OUString("MergeKey1u2"), key1), "testGenerateMerge2 error 13");
144 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK2SubKey21"), key2), "testGenerateMerge2 error 14");
145 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue"), key3), "testGenerateMerge2 error 15");
146 REG_ENSURE(!key3.setValue(OUString(), RegValueType::BINARY, (void*)"a1b2c3d4e5f6g7h8i9", 19), "testGenerateMerge1 error 15a");
147 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK2SubKey22"), key4), "testGenerateMerge2 error 16");
148 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK2SubKey22/KeyWithLongValue"), key5), "testGenerateMerge2 error 17");
149 REG_ENSURE(!key5.setValue(OUString(), RegValueType::LONG, &lValue2, sizeof(sal_Int32)), "testGenerateMerge1 error 17a");
150 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK2SubKey23"), key6), "testGenerateMerge2 error 18");
151 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK2SubKey23/KeyWithStringValue"), key7), "testGenerateMerge2 error 19");
152 REG_ENSURE(!key7.setValue(OUString(), RegValueType::STRING, sValue, strlen(sValue)+1), "testGenerateMerge1 error 19a");
153 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK12SubKey1u2"), key8), "testGenerateMerge2 error 20");
154 REG_ENSURE(!rootKey.createKey(OUString("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), key9), "testGenerateMerge2 error 21");
155 REG_ENSURE(!key9.setValue(OUString(), RegValueType::LONG, &lValue4, sizeof(sal_Int32)), "testGenerateMerge1 error 21a");
157 REG_ENSURE(!rootKey.closeKey() &&
158 !key1.closeKey() &&
159 !key2.closeKey() &&
160 !key3.closeKey() &&
161 !key4.closeKey() &&
162 !key5.closeKey() &&
163 !key6.closeKey() &&
164 !key7.closeKey() &&
165 !key8.closeKey() &&
166 !key9.closeKey(), "testGenerateMerge2 error 22");
169 delete myRegistry;
171 cout << "test_generateMerge2() Ok!\n";
172 return;
175 void test_merge()
177 Registry *myRegistry = new Registry();
179 RegistryKey rootKey, key1, mkey1, key2, mkey2, key1u2, mkey1u2;
181 REG_ENSURE(!myRegistry->create(OUString("mergetest.rdb")), "testMerge error 1");
182 REG_ENSURE(myRegistry->getName() == "mergetest.rdb", "testMerge error 1.a)");
183 REG_ENSURE(!myRegistry->openRootKey(rootKey), "testMerge error 2");
184 REG_ENSURE(!myRegistry->loadKey(rootKey, OUString("/stardiv/IchbineinMergeKey"),
185 OUString("merge1.rdb")), "testMerge error 3");
186 REG_ENSURE(!myRegistry->mergeKey(rootKey, OUString("/stardiv/IchbineinMergeKey"),
187 OUString("merge2.rdb")), "testMerge error 4");
190 REG_ENSURE(!rootKey.openKey("/stardiv/IchbineinMergeKey", key1), "testMerge error 5");
192 REG_ENSURE(!key1.openKey("MergeKey1", mkey1), "testMerge error 6");
193 REG_ENSURE(!mkey1.closeKey(), "testMerge error 7");
195 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey1", mkey1), "testMerge error 8");
196 REG_ENSURE(!mkey1.closeKey(), "testMerge error 9");
197 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey1/KeyWithLongValue", mkey1), "testMerge error 10");
198 REG_ENSURE(!mkey1.closeKey(), "testMerge error 11");
200 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey2", mkey1), "testMerge error 12");
201 REG_ENSURE(!mkey1.closeKey(), "testMerge error 13");
202 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey2/KeyWithStringValue", mkey1), "testMerge error 14");
203 REG_ENSURE(!mkey1.closeKey(), "testMerge error 15");
205 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey3", mkey1), "testMerge error 16");
206 REG_ENSURE(!mkey1.closeKey(), "testMerge error 17");
207 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue", mkey1), "testMerge error 18");
208 REG_ENSURE(!mkey1.closeKey(), "testMerge error 19");
210 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey4", mkey1), "testMerge error 20");
211 REG_ENSURE(!mkey1.closeKey(), "testMerge error 21");
212 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey4/KeyWithBinaryValue", mkey1), "testMerge error 22");
213 REG_ENSURE(!mkey1.closeKey(), "testMerge error 23");
215 REG_ENSURE(!key1.closeKey(), "testMerge error 24");
218 REG_ENSURE(!rootKey.openKey("/stardiv/IchbineinMergeKey", key2), "testMerge error 25");
220 REG_ENSURE(!key2.openKey("MergeKey2", mkey2), "testMerge error 26");
221 REG_ENSURE(!mkey2.closeKey(), "testMerge error 27");
223 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey1", mkey2), "testMerge error 28");
224 REG_ENSURE(!mkey2.closeKey(), "testMerge error 29");
225 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey1/KeyWithBinaryValue", mkey2), "testMerge error 30");
226 REG_ENSURE(!mkey2.closeKey(), "testMerge error 31");
228 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey2", mkey2), "testMerge error 31");
229 REG_ENSURE(!mkey2.closeKey(), "testMerge error 33");
230 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue", mkey2), "testMerge error 34");
231 REG_ENSURE(!mkey2.closeKey(), "testMerge error 35");
233 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey3", mkey2), "testMerge error 36");
234 REG_ENSURE(!mkey2.closeKey(), "testMerge error 37");
235 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey3/KeyWithStringValue", mkey2), "testMerge error 38");
236 REG_ENSURE(!mkey2.closeKey(), "testMerge error 39");
238 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey4", mkey2), "testMerge error 40");
239 REG_ENSURE(!mkey2.closeKey(), "testMerge error 41");
240 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey4/KeyWithLongValue", mkey2), "testMerge error 42");
241 REG_ENSURE(!mkey2.closeKey(), "testMerge error 43");
243 REG_ENSURE(!key2.closeKey(), "testMerge error 44");
246 REG_ENSURE(!rootKey.openKey("/stardiv/IchbineinMergeKey", key1u2), "testMerge error 40");
248 REG_ENSURE(!key1u2.openKey("MergeKey1u2", mkey1u2), "testMerge error 41");
249 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 42");
251 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK1SubKey11", mkey1u2), "testMerge error 43");
252 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 44");
253 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK1SubKey11/KeyWithLongValue", mkey1u2), "testMerge error 45");
254 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 46");
256 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK1SubKey12", mkey1u2), "testMerge error 47");
257 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 48");
258 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK1SubKey12/KeyWithStringValue", mkey1u2), "testMerge error 49");
259 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 50");
261 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK1SubKey13", mkey1u2), "testMerge error 51");
262 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 52");
263 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue", mkey1u2), "testMerge error 53");
264 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 54");
266 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK2SubKey21", mkey1u2), "testMerge error 55");
267 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 56");
268 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue", mkey1u2), "testMerge error 57");
269 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 58");
271 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK2SubKey22", mkey1u2), "testMerge error 59");
272 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 60");
273 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK2SubKey22/KeyWithLongValue", mkey1u2), "testMerge error 61");
274 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 62");
276 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK2SubKey23", mkey1u2), "testMerge error 63");
277 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 64");
278 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK2SubKey23/KeyWithStringValue", mkey1u2), "testMerge error 65");
279 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 66");
281 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK12SubKey1u2", mkey1u2), "testMerge error 67");
282 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 68");
283 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue", mkey1u2), "testMerge error 69");
284 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 70");
286 REG_ENSURE(!key1u2.closeKey(), "testMerge error 71");
289 RegValueType valueType;
290 sal_uInt32 valueSize;
291 sal_Int32 int32Value;
292 sal_uInt8 *Value;
294 REG_ENSURE(!rootKey.openKey("/stardiv/IchbineinMergeKey", key1), "testMerge error 72");
296 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1/MK1SubKey1/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 73");
297 REG_ENSURE(valueType == RegValueType::LONG && valueSize == sizeof(sal_Int32), "testMerge error 74");
298 REG_ENSURE(!key1.getValue(OUString("/MergeKey1/MK1SubKey1/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 74.a)");
299 REG_ENSURE(int32Value == lValue1, "testMerge error 74.b)");
301 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1/MK1SubKey2/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 75");
302 REG_ENSURE(valueType == RegValueType::STRING && valueSize == strlen(sValue)+1, "testMerge error 76");
303 Value = new sal_uInt8[valueSize];
304 REG_ENSURE(!key1.getValue(OUString("/MergeKey1/MK1SubKey2/KeyWithStringValue"), (RegValue)Value), "testMerge error 76.a)");
305 REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 76.b)");
306 delete [] Value;
308 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue"), &valueType, &valueSize), "testMerge error 77");
309 REG_ENSURE(valueType == RegValueType::UNICODE && valueSize == (wValue.getLength()+1)*sizeof(sal_Unicode), "testMerge error 78");
310 Value = new sal_uInt8[valueSize];
311 REG_ENSURE(!key1.getValue(OUString("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue"), (RegValue)Value), "testMerge error 78.a)");
312 REG_ENSURE(wValue.equals( (const sal_Unicode*)Value ), "testMerge error 78.b)");
313 delete [] Value;
315 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1/MK1SubKey4/KeyWithBinaryValue"), &valueType, &valueSize), "testMerge error 79");
316 REG_ENSURE(valueType == RegValueType::BINARY && valueSize == 27, "testMerge error 80");
317 Value = new sal_uInt8[valueSize];
318 REG_ENSURE(!key1.getValue(OUString("/MergeKey1/MK1SubKey4/KeyWithBinaryValue"), (RegValue)Value), "testMerge error 80.a)");
319 REG_ENSURE(strcmp((const sal_Char*)Value, "abcdefghijklmnopqrstuvwxyz") == 0, "testMerge error 80.b)");
320 delete [] Value;
322 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey2/MK2SubKey1/KeyWithBinaryValue"), &valueType, &valueSize), "testMerge error 81");
323 REG_ENSURE(valueType == RegValueType::BINARY && valueSize == 11, "testMerge error 82");
324 Value = new sal_uInt8[valueSize];
325 REG_ENSURE(!key1.getValue(OUString("/MergeKey2/MK2SubKey1/KeyWithBinaryValue"), (RegValue)Value), "testMerge error 82.a)");
326 REG_ENSURE(strcmp((const sal_Char*)Value, "1234567890") == 0, "testMerge error 82.b)");
327 delete [] Value;
329 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue"), &valueType, &valueSize), "testMerge error 83");
330 REG_ENSURE(valueType == RegValueType::UNICODE&& valueSize == (wValue.getLength()+1)*sizeof(sal_Unicode), "testMerge error 84");
331 Value = new sal_uInt8[valueSize];
332 REG_ENSURE(!key1.getValue(OUString("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue"), (RegValue)Value), "testMerge error 84.a)");
333 REG_ENSURE(wValue.equals( (const sal_Unicode*)Value ), "testMerge error 84.b)");
334 delete [] Value;
336 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey2/MK2SubKey3/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 85");
337 REG_ENSURE(valueType == RegValueType::STRING && valueSize == strlen(sValue)+1, "testMerge error 86");
338 Value = new sal_uInt8[valueSize];
339 REG_ENSURE(!key1.getValue(OUString("/MergeKey2/MK2SubKey3/KeyWithStringValue"), (RegValue)Value), "testMerge error 86.a)");
340 REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 86.b)");
341 delete [] Value;
343 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey2/MK2SubKey4/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 87");
344 REG_ENSURE(valueType == RegValueType::LONG && valueSize == sizeof(sal_Int32), "testMerge error 88");
345 REG_ENSURE(!key1.getValue(OUString("/MergeKey2/MK2SubKey4/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 88.a)");
346 REG_ENSURE(int32Value == lValue1, "testMerge error 88.b)");
348 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK1SubKey11/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 89");
349 REG_ENSURE(valueType == RegValueType::LONG && valueSize == sizeof(sal_Int32), "testMerge error 90");
350 REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK1SubKey11/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 90.a)");
351 REG_ENSURE(int32Value == lValue2, "testMerge error 90.b)");
353 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK1SubKey12/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 91");
354 REG_ENSURE(valueType == RegValueType::STRING && valueSize == strlen(sValue)+1, "testMerge error 92");
355 Value = new sal_uInt8[valueSize];
356 REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK1SubKey12/KeyWithStringValue"), (RegValue)Value), "testMerge error 92.a)");
357 REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 92.b)");
358 delete [] Value;
360 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue"), &valueType, &valueSize), "testMerge error 93");
361 REG_ENSURE(valueType == RegValueType::UNICODE && valueSize == (wValue.getLength()+1)*sizeof(sal_Unicode), "testMerge error 94");
362 Value = new sal_uInt8[valueSize];
363 REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue"), (RegValue)Value), "testMerge error 94.a)");
364 REG_ENSURE(wValue.equals( (const sal_Unicode*)Value ), "testMerge error 94.b)");
365 delete [] Value;
367 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue"), &valueType, &valueSize), "testMerge error 95");
368 REG_ENSURE(valueType == RegValueType::BINARY && valueSize == 19, "testMerge error 96");
369 Value = new sal_uInt8[valueSize];
370 REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue"), (RegValue)Value), "testMerge error 96.a)");
371 REG_ENSURE(strcmp((const sal_Char*)Value, "a1b2c3d4e5f6g7h8i9") == 0, "testMerge error 96.b)");
372 delete [] Value;
374 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK2SubKey22/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 97");
375 REG_ENSURE(valueType == RegValueType::LONG && valueSize == sizeof(sal_Int32), "testMerge error 98");
376 REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK2SubKey22/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 98.a)");
377 REG_ENSURE(int32Value == lValue2, "testMerge error 98.b)");
379 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK2SubKey23/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 99");
380 REG_ENSURE(valueType == RegValueType::STRING && valueSize == strlen(sValue)+1, "testMerge error 100");
381 Value = new sal_uInt8[valueSize];
382 REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK2SubKey23/KeyWithStringValue"), (RegValue)Value), "testMerge error 100.a)");
383 REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 100.b)");
384 delete [] Value;
386 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 101");
387 REG_ENSURE(valueType == RegValueType::LONG && valueSize == sizeof(sal_Int32), "testMerge error 102");
388 REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 102.a)");
389 REG_ENSURE(int32Value == lValue4, "testMerge error 102.b)");
392 REG_ENSURE(!key1.closeKey(), "testMerge error 24");
395 REG_ENSURE(!rootKey.closeKey(), "testMerge error 10");
397 REG_ENSURE(!myRegistry->destroy( OUString("merge1.rdb") ), "test_registry_CppApi error 11");
398 REG_ENSURE(!myRegistry->destroy( OUString("merge2.rdb") ), "test_registry_CppApi error 12");
399 REG_ENSURE(!myRegistry->destroy( OUString() ), "test_registry_CppApi error 13");
401 delete myRegistry;
403 cout << "test_merge() Ok!\n";
404 return;
408 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */