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