|
| 1 | +/* |
| 2 | + * This file is part of PowerDNS or dnsdist. |
| 3 | + * Copyright -- PowerDNS.COM B.V. and its contributors |
| 4 | + * |
| 5 | + * This program is free software; you can redistribute it and/or modify |
| 6 | + * it under the terms of version 2 of the GNU General Public License as |
| 7 | + * published by the Free Software Foundation. |
| 8 | + * |
| 9 | + * In addition, for the avoidance of any doubt, permission is granted to |
| 10 | + * link this program with OpenSSL and to (re)distribute the binaries |
| 11 | + * produced as the result of such linking. |
| 12 | + * |
| 13 | + * This program is distributed in the hope that it will be useful, |
| 14 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | + * GNU General Public License for more details. |
| 17 | + * |
| 18 | + * You should have received a copy of the GNU General Public License |
| 19 | + * along with this program; if not, write to the Free Software |
| 20 | + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 21 | + */ |
| 22 | + |
| 23 | +#ifndef BOOST_TEST_DYN_LINK |
| 24 | +#define BOOST_TEST_DYN_LINK |
| 25 | +#endif |
| 26 | + |
| 27 | +#define BOOST_TEST_NO_MAIN |
| 28 | + |
| 29 | +#include "config.h" |
| 30 | +#include <boost/test/unit_test.hpp> |
| 31 | + |
| 32 | +#include "shuffle.hh" |
| 33 | +#include "test-common.hh" |
| 34 | + |
| 35 | +BOOST_AUTO_TEST_SUITE(shuffle_cc) |
| 36 | + |
| 37 | +BOOST_AUTO_TEST_CASE(test_simple) |
| 38 | +{ |
| 39 | + std::vector<DNSRecord> list; |
| 40 | + auto* address = &list; |
| 41 | + addRecordToList(list, DNSName("foo"), QType::A, "1.2.3.4"); |
| 42 | + addRecordToList(list, DNSName("foo2"), QType::A, "1.2.3.4"); |
| 43 | + auto dups = pdns::dedupRecords(list); |
| 44 | + BOOST_CHECK_EQUAL(dups, 0U); |
| 45 | + BOOST_CHECK_EQUAL(list.size(), 2U); |
| 46 | + addRecordToList(list, DNSName("foo"), QType::A, "1.2.3.4"); |
| 47 | + dups = pdns::dedupRecords(list); |
| 48 | + BOOST_CHECK_EQUAL(dups, 1U); |
| 49 | + BOOST_CHECK_EQUAL(list.size(), 2U); |
| 50 | + addRecordToList(list, DNSName("Foo"), QType::A, "1.2.3.4"); |
| 51 | + addRecordToList(list, DNSName("FoO"), QType::A, "1.2.3.4", DNSResourceRecord::ADDITIONAL, 999); |
| 52 | + dups = pdns::dedupRecords(list); |
| 53 | + BOOST_CHECK_EQUAL(dups, 2U); |
| 54 | + BOOST_CHECK_EQUAL(list.size(), 2U); |
| 55 | + BOOST_CHECK_EQUAL(address, &list); |
| 56 | +} |
| 57 | + |
| 58 | +BOOST_AUTO_TEST_SUITE_END() |
0 commit comments