update emoji autocorrect entries from po-files
[LibreOffice.git] / sal / test / testbootstrap.cxx
blob3919bcc22bdf3f61c4ed5ce35f747b676634f2f4
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>
29 int main( int argc, char *argv[] )
31 osl_setCommandArgs (argc, argv);
33 sal_Int32 nCount = rtl_getAppCommandArgCount();
35 #if OSL_DEBUG_LEVEL > 1
36 fprintf( stdout, "rtl-commandargs (%d) real args:%i ", nCount, argc);
37 for( sal_Int32 i = 0 ; i < nCount ; i ++ )
39 OUString data;
40 rtl_getAppCommandArg( i , &(data.pData) );
41 OString o = OUStringToOString( data, RTL_TEXTENCODING_ASCII_US );
42 fprintf( stdout, " %s", o.getStr() );
44 fprintf( stdout, "\n" );
45 #endif
47 if( nCount == 0 )
49 printf( "usage : testbootstrap <checkedValueOfMyBootstrapValue>\n" );
50 exit( 1 );
53 OUString iniName;
54 Bootstrap::get(OUString("iniName"), iniName, OUString());
56 #if OSL_DEBUG_LEVEL > 1
57 if(iniName.getLength())
59 OString tmp_iniName = OUStringToOString(iniName, RTL_TEXTENCODING_ASCII_US);
60 fprintf(stderr, "using ini: %s\n", tmp_iniName.getStr());
62 #endif
64 Bootstrap bootstrap(iniName);
66 OUString name( "MYBOOTSTRAPTESTVALUE" );
67 OUString myDefault("$Default");
69 OUString value;
70 sal_Bool useDefault;
72 OUString aDummy;
73 useDefault = bootstrap.getFrom(OUString("USEDEFAULT"), aDummy);
75 sal_Bool result = sal_False;
76 sal_Bool found = sal_True;
78 if(useDefault)
79 bootstrap.getFrom(name, value, myDefault);
81 else
82 found = bootstrap.getFrom(name, value);
84 if(found)
86 OUString para(OUString::createFromAscii( argv[1] ));
88 result = para == value;
90 if(!result)
92 OString para_tmp = OUStringToOString(para, RTL_TEXTENCODING_ASCII_US);
93 OString value_tmp = OUStringToOString(value, RTL_TEXTENCODING_ASCII_US);
95 fprintf(stderr, "para(%s) != value(%s)\n", para_tmp.getStr(), value_tmp.getStr());
98 else
99 fprintf(stderr, "bootstrap parameter couldn't be found\n");
101 // test the default case
102 name = "no_one_has_set_this_name";
103 OSL_ASSERT( ! bootstrap.getFrom( name, value ) );
104 result = result && !bootstrap.getFrom( name, value );
106 myDefault = "1";
107 OUString myDefault2 = "2";
109 bootstrap.getFrom( name, value, myDefault );
110 OSL_ASSERT( value == myDefault );
111 result = result && (value == myDefault);
113 bootstrap.getFrom( name, value, myDefault2 );
114 OSL_ASSERT( value == myDefault2 );
115 result = result && (value == myDefault2);
117 return result;
120 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */