xref: /AOO41X/main/sal/qa/osl/profile/osl_old_testprofile.cxx (revision 87d2adbc9cadf14644c3679b041b9226f7630199)
1 /**************************************************************
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one
4  * or more contributor license agreements.  See the NOTICE file
5  * distributed with this work for additional information
6  * regarding copyright ownership.  The ASF licenses this file
7  * to you under the Apache License, Version 2.0 (the
8  * "License"); you may not use this file except in compliance
9  * with the License.  You may obtain a copy of the License at
10  *
11  *   http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing,
14  * software distributed under the License is distributed on an
15  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16  * KIND, either express or implied.  See the License for the
17  * specific language governing permissions and limitations
18  * under the License.
19  *
20  *************************************************************/
21 
22 
23 
24 // MARKER(update_precomp.py): autogen include statement, do not remove
25 #include "precompiled_sal.hxx"
26 
27 // LLA:
28 // this file is converted to use with testshl2
29 // original was placed in sal/test/textenc.cxx
30 
31 
32 // -----------------------------------------------------------------------------
33 #include <stdio.h>
34 #include <osl/profile.h>
35 
36 #include "cppunit/TestAssert.h"
37 #include "cppunit/TestFixture.h"
38 #include "cppunit/extensions/HelperMacros.h"
39 #include "cppunit/plugin/TestPlugIn.h"
40 
41 //==================================================================================================
42 // -----------------------------------------------------------------------------
43 namespace osl_Profile
44 {
45     class oldtests : public CppUnit::TestFixture
46     {
47     public:
48         void test_profile();
49 
50         CPPUNIT_TEST_SUITE( oldtests );
51         CPPUNIT_TEST( test_profile );
52         CPPUNIT_TEST_SUITE_END( );
53     };
54 
test_profile(void)55 void oldtests::test_profile(void)
56 {
57     oslProfile hProfile;
58     rtl_uString* ustrProfileName=0;
59     rtl_uString* ustrProfileName2=0;
60 
61     rtl_uString_newFromAscii(&ustrProfileName,"//./tmp/soffice.ini");
62     rtl_uString_newFromAscii(&ustrProfileName2,"//./tmp/not_existing_path/soffice.ini");
63 
64 
65     // successful write
66     hProfile = osl_openProfile( ustrProfileName, 0 );
67     if (hProfile != 0)
68     {
69         if (! osl_writeProfileBool( hProfile, "testsection", "testbool", 1 ))
70             printf( "### cannot write into init file!\n" );
71 
72         osl_closeProfile( hProfile );
73     }
74 
75     // unsuccessful write
76     hProfile = osl_openProfile( ustrProfileName2, 0 );
77     if (hProfile != 0)
78     {
79         if (osl_writeProfileBool( hProfile, "testsection", "testbool", 1 ))
80             printf( "### unexpected success writing into test2.ini!\n" );
81 
82         osl_closeProfile( hProfile );
83     }
84 
85     rtl_uString_release(ustrProfileName);
86     rtl_uString_release(ustrProfileName2);
87 }
88 
89 } // namespace osl_Profile
90 
91 // -----------------------------------------------------------------------------
92 CPPUNIT_TEST_SUITE_REGISTRATION( osl_Profile::oldtests );
93 
94 // -----------------------------------------------------------------------------
95 CPPUNIT_PLUGIN_IMPLEMENT();
96