1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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 .
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
++ )
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());
51 printf( "usage : testbootstrap <checkedValueOfMyBootstrapValue>\n" );
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");
69 useDefault
= bootstrap
.getFrom(OUString("USEDEFAULT"), aDummy
);
71 sal_Bool result
= sal_False
;
72 sal_Bool found
= sal_True
;
75 bootstrap
.getFrom(name
, value
, myDefault
);
78 found
= bootstrap
.getFrom(name
, value
);
82 OUString
para(OUString::createFromAscii( argv
[1] ));
84 result
= para
== value
;
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());
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
);
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
);
116 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */