]> granicus.if.org Git - icinga2/blobdiff - test/base-array.cpp
Fix cookie with ActivateItems
[icinga2] / test / base-array.cpp
index 61b2043dfd7d1aec49994d95e89eb7b8dc9b435b..33e54e8f142526ac9089652fb47529840d5b5707 100644 (file)
@@ -1,26 +1,9 @@
-/******************************************************************************
- * Icinga 2                                                                   *
- * Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/)  *
- *                                                                            *
- * This program is free software; you can redistribute it and/or              *
- * modify it under the terms of the GNU General Public License                *
- * as published by the Free Software Foundation; either version 2             *
- * of the License, or (at your option) any later version.                     *
- *                                                                            *
- * This program is distributed in the hope that it will be useful,            *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of             *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the              *
- * GNU General Public License for more details.                               *
- *                                                                            *
- * You should have received a copy of the GNU General Public License          *
- * along with this program; if not, write to the Free Software Foundation     *
- * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
- ******************************************************************************/
+/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
 
 #include "base/array.hpp"
 #include "base/objectlock.hpp"
 #include "base/json.hpp"
-#include <boost/test/unit_test.hpp>
+#include <BoostTestTargetConfig.h>
 
 using namespace icinga;
 
@@ -91,7 +74,7 @@ BOOST_AUTO_TEST_CASE(remove)
 
        {
                ObjectLock olock(array);
-               Array::Iterator it = array->Begin();
+               auto it = array->Begin();
                array->Remove(it);
        }
 
@@ -102,6 +85,27 @@ BOOST_AUTO_TEST_CASE(remove)
        BOOST_CHECK(array->GetLength() == 0);
 }
 
+BOOST_AUTO_TEST_CASE(unique)
+{
+       Array::Ptr array = new Array();
+       array->Add("group1");
+       array->Add("group2");
+       array->Add("group1");
+       array->Add("group2");
+
+       Array::Ptr result;
+
+       {
+               ObjectLock olock(array);
+               result = array->Unique();
+       }
+
+       BOOST_CHECK(result->GetLength() == 2);
+       result->Sort();
+
+       BOOST_CHECK(result->Get(0) == "group1");
+       BOOST_CHECK(result->Get(1) == "group2");
+}
 BOOST_AUTO_TEST_CASE(foreach)
 {
        Array::Ptr array = new Array();