Fix deprecation warning
Also put iterator into dhandy namespace. I don't remember why I left it out, and it's probably a sign I should have not done so.
This commit is contained in:
parent
d3092f9359
commit
4d904ac689
3 changed files with 70 additions and 3 deletions
58
test/unit/infix_iterator.cpp
Normal file
58
test/unit/infix_iterator.cpp
Normal file
|
@ -0,0 +1,58 @@
|
|||
/* Copyright 2016-2024 Michele Santullo
|
||||
* This file is part of "duckhandy".
|
||||
*
|
||||
* "duckhandy" 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 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* "duckhandy" 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 "duckhandy". If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "catch2/catch_test_macros.hpp"
|
||||
#include "duckhandy/infix_iterator.hpp"
|
||||
#include <algorithm>
|
||||
#include <sstream>
|
||||
#include <vector>
|
||||
|
||||
TEST_CASE("infix_iterator tests", "[iterator][infix_iterator]") {
|
||||
using std::vector;
|
||||
using std::string;
|
||||
using std::copy;
|
||||
using std::ostringstream;
|
||||
using dhandy::infix_ostream_iterator;
|
||||
|
||||
{
|
||||
ostringstream oss;
|
||||
vector<string> empty{};
|
||||
copy(empty.begin(), empty.end(), infix_ostream_iterator<string>(oss, "lalala"));
|
||||
CHECK(oss.str() == "");
|
||||
}
|
||||
|
||||
{
|
||||
ostringstream oss;
|
||||
vector<string> data{"apple", "pear", "cherry", "mango"};
|
||||
copy(data.begin(), data.end(), infix_ostream_iterator<string>(oss, "lalala"));
|
||||
CHECK(oss.str() == "applelalalapearlalalacherrylalalamango");
|
||||
}
|
||||
|
||||
{
|
||||
ostringstream oss;
|
||||
vector<int> data{1, 2, 3, 4, 5, 6, 7};
|
||||
copy(data.begin(), data.end(), infix_ostream_iterator<int>(oss, ", "));
|
||||
CHECK(oss.str() == "1, 2, 3, 4, 5, 6, 7");
|
||||
}
|
||||
|
||||
{
|
||||
ostringstream oss;
|
||||
vector<string> data{"just one value"};
|
||||
copy(data.begin(), data.end(), infix_ostream_iterator<string>(oss, ", "));
|
||||
CHECK(oss.str() == "just one value");
|
||||
}
|
||||
}
|
|
@ -9,6 +9,7 @@ unit_test_prog = executable(meson.project_name(),
|
|||
'resource_pool_test.cpp',
|
||||
'version_test.cpp',
|
||||
'tiger_test.cpp',
|
||||
'infix_iterator.cpp',
|
||||
install: false,
|
||||
dependencies: [sprout_dep, catch2_dep],
|
||||
include_directories: [public_incl],
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue