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