tdf#130857 qt weld: Implement QtInstanceWidget::get_text_height
[LibreOffice.git] / sal / test / testbootstrap.cxx
blob9ae34f78c588d2d1964c1ff628f7d7212c0d73e1
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 .
20 #include <stdio.h>
22 #include <rtl/process.h>
23 #include <rtl/bootstrap.hxx>
24 #include <rtl/string.hxx>
25 #include <rtl/byteseq.hxx>
27 #include <osl/process.h>
28 #include <sal/log.hxx>
30 int main( int argc, char *argv[] )
32 osl_setCommandArgs (argc, argv);
34 sal_Int32 nCount = rtl_getAppCommandArgCount();
36 #if OSL_DEBUG_LEVEL > 0
37 OUStringBuffer debugBuff;
38 debugBuff.append("rtl-commandargs (").append(nCount).append(")real args: ").append(argc);
39 for( sal_Int32 i = 0 ; i < nCount ; i ++ )
41 OUString data;
42 rtl_getAppCommandArg( i , &(data.pData) );
43 OString o = OUStringToOString( data, RTL_TEXTENCODING_ASCII_US );
44 debugBuff.append(" ").append(o);
46 SAL_INFO("sal.test", debugBuff.toString());
47 #endif
49 if( nCount == 0 )
51 printf( "usage : testbootstrap <checkedValueOfMyBootstrapValue>\n" );
52 exit( 1 );
55 OUString iniName;
56 Bootstrap::get(OUString("iniName"), iniName, OUString());
58 SAL_INFO_IF(!iniName.isEmpty(), "sal.test", "using ini: " << iniName);
60 Bootstrap bootstrap(iniName);
62 OUString name( "MYBOOTSTRAPTESTVALUE" );
63 OUString myDefault("$Default");
65 OUString value;
66 sal_Bool useDefault;
68 OUString aDummy;
69 useDefault = bootstrap.getFrom(OUString("USEDEFAULT"), aDummy);
71 sal_Bool result = sal_False;
72 sal_Bool found = sal_True;
74 if(useDefault)
75 bootstrap.getFrom(name, value, myDefault);
77 else
78 found = bootstrap.getFrom(name, value);
80 if(found)
82 OUString para(OUString::createFromAscii( argv[1] ));
84 result = para == value;
86 if(!result)
88 OString para_tmp = OUStringToOString(para, RTL_TEXTENCODING_ASCII_US);
89 OString value_tmp = OUStringToOString(value, RTL_TEXTENCODING_ASCII_US);
91 fprintf(stderr, "para(%s) != value(%s)\n", para_tmp.getStr(), value_tmp.getStr());
94 else
95 fprintf(stderr, "bootstrap parameter couldn't be found\n");
97 // test the default case
98 name = "no_one_has_set_this_name";
99 OSL_ASSERT( ! bootstrap.getFrom( name, value ) );
100 result = result && !bootstrap.getFrom( name, value );
102 myDefault = "1";
103 OUString myDefault2 = "2";
105 bootstrap.getFrom( name, value, myDefault );
106 OSL_ASSERT( value == myDefault );
107 result = result && (value == myDefault);
109 bootstrap.getFrom( name, value, myDefault2 );
110 OSL_ASSERT( value == myDefault2 );
111 result = result && (value == myDefault2);
113 return result;
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */