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_cppuhelper.hxx"
26 #include <cppuhelper/proptypehlp.hxx>
27 
28 #include <com/sun/star/beans/Property.hpp>
29 
30 using namespace ::com::sun::star::uno;
31 using namespace ::cppu;
32 
testPropertyTypeHelper()33 void testPropertyTypeHelper()
34 {
35 	Any a;
36 
37 	a <<= ( sal_Int8 ) 25;
38 
39 	sal_Int32 i;
40 	convertPropertyValue( i ,  a );
41 	OSL_ASSERT( 25 == i );
42 
43 	sal_Int16 i16;
44 	convertPropertyValue( i16 ,  a );
45 	OSL_ASSERT( 25 == i16 );
46 
47 	sal_Int8 i8;
48 	convertPropertyValue( i8 ,  a );
49 	OSL_ASSERT( 25 == i8 );
50 
51 	sal_uInt32 i32;
52 	convertPropertyValue( i32 ,  a );
53 	OSL_ASSERT( 25 == i32 );
54 
55 	double d;
56 	convertPropertyValue( d , a );
57 	OSL_ASSERT( 25. == d );
58 
59 	float f;
60 	convertPropertyValue( f , a );
61 	OSL_ASSERT( 25. == f );
62 
63 	::com::sun::star::beans::Property prop;
64 
65 	prop.Name = rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("Huhu") );
66 	prop.Handle = 5;
67 	prop.Attributes = 3;
68 
69 	a <<= prop;
70 
71 	::com::sun::star::beans::Property prop2;
72 	convertPropertyValue( prop2 , a );
73  	OSL_ASSERT( prop.Handle == prop2.Handle && prop.Name == prop2.Name && prop.Attributes == prop2.Attributes );
74 
75 
76 	::rtl::OUString ow;
77 	a <<= prop.Name;
78 	convertPropertyValue( ow , a );
79 	OSL_ASSERT( ow == prop.Name );
80 }
81