Branch libreoffice-5-0-4
[LibreOffice.git] / registry / test / testmerge.cxx
blob48eb384473b6871e3f63304c576469ebee197e11
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");
191 REG_ENSURE(!rootKey.openKey("/stardiv/IchbineinMergeKey", key1), "testMerge error 5");
193 REG_ENSURE(!key1.openKey("MergeKey1", mkey1), "testMerge error 6");
194 REG_ENSURE(!mkey1.closeKey(), "testMerge error 7");
196 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey1", mkey1), "testMerge error 8");
197 REG_ENSURE(!mkey1.closeKey(), "testMerge error 9");
198 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey1/KeyWithLongValue", mkey1), "testMerge error 10");
199 REG_ENSURE(!mkey1.closeKey(), "testMerge error 11");
201 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey2", mkey1), "testMerge error 12");
202 REG_ENSURE(!mkey1.closeKey(), "testMerge error 13");
203 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey2/KeyWithStringValue", mkey1), "testMerge error 14");
204 REG_ENSURE(!mkey1.closeKey(), "testMerge error 15");
206 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey3", mkey1), "testMerge error 16");
207 REG_ENSURE(!mkey1.closeKey(), "testMerge error 17");
208 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue", mkey1), "testMerge error 18");
209 REG_ENSURE(!mkey1.closeKey(), "testMerge error 19");
211 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey4", mkey1), "testMerge error 20");
212 REG_ENSURE(!mkey1.closeKey(), "testMerge error 21");
213 REG_ENSURE(!key1.openKey("/MergeKey1/MK1SubKey4/KeyWithBinaryValue", mkey1), "testMerge error 22");
214 REG_ENSURE(!mkey1.closeKey(), "testMerge error 23");
216 REG_ENSURE(!key1.closeKey(), "testMerge error 24");
220 REG_ENSURE(!rootKey.openKey("/stardiv/IchbineinMergeKey", key2), "testMerge error 25");
222 REG_ENSURE(!key2.openKey("MergeKey2", mkey2), "testMerge error 26");
223 REG_ENSURE(!mkey2.closeKey(), "testMerge error 27");
225 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey1", mkey2), "testMerge error 28");
226 REG_ENSURE(!mkey2.closeKey(), "testMerge error 29");
227 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey1/KeyWithBinaryValue", mkey2), "testMerge error 30");
228 REG_ENSURE(!mkey2.closeKey(), "testMerge error 31");
230 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey2", mkey2), "testMerge error 31");
231 REG_ENSURE(!mkey2.closeKey(), "testMerge error 33");
232 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue", mkey2), "testMerge error 34");
233 REG_ENSURE(!mkey2.closeKey(), "testMerge error 35");
235 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey3", mkey2), "testMerge error 36");
236 REG_ENSURE(!mkey2.closeKey(), "testMerge error 37");
237 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey3/KeyWithStringValue", mkey2), "testMerge error 38");
238 REG_ENSURE(!mkey2.closeKey(), "testMerge error 39");
240 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey4", mkey2), "testMerge error 40");
241 REG_ENSURE(!mkey2.closeKey(), "testMerge error 41");
242 REG_ENSURE(!key2.openKey("/MergeKey2/MK2SubKey4/KeyWithLongValue", mkey2), "testMerge error 42");
243 REG_ENSURE(!mkey2.closeKey(), "testMerge error 43");
245 REG_ENSURE(!key2.closeKey(), "testMerge error 44");
249 REG_ENSURE(!rootKey.openKey("/stardiv/IchbineinMergeKey", key1u2), "testMerge error 40");
251 REG_ENSURE(!key1u2.openKey("MergeKey1u2", mkey1u2), "testMerge error 41");
252 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 42");
254 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK1SubKey11", mkey1u2), "testMerge error 43");
255 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 44");
256 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK1SubKey11/KeyWithLongValue", mkey1u2), "testMerge error 45");
257 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 46");
259 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK1SubKey12", mkey1u2), "testMerge error 47");
260 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 48");
261 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK1SubKey12/KeyWithStringValue", mkey1u2), "testMerge error 49");
262 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 50");
264 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK1SubKey13", mkey1u2), "testMerge error 51");
265 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 52");
266 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue", mkey1u2), "testMerge error 53");
267 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 54");
269 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK2SubKey21", mkey1u2), "testMerge error 55");
270 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 56");
271 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue", mkey1u2), "testMerge error 57");
272 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 58");
274 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK2SubKey22", mkey1u2), "testMerge error 59");
275 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 60");
276 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK2SubKey22/KeyWithLongValue", mkey1u2), "testMerge error 61");
277 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 62");
279 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK2SubKey23", mkey1u2), "testMerge error 63");
280 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 64");
281 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK2SubKey23/KeyWithStringValue", mkey1u2), "testMerge error 65");
282 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 66");
284 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK12SubKey1u2", mkey1u2), "testMerge error 67");
285 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 68");
286 REG_ENSURE(!key1u2.openKey("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue", mkey1u2), "testMerge error 69");
287 REG_ENSURE(!mkey1u2.closeKey(), "testMerge error 70");
289 REG_ENSURE(!key1u2.closeKey(), "testMerge error 71");
293 RegValueType valueType;
294 sal_uInt32 valueSize;
295 sal_Int32 int32Value;
296 sal_uInt8 *Value;
298 REG_ENSURE(!rootKey.openKey("/stardiv/IchbineinMergeKey", key1), "testMerge error 72");
300 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1/MK1SubKey1/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 73");
301 REG_ENSURE(valueType == RegValueType::LONG && valueSize == sizeof(sal_Int32), "testMerge error 74");
302 REG_ENSURE(!key1.getValue(OUString("/MergeKey1/MK1SubKey1/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 74.a)");
303 REG_ENSURE(int32Value == lValue1, "testMerge error 74.b)");
305 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1/MK1SubKey2/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 75");
306 REG_ENSURE(valueType == RegValueType::STRING && valueSize == strlen(sValue)+1, "testMerge error 76");
307 Value = new sal_uInt8[valueSize];
308 REG_ENSURE(!key1.getValue(OUString("/MergeKey1/MK1SubKey2/KeyWithStringValue"), (RegValue)Value), "testMerge error 76.a)");
309 REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 76.b)");
310 delete [] Value;
312 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue"), &valueType, &valueSize), "testMerge error 77");
313 REG_ENSURE(valueType == RegValueType::UNICODE && valueSize == (wValue.getLength()+1)*sizeof(sal_Unicode), "testMerge error 78");
314 Value = new sal_uInt8[valueSize];
315 REG_ENSURE(!key1.getValue(OUString("/MergeKey1/MK1SubKey3/KeyWithUnicodeValue"), (RegValue)Value), "testMerge error 78.a)");
316 REG_ENSURE(wValue.equals( (const sal_Unicode*)Value ), "testMerge error 78.b)");
317 delete [] Value;
319 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1/MK1SubKey4/KeyWithBinaryValue"), &valueType, &valueSize), "testMerge error 79");
320 REG_ENSURE(valueType == RegValueType::BINARY && valueSize == 27, "testMerge error 80");
321 Value = new sal_uInt8[valueSize];
322 REG_ENSURE(!key1.getValue(OUString("/MergeKey1/MK1SubKey4/KeyWithBinaryValue"), (RegValue)Value), "testMerge error 80.a)");
323 REG_ENSURE(strcmp((const sal_Char*)Value, "abcdefghijklmnopqrstuvwxyz") == 0, "testMerge error 80.b)");
324 delete [] Value;
326 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey2/MK2SubKey1/KeyWithBinaryValue"), &valueType, &valueSize), "testMerge error 81");
327 REG_ENSURE(valueType == RegValueType::BINARY && valueSize == 11, "testMerge error 82");
328 Value = new sal_uInt8[valueSize];
329 REG_ENSURE(!key1.getValue(OUString("/MergeKey2/MK2SubKey1/KeyWithBinaryValue"), (RegValue)Value), "testMerge error 82.a)");
330 REG_ENSURE(strcmp((const sal_Char*)Value, "1234567890") == 0, "testMerge error 82.b)");
331 delete [] Value;
333 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue"), &valueType, &valueSize), "testMerge error 83");
334 REG_ENSURE(valueType == RegValueType::UNICODE&& valueSize == (wValue.getLength()+1)*sizeof(sal_Unicode), "testMerge error 84");
335 Value = new sal_uInt8[valueSize];
336 REG_ENSURE(!key1.getValue(OUString("/MergeKey2/MK2SubKey2/KeyWithUnicodeValue"), (RegValue)Value), "testMerge error 84.a)");
337 REG_ENSURE(wValue.equals( (const sal_Unicode*)Value ), "testMerge error 84.b)");
338 delete [] Value;
340 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey2/MK2SubKey3/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 85");
341 REG_ENSURE(valueType == RegValueType::STRING && valueSize == strlen(sValue)+1, "testMerge error 86");
342 Value = new sal_uInt8[valueSize];
343 REG_ENSURE(!key1.getValue(OUString("/MergeKey2/MK2SubKey3/KeyWithStringValue"), (RegValue)Value), "testMerge error 86.a)");
344 REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 86.b)");
345 delete [] Value;
347 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey2/MK2SubKey4/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 87");
348 REG_ENSURE(valueType == RegValueType::LONG && valueSize == sizeof(sal_Int32), "testMerge error 88");
349 REG_ENSURE(!key1.getValue(OUString("/MergeKey2/MK2SubKey4/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 88.a)");
350 REG_ENSURE(int32Value == lValue1, "testMerge error 88.b)");
352 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK1SubKey11/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 89");
353 REG_ENSURE(valueType == RegValueType::LONG && valueSize == sizeof(sal_Int32), "testMerge error 90");
354 REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK1SubKey11/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 90.a)");
355 REG_ENSURE(int32Value == lValue2, "testMerge error 90.b)");
357 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK1SubKey12/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 91");
358 REG_ENSURE(valueType == RegValueType::STRING && valueSize == strlen(sValue)+1, "testMerge error 92");
359 Value = new sal_uInt8[valueSize];
360 REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK1SubKey12/KeyWithStringValue"), (RegValue)Value), "testMerge error 92.a)");
361 REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 92.b)");
362 delete [] Value;
364 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue"), &valueType, &valueSize), "testMerge error 93");
365 REG_ENSURE(valueType == RegValueType::UNICODE && valueSize == (wValue.getLength()+1)*sizeof(sal_Unicode), "testMerge error 94");
366 Value = new sal_uInt8[valueSize];
367 REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK1SubKey13/KeyWithUnicodeValue"), (RegValue)Value), "testMerge error 94.a)");
368 REG_ENSURE(wValue.equals( (const sal_Unicode*)Value ), "testMerge error 94.b)");
369 delete [] Value;
371 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue"), &valueType, &valueSize), "testMerge error 95");
372 REG_ENSURE(valueType == RegValueType::BINARY && valueSize == 19, "testMerge error 96");
373 Value = new sal_uInt8[valueSize];
374 REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK2SubKey21/KeyWithBinaryValue"), (RegValue)Value), "testMerge error 96.a)");
375 REG_ENSURE(strcmp((const sal_Char*)Value, "a1b2c3d4e5f6g7h8i9") == 0, "testMerge error 96.b)");
376 delete [] Value;
378 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK2SubKey22/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 97");
379 REG_ENSURE(valueType == RegValueType::LONG && valueSize == sizeof(sal_Int32), "testMerge error 98");
380 REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK2SubKey22/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 98.a)");
381 REG_ENSURE(int32Value == lValue2, "testMerge error 98.b)");
383 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK2SubKey23/KeyWithStringValue"), &valueType, &valueSize), "testMerge error 99");
384 REG_ENSURE(valueType == RegValueType::STRING && valueSize == strlen(sValue)+1, "testMerge error 100");
385 Value = new sal_uInt8[valueSize];
386 REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK2SubKey23/KeyWithStringValue"), (RegValue)Value), "testMerge error 100.a)");
387 REG_ENSURE(strcmp((const sal_Char*)Value, sValue) == 0, "testMerge error 100.b)");
388 delete [] Value;
390 REG_ENSURE(!key1.getValueInfo(OUString("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), &valueType, &valueSize), "testMerge error 101");
391 REG_ENSURE(valueType == RegValueType::LONG && valueSize == sizeof(sal_Int32), "testMerge error 102");
392 REG_ENSURE(!key1.getValue(OUString("/MergeKey1u2/MK12SubKey1u2/KeyWithLongValue"), (RegValue)&int32Value), "testMerge error 102.a)");
393 REG_ENSURE(int32Value == lValue4, "testMerge error 102.b)");
396 REG_ENSURE(!key1.closeKey(), "testMerge error 24");
400 REG_ENSURE(!rootKey.closeKey(), "testMerge error 10");
402 REG_ENSURE(!myRegistry->destroy( OUString("merge1.rdb") ), "test_registry_CppApi error 11");
403 REG_ENSURE(!myRegistry->destroy( OUString("merge2.rdb") ), "test_registry_CppApi error 12");
404 REG_ENSURE(!myRegistry->destroy( OUString() ), "test_registry_CppApi error 13");
406 delete myRegistry;
408 cout << "test_merge() Ok!\n";
409 return;
413 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */