mirror of
https://github.com/saymrwulf/uhd.git
synced 2026-05-14 20:58:09 +00:00
Starting with Boost 1.66 and the corresponding ASIO version, there were some changes introduced based on the C++ Networking TS. This includes changes like replacing io_service with io_context, deprecating some functions, etc. Starting with Boost 1.87, the old style is no longer supported. This commit updates all usage of ASIO in a way that makes UHD compatible with future versions of ASIO. However, this makes UHD no longer compatible with Boost 1.65 and below. Summary of changes: - Replace asio::io_service with asio::io_context - Replace asio::io_service::strand with asio::strand<asio::io_context::executor_type> - This implies using asio::post() instead of asio::strand::post() - Replace asio::buffer_cast<T>(buf) with static_cast<T>(buf.data()) - Update resolve(query) with new API - Replace references to endpoint_iterator with resolver::results_type - Replace ip::address::from_string() with ip::make_address() Co-authored-by: Jörg Hofrichter <joerg.hofrichter@emerson.com>
80 lines
2.3 KiB
C++
80 lines
2.3 KiB
C++
//
|
|
// Copyright 2018 Ettus Research, a National Instruments Company
|
|
//
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
//
|
|
|
|
#include <uhdlib/utils/eeprom_utils.hpp>
|
|
#include <boost/assign/list_of.hpp>
|
|
#include <boost/test/unit_test.hpp>
|
|
|
|
using namespace boost::assign;
|
|
|
|
class upper_case_char
|
|
{
|
|
public:
|
|
upper_case_char(char ch)
|
|
{
|
|
value = ch;
|
|
}
|
|
static upper_case_char from_string(std::string str)
|
|
{
|
|
return upper_case_char(toupper(str[0]));
|
|
}
|
|
std::string to_string()
|
|
{
|
|
return std::string(1, value);
|
|
}
|
|
|
|
private:
|
|
char value;
|
|
};
|
|
|
|
BOOST_AUTO_TEST_CASE(test_eeprom_duplicate_check)
|
|
{
|
|
const uhd::dict<std::string, std::string> curr_eeprom =
|
|
map_list_of("0", "A")("1", "B")("2", "C");
|
|
const uhd::dict<std::string, std::string> new_eeprom_no_dups =
|
|
map_list_of("0", "d")("1", "e");
|
|
const uhd::dict<std::string, std::string> new_eeprom_dups_in_curr =
|
|
map_list_of("0", "b");
|
|
const uhd::dict<std::string, std::string> new_eeprom_dups_in_new =
|
|
map_list_of("0", "c")("1", "c");
|
|
const uhd::dict<std::string, std::string> new_eeprom_dups_in_both =
|
|
map_list_of("0", "b")("1", "B");
|
|
const std::vector<std::string> keys = {"0", "1", "2"};
|
|
|
|
BOOST_CHECK_EQUAL(check_for_duplicates("TEST",
|
|
new_eeprom_no_dups,
|
|
curr_eeprom,
|
|
"Test Value",
|
|
keys,
|
|
[](const std::string& str) {
|
|
return upper_case_char::from_string(str).to_string();
|
|
}),
|
|
false);
|
|
BOOST_CHECK(check_for_duplicates("TEST",
|
|
new_eeprom_dups_in_curr,
|
|
curr_eeprom,
|
|
"Test Value",
|
|
keys,
|
|
[](const std::string& str) {
|
|
return upper_case_char::from_string(str).to_string();
|
|
}));
|
|
BOOST_CHECK(check_for_duplicates("TEST",
|
|
new_eeprom_dups_in_new,
|
|
curr_eeprom,
|
|
"Test Value",
|
|
keys,
|
|
[](const std::string& str) {
|
|
return upper_case_char::from_string(str).to_string();
|
|
}));
|
|
BOOST_CHECK(check_for_duplicates("TEST",
|
|
new_eeprom_dups_in_both,
|
|
curr_eeprom,
|
|
"Test Value",
|
|
keys,
|
|
[](const std::string& str) {
|
|
return upper_case_char::from_string(str).to_string();
|
|
}));
|
|
}
|