137adc4f0SAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 337adc4f0SAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 437adc4f0SAndrew Rist * or more contributor license agreements. See the NOTICE file 537adc4f0SAndrew Rist * distributed with this work for additional information 637adc4f0SAndrew Rist * regarding copyright ownership. The ASF licenses this file 737adc4f0SAndrew Rist * to you under the Apache License, Version 2.0 (the 837adc4f0SAndrew Rist * "License"); you may not use this file except in compliance 937adc4f0SAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 1137adc4f0SAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 1337adc4f0SAndrew Rist * Unless required by applicable law or agreed to in writing, 1437adc4f0SAndrew Rist * software distributed under the License is distributed on an 1537adc4f0SAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 1637adc4f0SAndrew Rist * KIND, either express or implied. See the License for the 1737adc4f0SAndrew Rist * specific language governing permissions and limitations 1837adc4f0SAndrew Rist * under the License. 19cdf0e10cSrcweir * 2037adc4f0SAndrew Rist *************************************************************/ 2137adc4f0SAndrew Rist 2237adc4f0SAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "sal/config.h" 25cdf0e10cSrcweir 26cdf0e10cSrcweir #include "com/sun/star/io/IOException.hpp" 27cdf0e10cSrcweir #include "com/sun/star/uno/Sequence.hxx" 28cdf0e10cSrcweir #include "cppu/unotype.hxx" 29*e5230ffaSDamjan Jovanovic #include "gtest/gtest.h" 30cdf0e10cSrcweir #include "rtl/ref.hxx" 31cdf0e10cSrcweir #include "rtl/string.h" 32cdf0e10cSrcweir #include "sal/types.h" 33cdf0e10cSrcweir #include "typelib/typedescription.hxx" 34cdf0e10cSrcweir 35cdf0e10cSrcweir #include "../source/bridge.hxx" 36cdf0e10cSrcweir #include "../source/cache.hxx" 37cdf0e10cSrcweir #include "../source/readerstate.hxx" 38cdf0e10cSrcweir #include "../source/unmarshal.hxx" 39cdf0e10cSrcweir 40cdf0e10cSrcweir namespace { 41cdf0e10cSrcweir 42cdf0e10cSrcweir namespace css = com::sun::star; 43cdf0e10cSrcweir 44*e5230ffaSDamjan Jovanovic class Test: public ::testing::Test { 45*e5230ffaSDamjan Jovanovic public: 46cdf0e10cSrcweir }; 47cdf0e10cSrcweir 48*e5230ffaSDamjan Jovanovic TEST_F(Test, testTypeOfBooleanSequence) { 49cdf0e10cSrcweir binaryurp::ReaderState state; 50cdf0e10cSrcweir css::uno::Sequence< sal_Int8 > buf(13); 51cdf0e10cSrcweir buf[0] = static_cast< sal_Int8 >(20 | 0x80); // sequence type | cache flag 52cdf0e10cSrcweir buf[1] = static_cast< sal_Int8 >(binaryurp::cache::ignore >> 8); 53cdf0e10cSrcweir buf[2] = static_cast< sal_Int8 >(binaryurp::cache::ignore & 0xFF); 54cdf0e10cSrcweir buf[3] = RTL_CONSTASCII_LENGTH("[]boolean"); 55cdf0e10cSrcweir buf[4] = '['; 56cdf0e10cSrcweir buf[5] = ']'; 57cdf0e10cSrcweir buf[6] = 'b'; 58cdf0e10cSrcweir buf[7] = 'o'; 59cdf0e10cSrcweir buf[8] = 'o'; 60cdf0e10cSrcweir buf[9] = 'l'; 61cdf0e10cSrcweir buf[10] = 'e'; 62cdf0e10cSrcweir buf[11] = 'a'; 63cdf0e10cSrcweir buf[12] = 'n'; 64cdf0e10cSrcweir binaryurp::Unmarshal m(rtl::Reference< binaryurp::Bridge >(), state, buf); 65cdf0e10cSrcweir css::uno::TypeDescription t(m.readType()); 66*e5230ffaSDamjan Jovanovic ASSERT_TRUE( 67cdf0e10cSrcweir t.equals( 68cdf0e10cSrcweir css::uno::TypeDescription( 69cdf0e10cSrcweir cppu::UnoType< css::uno::Sequence< bool > >::get()))); 70cdf0e10cSrcweir m.done(); 71cdf0e10cSrcweir } 72cdf0e10cSrcweir 73*e5230ffaSDamjan Jovanovic TEST_F(Test, testTypeOfVoidSequence) { 74cdf0e10cSrcweir binaryurp::ReaderState state; 75cdf0e10cSrcweir css::uno::Sequence< sal_Int8 > buf(10); 76cdf0e10cSrcweir buf[0] = static_cast< sal_Int8 >(20 | 0x80); // sequence type | cache flag 77cdf0e10cSrcweir buf[1] = static_cast< sal_Int8 >(binaryurp::cache::ignore >> 8); 78cdf0e10cSrcweir buf[2] = static_cast< sal_Int8 >(binaryurp::cache::ignore & 0xFF); 79cdf0e10cSrcweir buf[3] = RTL_CONSTASCII_LENGTH("[]void"); 80cdf0e10cSrcweir buf[4] = '['; 81cdf0e10cSrcweir buf[5] = ']'; 82cdf0e10cSrcweir buf[6] = 'v'; 83cdf0e10cSrcweir buf[7] = 'o'; 84cdf0e10cSrcweir buf[8] = 'i'; 85cdf0e10cSrcweir buf[9] = 'd'; 86cdf0e10cSrcweir binaryurp::Unmarshal m(rtl::Reference< binaryurp::Bridge >(), state, buf); 87cdf0e10cSrcweir try { 88cdf0e10cSrcweir m.readType(); 89*e5230ffaSDamjan Jovanovic FAIL() << "exception expected"; 90cdf0e10cSrcweir } catch (css::io::IOException &) {} 91cdf0e10cSrcweir } 92cdf0e10cSrcweir 93cdf0e10cSrcweir 94cdf0e10cSrcweir } 95