GPU-Calc: remove Alloc_Host_Ptr for clmem of NAN vector
[LibreOffice.git] / sal / test / testbootstrap.cxx
bloba7eee9a9bfc078b79111c87064b68f4d3e2f49de
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 <stdio.h>
23 #include <rtl/process.h>
24 #include <rtl/bootstrap.hxx>
25 #include <rtl/string.hxx>
26 #include <rtl/byteseq.hxx>
28 #include <osl/process.h>
30 using namespace ::rtl;
33 int main( int argc, char *argv[] )
35 osl_setCommandArgs (argc, argv);
37 sal_Int32 nCount = rtl_getAppCommandArgCount();
39 #if OSL_DEBUG_LEVEL > 1
40 fprintf( stdout, "rtl-commandargs (%d) real args:%i ", nCount, argc);
41 for( sal_Int32 i = 0 ; i < nCount ; i ++ )
43 OUString data;
44 rtl_getAppCommandArg( i , &(data.pData) );
45 OString o = OUStringToOString( data, RTL_TEXTENCODING_ASCII_US );
46 fprintf( stdout, " %s", o.getStr() );
48 fprintf( stdout, "\n" );
49 #endif
51 if( nCount == 0 )
53 printf( "usage : testbootstrap <checkedValueOfMyBootstrapValue>\n" );
54 exit( 1 );
58 OUString iniName;
59 Bootstrap::get(OUString("iniName"), iniName, OUString());
61 #if OSL_DEBUG_LEVEL > 1
62 if(iniName.getLength())
64 OString tmp_iniName = OUStringToOString(iniName, RTL_TEXTENCODING_ASCII_US);
65 fprintf(stderr, "using ini: %s\n", tmp_iniName.getStr());
67 #endif
69 Bootstrap bootstrap(iniName);
72 OUString name( "MYBOOTSTRAPTESTVALUE" );
73 OUString myDefault("$Default");
75 OUString value;
76 sal_Bool useDefault;
78 OUString aDummy;
79 useDefault = bootstrap.getFrom(OUString("USEDEFAULT"), aDummy);
81 sal_Bool result = sal_False;
82 sal_Bool found = sal_True;
84 if(useDefault)
85 bootstrap.getFrom(name, value, myDefault);
87 else
88 found = bootstrap.getFrom(name, value);
90 if(found)
92 OUString para(OUString::createFromAscii( argv[1] ));
94 result = para == value;
96 if(!result)
98 OString para_tmp = OUStringToOString(para, RTL_TEXTENCODING_ASCII_US);
99 OString value_tmp = OUStringToOString(value, RTL_TEXTENCODING_ASCII_US);
101 fprintf(stderr, "para(%s) != value(%s)\n", para_tmp.getStr(), value_tmp.getStr());
104 else
105 fprintf(stderr, "bootstrap parameter couldn't be found\n");
107 // test the default case
108 name = "no_one_has_set_this_name";
109 OSL_ASSERT( ! bootstrap.getFrom( name, value ) );
110 result = result && !bootstrap.getFrom( name, value );
112 myDefault = "1";
113 OUString myDefault2 = "2";
115 bootstrap.getFrom( name, value, myDefault );
116 OSL_ASSERT( value == myDefault );
117 result = result && (value == myDefault);
119 bootstrap.getFrom( name, value, myDefault2 );
120 OSL_ASSERT( value == myDefault2 );
121 result = result && (value == myDefault2);
123 return result;
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */