19d7e27acSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 39d7e27acSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 49d7e27acSAndrew Rist * or more contributor license agreements. See the NOTICE file 59d7e27acSAndrew Rist * distributed with this work for additional information 69d7e27acSAndrew Rist * regarding copyright ownership. The ASF licenses this file 79d7e27acSAndrew Rist * to you under the Apache License, Version 2.0 (the 89d7e27acSAndrew Rist * "License"); you may not use this file except in compliance 99d7e27acSAndrew Rist * with the License. You may obtain a copy of the License at 10cdf0e10cSrcweir * 119d7e27acSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12cdf0e10cSrcweir * 139d7e27acSAndrew Rist * Unless required by applicable law or agreed to in writing, 149d7e27acSAndrew Rist * software distributed under the License is distributed on an 159d7e27acSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 169d7e27acSAndrew Rist * KIND, either express or implied. See the License for the 179d7e27acSAndrew Rist * specific language governing permissions and limitations 189d7e27acSAndrew Rist * under the License. 19cdf0e10cSrcweir * 209d7e27acSAndrew Rist *************************************************************/ 219d7e27acSAndrew Rist 224b7589a4SDamjan Jovanovic #include "precompiled_cppuhelper.hxx" 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "cppuhelper/unourl.hxx" 25cdf0e10cSrcweir #include "rtl/malformeduriexception.hxx" 26cdf0e10cSrcweir #include "rtl/strbuf.hxx" 27cdf0e10cSrcweir #include "rtl/string.h" 28cdf0e10cSrcweir #include "rtl/textenc.h" 29cdf0e10cSrcweir #include "rtl/ustring.hxx" 30cdf0e10cSrcweir #include "sal/types.h" 315c0ee992SDamjan Jovanovic #include "gtest/gtest.h" 32cdf0e10cSrcweir 33cdf0e10cSrcweir namespace cppu_unourl 34cdf0e10cSrcweir { 355c0ee992SDamjan Jovanovic class UrlTest : public ::testing::Test 36cdf0e10cSrcweir { 37cdf0e10cSrcweir public: 385c0ee992SDamjan Jovanovic }; 395c0ee992SDamjan Jovanovic 405c0ee992SDamjan Jovanovic TEST_F(UrlTest, testDescriptorParsing) 41cdf0e10cSrcweir { 42cdf0e10cSrcweir struct Test 43cdf0e10cSrcweir { 44cdf0e10cSrcweir char const * pInput; 45cdf0e10cSrcweir bool bValid; 46cdf0e10cSrcweir }; 47cdf0e10cSrcweir static Test const aTests[] 48cdf0e10cSrcweir = { { "", false }, 49cdf0e10cSrcweir { "abc", true }, 50cdf0e10cSrcweir { "Abc", true }, 51cdf0e10cSrcweir { "aBC", true }, 52cdf0e10cSrcweir { "ABC", true }, 53cdf0e10cSrcweir { "1abc", true }, 54cdf0e10cSrcweir { "123", true }, 55cdf0e10cSrcweir { "abc-1", false }, 56cdf0e10cSrcweir { "ab%63", false }, 57cdf0e10cSrcweir { "abc,", false }, 58cdf0e10cSrcweir { "abc,def=", true }, 59cdf0e10cSrcweir { "abc,Def=", true }, 60cdf0e10cSrcweir { "abc,DEF=", true }, 61cdf0e10cSrcweir { "abc,1def=", true }, 62cdf0e10cSrcweir { "abc,123=", true }, 63cdf0e10cSrcweir { "abc,def-1=", false }, 64cdf0e10cSrcweir { "abc,def", false }, 65cdf0e10cSrcweir { "abc,def=xxx,def=xxx", false }, 66cdf0e10cSrcweir { "abc,def=xxx,ghi=xxx", true }, 67cdf0e10cSrcweir { "abc,,def=xxx", false }, 68cdf0e10cSrcweir { "abc,def=xxx,,ghi=xxx", false }, 69cdf0e10cSrcweir { "abc,def=xxx,ghi=xxx,", false }, 70cdf0e10cSrcweir { "abc,def=%", true }, 71cdf0e10cSrcweir { "abc,def=%1", true }, 72cdf0e10cSrcweir { "abc,def=%00", true }, 73cdf0e10cSrcweir { "abc,def=%22", true }, 74cdf0e10cSrcweir { "abc,def=\"", true }, 75cdf0e10cSrcweir { "abc,def=%ed%a0%80", true } }; 76*2cfa35e9SPeter Kovacs for (unsigned int i = 0; i < sizeof aTests / sizeof (Test); ++i) 77cdf0e10cSrcweir { 78cdf0e10cSrcweir bool bValid = false; 79cdf0e10cSrcweir try 80cdf0e10cSrcweir { 81cdf0e10cSrcweir cppu::UnoUrlDescriptor aDescriptor(rtl::OUString::createFromAscii( 82cdf0e10cSrcweir aTests[i].pInput)); 83cdf0e10cSrcweir bValid = true; 84cdf0e10cSrcweir } 85cdf0e10cSrcweir catch (rtl::MalformedUriException &) 86cdf0e10cSrcweir {} 87cdf0e10cSrcweir 88cdf0e10cSrcweir if (aTests[i].bValid) 89cdf0e10cSrcweir { 905c0ee992SDamjan Jovanovic ASSERT_TRUE(bValid) << "Valid uri parsed as invalid"; 91cdf0e10cSrcweir } 92cdf0e10cSrcweir else 93cdf0e10cSrcweir { 945c0ee992SDamjan Jovanovic ASSERT_TRUE(!bValid) << "Invalid uri parsed as valid"; 95cdf0e10cSrcweir } 96cdf0e10cSrcweir } 97cdf0e10cSrcweir } 98cdf0e10cSrcweir 995c0ee992SDamjan Jovanovic TEST_F(UrlTest, testDescriptorDescriptor) 100cdf0e10cSrcweir { 101cdf0e10cSrcweir struct Test 102cdf0e10cSrcweir { 103cdf0e10cSrcweir char const * pInput; 104cdf0e10cSrcweir char const * pDescriptor; 105cdf0e10cSrcweir }; 106cdf0e10cSrcweir static Test const aTests[] 107cdf0e10cSrcweir = {{ "abc", "abc" }, 108cdf0e10cSrcweir { "Abc", "Abc" }, 109cdf0e10cSrcweir { "aBC", "aBC" }, 110cdf0e10cSrcweir { "ABC", "ABC" }, 111cdf0e10cSrcweir { "1abc", "1abc" }, 112cdf0e10cSrcweir { "123", "123" }, 113cdf0e10cSrcweir { "abc,def=", "abc,def=" }, 114cdf0e10cSrcweir { "abc,Def=", "abc,Def=" }, 115cdf0e10cSrcweir { "abc,DEF=", "abc,DEF=" }, 116cdf0e10cSrcweir { "abc,1def=", "abc,1def=" }, 117cdf0e10cSrcweir { "abc,123=", "abc,123=" }, 118cdf0e10cSrcweir { "abc,def=xxx,ghi=xxx", "abc,def=xxx,ghi=xxx" }, 119cdf0e10cSrcweir { "abc,def=%", "abc,def=%" }, 120cdf0e10cSrcweir { "abc,def=%1", "abc,def=%1" }, 121cdf0e10cSrcweir { "abc,def=%00", "abc,def=%00" }, 122cdf0e10cSrcweir { "abc,def=%22", "abc,def=%22" }, 123cdf0e10cSrcweir { "abc,def=\"", "abc,def=\"" }, 124cdf0e10cSrcweir { "abc,def=%ed%a0%80", "abc,def=%ed%a0%80" } }; 125*2cfa35e9SPeter Kovacs for (unsigned int i = 0; i < sizeof aTests / sizeof (Test); ++i) 126cdf0e10cSrcweir { 127cdf0e10cSrcweir bool bValid = false; 128cdf0e10cSrcweir rtl::OUString aDescriptor; 129cdf0e10cSrcweir try 130cdf0e10cSrcweir { 131cdf0e10cSrcweir aDescriptor = cppu::UnoUrlDescriptor(rtl::OUString::createFromAscii( 132cdf0e10cSrcweir aTests[i].pInput)). 133cdf0e10cSrcweir getDescriptor(); 134cdf0e10cSrcweir bValid = true; 135cdf0e10cSrcweir } 136cdf0e10cSrcweir catch (rtl::MalformedUriException &) 137cdf0e10cSrcweir {} 138cdf0e10cSrcweir 1395c0ee992SDamjan Jovanovic ASSERT_TRUE(bValid) << "Failed to parse URI"; 1405c0ee992SDamjan Jovanovic ASSERT_TRUE(aDescriptor.equalsAscii(aTests[i].pDescriptor)) << "Failed to parse URI correctly"; 141cdf0e10cSrcweir } 142cdf0e10cSrcweir } 143cdf0e10cSrcweir 144cdf0e10cSrcweir 1455c0ee992SDamjan Jovanovic TEST_F(UrlTest, testDescriptorName) 146cdf0e10cSrcweir { 147cdf0e10cSrcweir struct Test 148cdf0e10cSrcweir { 149cdf0e10cSrcweir char const * pInput; 150cdf0e10cSrcweir char const * pName; 151cdf0e10cSrcweir }; 152cdf0e10cSrcweir static Test const aTests[] 153cdf0e10cSrcweir = { { "abc", "abc" }, 154cdf0e10cSrcweir { "Abc", "abc" }, 155cdf0e10cSrcweir { "aBC", "abc" }, 156cdf0e10cSrcweir { "ABC", "abc" }, 157cdf0e10cSrcweir { "1abc", "1abc" }, 158cdf0e10cSrcweir { "123", "123" }, 159cdf0e10cSrcweir { "abc,def=", "abc" }, 160cdf0e10cSrcweir { "abc,Def=", "abc" }, 161cdf0e10cSrcweir { "abc,DEF=", "abc" }, 162cdf0e10cSrcweir { "abc,1def=", "abc" }, 163cdf0e10cSrcweir { "abc,123=", "abc" }, 164cdf0e10cSrcweir { "abc,def=xxx,ghi=xxx", "abc" }, 165cdf0e10cSrcweir { "abc,def=%", "abc" }, 166cdf0e10cSrcweir { "abc,def=%1", "abc" }, 167cdf0e10cSrcweir { "abc,def=%00", "abc" }, 168cdf0e10cSrcweir { "abc,def=%22", "abc" }, 169cdf0e10cSrcweir { "abc,def=\"", "abc" }, 170cdf0e10cSrcweir { "abc,def=%ed%a0%80", "abc" } }; 171*2cfa35e9SPeter Kovacs for (unsigned int i = 0; i < sizeof aTests / sizeof (Test); ++i) 172cdf0e10cSrcweir { 173cdf0e10cSrcweir bool bValid = false; 174cdf0e10cSrcweir rtl::OUString aName; 175cdf0e10cSrcweir try 176cdf0e10cSrcweir { 177cdf0e10cSrcweir aName = cppu::UnoUrlDescriptor(rtl::OUString::createFromAscii( 178cdf0e10cSrcweir aTests[i].pInput)).getName(); 179cdf0e10cSrcweir bValid = true; 180cdf0e10cSrcweir } 181cdf0e10cSrcweir catch (rtl::MalformedUriException &) 182cdf0e10cSrcweir {} 183cdf0e10cSrcweir 1845c0ee992SDamjan Jovanovic ASSERT_TRUE(bValid) << "Failed to parse URI"; 1855c0ee992SDamjan Jovanovic ASSERT_TRUE(aName.equalsAscii(aTests[i].pName)) << "Failed to parse URI correctly"; 186cdf0e10cSrcweir } 187cdf0e10cSrcweir } 188cdf0e10cSrcweir 1895c0ee992SDamjan Jovanovic TEST_F(UrlTest, testDescriptorKey) 190cdf0e10cSrcweir { 191cdf0e10cSrcweir struct Test 192cdf0e10cSrcweir { 193cdf0e10cSrcweir char const * pInput; 194cdf0e10cSrcweir char const * pKey; 195cdf0e10cSrcweir bool bPresent; 196cdf0e10cSrcweir }; 197cdf0e10cSrcweir static Test const aTests[] 198cdf0e10cSrcweir = { { "abc", "abc", false }, 199cdf0e10cSrcweir { "abc", "def", false }, 200cdf0e10cSrcweir { "1abc", "def", false }, 201cdf0e10cSrcweir { "123", "def", false }, 202cdf0e10cSrcweir { "abc,def=", "abc", false }, 203cdf0e10cSrcweir { "abc,def=", "def", true }, 204cdf0e10cSrcweir { "abc,def=", "defg", false }, 205cdf0e10cSrcweir { "abc,def=", "de", false }, 206cdf0e10cSrcweir { "abc,def=", "ghi", false }, 207cdf0e10cSrcweir { "abc,Def=", "def", true }, 208cdf0e10cSrcweir { "abc,Def=", "Def", true }, 209cdf0e10cSrcweir { "abc,Def=", "dEF", true }, 210cdf0e10cSrcweir { "abc,Def=", "DEF", true }, 211cdf0e10cSrcweir { "abc,def=xxx,ghi=xxx", "abc", false }, 212cdf0e10cSrcweir { "abc,def=xxx,ghi=xxx", "def", true }, 213cdf0e10cSrcweir { "abc,def=xxx,ghi=xxx", "ghi", true }, 214cdf0e10cSrcweir { "abc,def=xxx,ghi=xxx", "jkl", false } }; 215*2cfa35e9SPeter Kovacs for (unsigned int i = 0; i < sizeof aTests / sizeof (Test); ++i) 216cdf0e10cSrcweir { 217cdf0e10cSrcweir bool bValid = false; 218cdf0e10cSrcweir bool bPresent = false; 219cdf0e10cSrcweir try 220cdf0e10cSrcweir { 221cdf0e10cSrcweir bPresent = cppu::UnoUrlDescriptor(rtl::OUString::createFromAscii( 222cdf0e10cSrcweir aTests[i].pInput)). 223cdf0e10cSrcweir hasParameter(rtl::OUString::createFromAscii(aTests[i].pKey)); 224cdf0e10cSrcweir bValid = true; 225cdf0e10cSrcweir } 226cdf0e10cSrcweir catch (rtl::MalformedUriException &) 227cdf0e10cSrcweir {} 228cdf0e10cSrcweir 2295c0ee992SDamjan Jovanovic ASSERT_TRUE(bValid) << "Failed to parse URI"; 2305c0ee992SDamjan Jovanovic ASSERT_TRUE(bPresent == aTests[i].bPresent) << "Failed to detect parameter correctly"; 231cdf0e10cSrcweir } 232cdf0e10cSrcweir } 233cdf0e10cSrcweir 2345c0ee992SDamjan Jovanovic TEST_F(UrlTest, testDescriptorValue) 235cdf0e10cSrcweir { 236cdf0e10cSrcweir struct Test 237cdf0e10cSrcweir { 238cdf0e10cSrcweir char const * pInput; 239cdf0e10cSrcweir char const * pKey; 240cdf0e10cSrcweir char const * pValue; 241cdf0e10cSrcweir }; 242cdf0e10cSrcweir static Test const aTests[] 243cdf0e10cSrcweir = { { "abc", "abc", "" }, 244cdf0e10cSrcweir { "abc", "def", "" }, 245cdf0e10cSrcweir { "1abc", "def", "" }, 246cdf0e10cSrcweir { "123", "def", "" }, 247cdf0e10cSrcweir { "abc,def=", "abc", "" }, 248cdf0e10cSrcweir { "abc,def=", "def", "" }, 249cdf0e10cSrcweir { "abc,def=", "defg", "" }, 250cdf0e10cSrcweir { "abc,def=", "de", "" }, 251cdf0e10cSrcweir { "abc,def=", "ghi", "" }, 252cdf0e10cSrcweir { "abc,Def=", "def", "" }, 253cdf0e10cSrcweir { "abc,Def=", "Def", "" }, 254cdf0e10cSrcweir { "abc,Def=", "dEF", "" }, 255cdf0e10cSrcweir { "abc,Def=", "DEF", "" }, 256cdf0e10cSrcweir { "abc,def=xxx,ghi=xxx", "abc", "" }, 257cdf0e10cSrcweir { "abc,def=xxx,ghi=xxx", "def", "xxx" }, 258cdf0e10cSrcweir { "abc,def=xxx,ghi=xxx", "ghi", "xxx" }, 259cdf0e10cSrcweir { "abc,def=xxx,ghi=xxx", "jkl", "" }, 260cdf0e10cSrcweir { "abc,def=%", "def", "%" }, 261cdf0e10cSrcweir { "abc,def=%1", "def", "%1" }, 262cdf0e10cSrcweir { "abc,def=%22", "def", "\"" }, 263cdf0e10cSrcweir { "abc,def=\"", "def", "\"" }, 264cdf0e10cSrcweir { "abc,def=abc", "def", "abc" }, 265cdf0e10cSrcweir { "abc,def=Abc", "def", "Abc" }, 266cdf0e10cSrcweir { "abc,def=aBC", "def", "aBC" }, 267cdf0e10cSrcweir { "abc,def=ABC", "def", "ABC" }, 268cdf0e10cSrcweir { "abc,def=%,ghi=", "def", "%" }, 269cdf0e10cSrcweir { "abc,def=%1,ghi=", "def", "%1" }, 270cdf0e10cSrcweir { "abc,def=%22,ghi=", "def", "\"" }, 271cdf0e10cSrcweir { "abc,def=\",ghi=", "def", "\"" }, 272cdf0e10cSrcweir { "abc,def=abc,ghi=", "def", "abc" }, 273cdf0e10cSrcweir { "abc,def=Abc,ghi=", "def", "Abc" }, 274cdf0e10cSrcweir { "abc,def=aBC,ghi=", "def", "aBC" }, 275cdf0e10cSrcweir { "abc,def=ABC,ghi=", "def", "ABC" }, 276cdf0e10cSrcweir { "abc,abc=,def=%", "def", "%" }, 277cdf0e10cSrcweir { "abc,abc=,def=%1", "def", "%1" }, 278cdf0e10cSrcweir { "abc,abc=,def=%22", "def", "\"" }, 279cdf0e10cSrcweir { "abc,abc=,def=\"", "def", "\"" }, 280cdf0e10cSrcweir { "abc,abc=,def=abc", "def", "abc" }, 281cdf0e10cSrcweir { "abc,abc=,def=Abc", "def", "Abc" }, 282cdf0e10cSrcweir { "abc,abc=,def=aBC", "def", "aBC" }, 283cdf0e10cSrcweir { "abc,abc=,def=ABC", "def", "ABC" } }; 284*2cfa35e9SPeter Kovacs for (unsigned int i = 0; i < sizeof aTests / sizeof (Test); ++i) 285cdf0e10cSrcweir { 286cdf0e10cSrcweir bool bValid = false; 287cdf0e10cSrcweir rtl::OUString aValue; 288cdf0e10cSrcweir try 289cdf0e10cSrcweir { 290cdf0e10cSrcweir aValue = cppu::UnoUrlDescriptor(rtl::OUString::createFromAscii( 291cdf0e10cSrcweir aTests[i].pInput)). 292cdf0e10cSrcweir getParameter(rtl::OUString::createFromAscii(aTests[i].pKey)); 293cdf0e10cSrcweir bValid = true; 294cdf0e10cSrcweir } 295cdf0e10cSrcweir catch (rtl::MalformedUriException &) 296cdf0e10cSrcweir {} 2975c0ee992SDamjan Jovanovic ASSERT_TRUE(bValid) << "Failed to parse URI"; 2985c0ee992SDamjan Jovanovic ASSERT_TRUE(aValue.equalsAscii(aTests[i].pValue)) << "Failed to get param correctly"; 299cdf0e10cSrcweir } 300cdf0e10cSrcweir } 301cdf0e10cSrcweir 3025c0ee992SDamjan Jovanovic TEST_F(UrlTest, testUrlParsing) 303cdf0e10cSrcweir { 304cdf0e10cSrcweir struct Test 305cdf0e10cSrcweir { 306cdf0e10cSrcweir char const * pInput; 307cdf0e10cSrcweir bool bValid; 308cdf0e10cSrcweir }; 309cdf0e10cSrcweir static Test const aTests[] 310cdf0e10cSrcweir = { { "", false }, 311cdf0e10cSrcweir { "abc", false }, 312cdf0e10cSrcweir { "uno", false }, 313cdf0e10cSrcweir { "uno:", false }, 314cdf0e10cSrcweir { "uno:abc;def;ghi", true }, 315cdf0e10cSrcweir { "Uno:abc;def;ghi", true }, 316cdf0e10cSrcweir { "uNO:abc;def;ghi", true }, 317cdf0e10cSrcweir { "UNO:abc;def;ghi", true }, 318cdf0e10cSrcweir { "uno:abc,def=xxx,ghi=xxx;def,ghi=xxx,jkl=xxx;ghi", true }, 319cdf0e10cSrcweir { "uno:abc,def=xxx,ghi=xxx;def,ghi=xxx,jkl=xxx,;ghi", false }, 320cdf0e10cSrcweir { "uno:abc;def;", false }, 321cdf0e10cSrcweir { "uno:abc;def;a", true }, 322cdf0e10cSrcweir { "uno:abc;def;A", true }, 323cdf0e10cSrcweir { "uno:abc;def;1", true }, 324cdf0e10cSrcweir { "uno:abc;def;$&+,/:=?@", true }, 325cdf0e10cSrcweir { "uno:abc;def;%24&+,/:=?@", false } }; 326*2cfa35e9SPeter Kovacs for (unsigned int i = 0; i < sizeof aTests / sizeof (Test); ++i) 327cdf0e10cSrcweir { 328cdf0e10cSrcweir bool bValid = false; 329cdf0e10cSrcweir try 330cdf0e10cSrcweir { 331cdf0e10cSrcweir cppu::UnoUrl aUrl(rtl::OUString::createFromAscii(aTests[i].pInput)); 332cdf0e10cSrcweir bValid = true; 333cdf0e10cSrcweir } 334cdf0e10cSrcweir catch (rtl::MalformedUriException &) 335cdf0e10cSrcweir {} 336cdf0e10cSrcweir 337cdf0e10cSrcweir if (aTests[i].bValid) 338cdf0e10cSrcweir { 3395c0ee992SDamjan Jovanovic ASSERT_TRUE(bValid) << "Valid uri parsed as invalid"; 340cdf0e10cSrcweir } 341cdf0e10cSrcweir else 342cdf0e10cSrcweir { 3435c0ee992SDamjan Jovanovic ASSERT_TRUE(!bValid) << "Invalid uri parsed as valid"; 344cdf0e10cSrcweir } 345cdf0e10cSrcweir 346cdf0e10cSrcweir } 347cdf0e10cSrcweir } 348cdf0e10cSrcweir 3495c0ee992SDamjan Jovanovic TEST_F(UrlTest, testUrlConnection) 350cdf0e10cSrcweir { 351cdf0e10cSrcweir struct Test 352cdf0e10cSrcweir { 353cdf0e10cSrcweir char const * pInput; 354cdf0e10cSrcweir char const * pConnection; 355cdf0e10cSrcweir }; 356cdf0e10cSrcweir static Test const aTests[] 357cdf0e10cSrcweir = { { "uno:abc;def;ghi", "abc" }, 358cdf0e10cSrcweir { "uno:Abc;def;ghi", "Abc" }, 359cdf0e10cSrcweir { "uno:aBC;def;ghi", "aBC" }, 360cdf0e10cSrcweir { "uno:ABC;def;ghi", "ABC" }, 361cdf0e10cSrcweir { "uno:abc,def=xxx,ghi=xxx;def,ghi=xxx,jkl=xxx;ghi", 362cdf0e10cSrcweir "abc,def=xxx,ghi=xxx" } }; 363*2cfa35e9SPeter Kovacs for (unsigned int i = 0; i < sizeof aTests / sizeof (Test); ++i) 364cdf0e10cSrcweir { 365cdf0e10cSrcweir bool bValid = false; 366cdf0e10cSrcweir rtl::OUString aConnection; 367cdf0e10cSrcweir try 368cdf0e10cSrcweir { 369cdf0e10cSrcweir aConnection = cppu::UnoUrl(rtl::OUString::createFromAscii( 370cdf0e10cSrcweir aTests[i].pInput)). 371cdf0e10cSrcweir getConnection().getDescriptor(); 372cdf0e10cSrcweir bValid = true; 373cdf0e10cSrcweir } 374cdf0e10cSrcweir catch (rtl::MalformedUriException &) 375cdf0e10cSrcweir {} 3765c0ee992SDamjan Jovanovic ASSERT_TRUE(bValid) << "Failed to parse URI"; 3775c0ee992SDamjan Jovanovic ASSERT_TRUE(aConnection.equalsAscii(aTests[i].pConnection)) << "Failed to get param correctly"; 378cdf0e10cSrcweir } 379cdf0e10cSrcweir } 380cdf0e10cSrcweir 3815c0ee992SDamjan Jovanovic TEST_F(UrlTest, testUrlProtocol) 382cdf0e10cSrcweir { 383cdf0e10cSrcweir struct Test 384cdf0e10cSrcweir { 385cdf0e10cSrcweir char const * pInput; 386cdf0e10cSrcweir char const * pProtocol; 387cdf0e10cSrcweir }; 388cdf0e10cSrcweir static Test const aTests[] 389cdf0e10cSrcweir = { { "uno:abc;def;ghi", "def" }, 390cdf0e10cSrcweir { "uno:abc;Def;ghi", "Def" }, 391cdf0e10cSrcweir { "uno:abc;dEF;ghi", "dEF" }, 392cdf0e10cSrcweir { "uno:abc;DEF;ghi", "DEF" }, 393cdf0e10cSrcweir { "uno:abc,def=xxx,ghi=xxx;def,ghi=xxx,jkl=xxx;ghi", 394cdf0e10cSrcweir "def,ghi=xxx,jkl=xxx" } }; 395*2cfa35e9SPeter Kovacs for (unsigned int i = 0; i < sizeof aTests / sizeof (Test); ++i) 396cdf0e10cSrcweir { 397cdf0e10cSrcweir bool bValid = false; 398cdf0e10cSrcweir rtl::OUString aProtocol; 399cdf0e10cSrcweir try 400cdf0e10cSrcweir { 401cdf0e10cSrcweir aProtocol = cppu::UnoUrl(rtl::OUString::createFromAscii( 402cdf0e10cSrcweir aTests[i].pInput)). 403cdf0e10cSrcweir getProtocol().getDescriptor(); 404cdf0e10cSrcweir bValid = true; 405cdf0e10cSrcweir } 406cdf0e10cSrcweir catch (rtl::MalformedUriException &) 407cdf0e10cSrcweir {} 4085c0ee992SDamjan Jovanovic ASSERT_TRUE(bValid) << "Failed to parse URI"; 4095c0ee992SDamjan Jovanovic ASSERT_TRUE(aProtocol.equalsAscii(aTests[i].pProtocol)) << "Failed to get protocol correctly"; 410cdf0e10cSrcweir } 411cdf0e10cSrcweir } 412cdf0e10cSrcweir 4135c0ee992SDamjan Jovanovic TEST_F(UrlTest, testUrlObjectName) 414cdf0e10cSrcweir { 415cdf0e10cSrcweir struct Test 416cdf0e10cSrcweir { 417cdf0e10cSrcweir char const * pInput; 418cdf0e10cSrcweir char const * pObjectName; 419cdf0e10cSrcweir }; 420cdf0e10cSrcweir static Test const aTests[] 421cdf0e10cSrcweir = { { "uno:abc;def;ghi", "ghi" }, 422cdf0e10cSrcweir { "uno:abc;def;Ghi", "Ghi" }, 423cdf0e10cSrcweir { "uno:abc;def;gHI", "gHI" }, 424cdf0e10cSrcweir { "uno:abc;def;GHI", "GHI" }, 425cdf0e10cSrcweir { "uno:abc,def=xxx,ghi=xxx;def,ghi=xxx,jkl=xxx;ghi", "ghi" }, 426cdf0e10cSrcweir { "uno:abc;def;a", "a" }, 427cdf0e10cSrcweir { "uno:abc;def;A", "A" }, 428cdf0e10cSrcweir { "uno:abc;def;1", "1" }, 429cdf0e10cSrcweir { "uno:abc;def;$&+,/:=?@", "$&+,/:=?@" } }; 430*2cfa35e9SPeter Kovacs for (unsigned int i = 0; i < sizeof aTests / sizeof (Test); ++i) 431cdf0e10cSrcweir { 432cdf0e10cSrcweir bool bValid = false; 433cdf0e10cSrcweir rtl::OUString aObjectName; 434cdf0e10cSrcweir try 435cdf0e10cSrcweir { 436cdf0e10cSrcweir aObjectName = cppu::UnoUrl(rtl::OUString::createFromAscii( 437cdf0e10cSrcweir aTests[i].pInput)).getObjectName(); 438cdf0e10cSrcweir bValid = true; 439cdf0e10cSrcweir } 440cdf0e10cSrcweir catch (rtl::MalformedUriException &) 441cdf0e10cSrcweir {} 4425c0ee992SDamjan Jovanovic ASSERT_TRUE(bValid) << "Failed to parse URI"; 4435c0ee992SDamjan Jovanovic ASSERT_TRUE(aObjectName.equalsAscii(aTests[i].pObjectName)) << "Failed to get protocol correctly"; 444cdf0e10cSrcweir } 445cdf0e10cSrcweir } 446cdf0e10cSrcweir } // namespace cppu_ifcontainer 447cdf0e10cSrcweir 44826d3e425SDamjan Jovanovic int main(int argc, char **argv) 44926d3e425SDamjan Jovanovic { 45026d3e425SDamjan Jovanovic ::testing::InitGoogleTest(&argc, argv); 45126d3e425SDamjan Jovanovic return RUN_ALL_TESTS(); 45226d3e425SDamjan Jovanovic } 45326d3e425SDamjan Jovanovic 454