| 1 | /** \file |
| 2 | * \brief Tests for ogdf::AdjEntryArray |
| 3 | * |
| 4 | * \author Mirko Wagner, Tilo Wiedera |
| 5 | * |
| 6 | * \par License: |
| 7 | * This file is part of the Open Graph Drawing Framework (OGDF). |
| 8 | * |
| 9 | * \par |
| 10 | * Copyright (C)<br> |
| 11 | * See README.md in the OGDF root directory for details. |
| 12 | * |
| 13 | * \par |
| 14 | * This program is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU General Public License |
| 16 | * Version 2 or 3 as published by the Free Software Foundation; |
| 17 | * see the file LICENSE.txt included in the packaging of this file |
| 18 | * for details. |
| 19 | * |
| 20 | * \par |
| 21 | * This program is distributed in the hope that it will be useful, |
| 22 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 23 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 24 | * GNU General Public License for more details. |
| 25 | * |
| 26 | * \par |
| 27 | * You should have received a copy of the GNU General Public |
| 28 | * License along with this program; if not, see |
| 29 | * http://www.gnu.org/copyleft/gpl.html |
| 30 | */ |
| 31 | #include "array_helper.h" |
| 32 | #include <ogdf/basic/AdjEntryArray.h> |
| 33 | |
| 34 | using namespace ogdf; |
| 35 | using namespace bandit; |
| 36 | |
| 37 | go_bandit([]() { |
| 38 | auto chooseAdjEntry = [](const Graph &graph) { |
| 39 | edge e = graph.chooseEdge(); |
| 40 | return randomNumber(0, 1) ? e->adjSource() : e->adjTarget(); |
| 41 | }; |
| 42 | |
| 43 | auto allAdjEntries = [](const Graph &graph, List<adjEntry> &list) { |
| 44 | list.clear(); |
| 45 | |
| 46 | for(edge e : graph.edges) { |
| 47 | list.pushBack(e->adjSource()); |
| 48 | list.pushBack(e->adjTarget()); |
| 49 | } |
| 50 | }; |
| 51 | |
| 52 | auto createAdjEntry = [](Graph &graph) { |
| 53 | edge e = graph.newEdge(graph.chooseNode(), graph.chooseNode()); |
| 54 | return randomNumber(0, 1) ? e->adjSource() : e->adjTarget(); |
| 55 | }; |
| 56 | |
| 57 | describeArray<AdjEntryArray, adjEntry, int>("AdjEntryArray filled with ints" , 42, 43, chooseAdjEntry, allAdjEntries, createAdjEntry); |
| 58 | describeArray<AdjEntryArray, adjEntry, List<int>>("AdjEntryArray filled with lists of ints" , {1, 2, 3}, {42}, chooseAdjEntry, allAdjEntries, createAdjEntry); |
| 59 | }); |
| 60 | |