1dde7d3faSAndrew Rist /************************************************************** 2cdf0e10cSrcweir * 3dde7d3faSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one 4dde7d3faSAndrew Rist * or more contributor license agreements. See the NOTICE file 5dde7d3faSAndrew Rist * distributed with this work for additional information 6dde7d3faSAndrew Rist * regarding copyright ownership. The ASF licenses this file 7dde7d3faSAndrew Rist * to you under the Apache License, Version 2.0 (the 8dde7d3faSAndrew Rist * "License"); you may not use this file except in compliance 9dde7d3faSAndrew Rist * with the License. You may obtain a copy of the License at 10dde7d3faSAndrew Rist * 11dde7d3faSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0 12dde7d3faSAndrew Rist * 13dde7d3faSAndrew Rist * Unless required by applicable law or agreed to in writing, 14dde7d3faSAndrew Rist * software distributed under the License is distributed on an 15dde7d3faSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 16dde7d3faSAndrew Rist * KIND, either express or implied. See the License for the 17dde7d3faSAndrew Rist * specific language governing permissions and limitations 18dde7d3faSAndrew Rist * under the License. 19dde7d3faSAndrew Rist * 20dde7d3faSAndrew Rist *************************************************************/ 21dde7d3faSAndrew Rist 22dde7d3faSAndrew Rist 23cdf0e10cSrcweir 24cdf0e10cSrcweir #include "precompiled_comphelper.hxx" 25cdf0e10cSrcweir #include "sal/config.h" 26cdf0e10cSrcweir 27cdf0e10cSrcweir #include "com/sun/star/uno/Reference.hxx" 28cdf0e10cSrcweir #include "com/sun/star/uno/XInterface.hpp" 29cdf0e10cSrcweir #include "comphelper/weakbag.hxx" 30cdf0e10cSrcweir #include "cppuhelper/weak.hxx" 31*e92f3138SDamjan Jovanovic #include "gtest/gtest.h" 32cdf0e10cSrcweir 33cdf0e10cSrcweir namespace { 34cdf0e10cSrcweir 35cdf0e10cSrcweir namespace css = com::sun::star; 36cdf0e10cSrcweir 37*e92f3138SDamjan Jovanovic class Test: public ::testing::Test { 38cdf0e10cSrcweir public: 39cdf0e10cSrcweir }; 40cdf0e10cSrcweir TEST_F(Test,test)41*e92f3138SDamjan JovanovicTEST_F(Test, test) { 42*e92f3138SDamjan Jovanovic css::uno::Reference< css::uno::XInterface > ref1(new cppu::OWeakObject); 43*e92f3138SDamjan Jovanovic css::uno::Reference< css::uno::XInterface > ref2(new cppu::OWeakObject); 44*e92f3138SDamjan Jovanovic css::uno::Reference< css::uno::XInterface > ref3(new cppu::OWeakObject); 45*e92f3138SDamjan Jovanovic comphelper::WeakBag< css::uno::XInterface > bag; 46*e92f3138SDamjan Jovanovic bag.add(ref1); 47*e92f3138SDamjan Jovanovic bag.add(ref1); 48*e92f3138SDamjan Jovanovic bag.add(ref2); 49*e92f3138SDamjan Jovanovic bag.add(ref2); 50*e92f3138SDamjan Jovanovic ref1.clear(); 51*e92f3138SDamjan Jovanovic bag.add(ref3); 52*e92f3138SDamjan Jovanovic ref3.clear(); 53*e92f3138SDamjan Jovanovic ASSERT_TRUE(bag.remove() == ref2) << "remove first ref2"; 54*e92f3138SDamjan Jovanovic ASSERT_TRUE(bag.remove() == ref2) << "remove second ref2"; 55*e92f3138SDamjan Jovanovic ASSERT_TRUE(!bag.remove().is()) << "remove first null"; 56*e92f3138SDamjan Jovanovic ASSERT_TRUE(!bag.remove().is()) << "remove second null"; 57*e92f3138SDamjan Jovanovic } 58*e92f3138SDamjan Jovanovic 59cdf0e10cSrcweir 60cdf0e10cSrcweir } 61cdf0e10cSrcweir main(int argc,char ** argv)62*e92f3138SDamjan Jovanovicint main(int argc, char **argv) 63*e92f3138SDamjan Jovanovic { 64*e92f3138SDamjan Jovanovic ::testing::InitGoogleTest(&argc, argv); 65*e92f3138SDamjan Jovanovic return RUN_ALL_TESTS(); 66*e92f3138SDamjan Jovanovic } 67