Skip to content

Commit

Permalink
Remove testing-tools/span.h
Browse files Browse the repository at this point in the history
  • Loading branch information
Morwenn committed Jan 16, 2024
1 parent a3ce49c commit e537e0a
Show file tree
Hide file tree
Showing 7 changed files with 30 additions and 83 deletions.
16 changes: 8 additions & 8 deletions tests/adapters/hybrid_adapter_sfinae.cpp
@@ -1,15 +1,15 @@
/*
* Copyright (c) 2015-2022 Morwenn
* Copyright (c) 2015-2024 Morwenn
* SPDX-License-Identifier: MIT
*/
#include <concepts>
#include <iterator>
#include <span>
#include <string>
#include <vector>
#include <catch2/catch_test_macros.hpp>
#include <cpp-sort/adapters/hybrid_adapter.h>
#include <cpp-sort/sorter_facade.h>
#include <testing-tools/span.h>

namespace
{
Expand Down Expand Up @@ -116,13 +116,13 @@ TEST_CASE( "sfinae forwarding in hybrid_adapter",

SECTION( "with span" )
{
sorter_type res1 = sorter(make_span(vec1));
sorter_type res1 = sorter(std::span(vec1));
CHECK( res1 == sorter_type::integer );

sorter_type res2 = sorter(make_span(vec2));
sorter_type res2 = sorter(std::span(vec2));
CHECK( res2 == sorter_type::floating_point );

sorter_type res3 = sorter(make_span(vec3));
sorter_type res3 = sorter(std::span(vec3));
CHECK( res3 == sorter_type::generic );
}
}
Expand Down Expand Up @@ -173,13 +173,13 @@ TEST_CASE( "sfinae forwarding in nested hybrid_adapter",

SECTION( "with span" )
{
sorter_type res1 = sorter(make_span(vec1));
sorter_type res1 = sorter(std::span(vec1));
CHECK( res1 == sorter_type::integer );

sorter_type res2 = sorter(make_span(vec2));
sorter_type res2 = sorter(std::span(vec2));
CHECK( res2 == sorter_type::floating_point );

sorter_type res3 = sorter(make_span(vec3));
sorter_type res3 = sorter(std::span(vec3));
CHECK( res3 == sorter_type::generic );
}
}
10 changes: 5 additions & 5 deletions tests/adapters/indirect_adapter.cpp
@@ -1,18 +1,18 @@
/*
* Copyright (c) 2016-2022 Morwenn
* Copyright (c) 2016-2024 Morwenn
* SPDX-License-Identifier: MIT
*/
#include <algorithm>
#include <functional>
#include <iterator>
#include <span>
#include <vector>
#include <catch2/catch_test_macros.hpp>
#include <cpp-sort/adapters/indirect_adapter.h>
#include <cpp-sort/sorters/quick_sorter.h>
#include <cpp-sort/sorters/spread_sorter.h>
#include <testing-tools/algorithm.h>
#include <testing-tools/distributions.h>
#include <testing-tools/span.h>

TEST_CASE( "basic tests with indirect_adapter",
"[indirect_adapter]" )
Expand Down Expand Up @@ -74,20 +74,20 @@ TEST_CASE( "indirect_adapter with temporary span",

SECTION( "with comparison" )
{
sorter(make_span(collection), std::greater<>{});
sorter(std::span(collection), std::greater<>{});
CHECK( std::is_sorted(collection.begin(), collection.end(), std::greater<>{}) );
}

SECTION( "with projection" )
{
sorter(make_span(collection), std::negate<>{});
sorter(std::span(collection), std::negate<>{});
CHECK( helpers::is_sorted(collection.begin(), collection.end(),
std::less<>{}, std::negate<>{}) );
}

SECTION( "with comparison and projection" )
{
sorter(make_span(collection), std::greater<>{}, std::negate<>{});
sorter(std::span(collection), std::greater<>{}, std::negate<>{});
CHECK( std::is_sorted(collection.begin(), collection.end()) );
}
}
Expand Down
13 changes: 6 additions & 7 deletions tests/metrics/comparisons.cpp
@@ -1,19 +1,18 @@
/*
* Copyright (c) 2023 Morwenn
* Copyright (c) 2023-2024 Morwenn
* SPDX-License-Identifier: MIT
*/
#include <algorithm>
#include <cstddef>
#include <functional>
#include <iterator>
#include <list>
#include <vector>
#include <ranges>
#include <catch2/catch_test_macros.hpp>
#include <cpp-sort/metrics/comparisons.h>
#include <cpp-sort/sorters/selection_sorter.h>
#include <testing-tools/algorithm.h>
#include <testing-tools/distributions.h>
#include <testing-tools/span.h>
#include <testing-tools/wrapper.h>

using wrapper = generic_wrapper<int>;
Expand Down Expand Up @@ -52,8 +51,8 @@ TEST_CASE( "basic metrics::comparisons tests",
}
}

TEST_CASE( "metrics::comparisons with span",
"[metrics][span][selection_sorter]" )
TEST_CASE( "metrics::comparisons with temporary range",
"[metrics][subrange][selection_sorter]" )
{
cppsort::metrics::comparisons<
cppsort::selection_sorter
Expand All @@ -65,7 +64,7 @@ TEST_CASE( "metrics::comparisons with span",
auto distribution = dist::shuffled{};
distribution(std::back_inserter(collection), 65, 0);

auto res = sorter(make_span(collection));
auto res = sorter(std::ranges::subrange(collection));
CHECK( res == 2080 );
CHECK( std::is_sorted(collection.begin(), collection.end()) );
}
Expand All @@ -76,7 +75,7 @@ TEST_CASE( "metrics::comparisons with span",
auto distribution = dist::shuffled{};
distribution(std::back_inserter(collection), 80, 0);

auto res = sorter(make_span(collection), &wrapper::value);
auto res = sorter(std::ranges::subrange(collection), &wrapper::value);
CHECK( res == 3160 );
CHECK( helpers::is_sorted(collection.begin(), collection.end(),
std::less<>{}, &wrapper::value) );
Expand Down
8 changes: 4 additions & 4 deletions tests/metrics/moves.cpp
@@ -1,18 +1,18 @@
/*
* Copyright (c) 2023 Morwenn
* Copyright (c) 2023-2024 Morwenn
* SPDX-License-Identifier: MIT
*/
#include <algorithm>
#include <cstddef>
#include <functional>
#include <iterator>
#include <span>
#include <vector>
#include <catch2/catch_test_macros.hpp>
#include <cpp-sort/metrics/moves.h>
#include <cpp-sort/sorters/heap_sorter.h>
#include <testing-tools/algorithm.h>
#include <testing-tools/distributions.h>
#include <testing-tools/span.h>
#include <testing-tools/wrapper.h>

using wrapper = generic_wrapper<int>;
Expand Down Expand Up @@ -57,7 +57,7 @@ TEST_CASE( "metrics::moves with span",
auto distribution = dist::descending_plateau{};
distribution(std::back_inserter(collection), 65);

auto res = sorter(make_span(collection));
auto res = sorter(std::span(collection));
CHECK( res == 463 );
CHECK( std::is_sorted(collection.begin(), collection.end()) );
}
Expand All @@ -68,7 +68,7 @@ TEST_CASE( "metrics::moves with span",
auto distribution = dist::descending_plateau{};
distribution(std::back_inserter(collection), 80);

auto res = sorter(make_span(collection), &wrapper::value);
auto res = sorter(std::span(collection), &wrapper::value);
CHECK( res == 573 );
CHECK( helpers::is_sorted(collection.begin(), collection.end(),
std::less<>{}, &wrapper::value) );
Expand Down
9 changes: 4 additions & 5 deletions tests/metrics/projections.cpp
@@ -1,20 +1,19 @@
/*
* Copyright (c) 2023 Morwenn
* Copyright (c) 2023-2024 Morwenn
* SPDX-License-Identifier: MIT
*/
#include <algorithm>
#include <cstddef>
#include <functional>
#include <iterator>
#include <list>
#include <vector>
#include <ranges>
#include <catch2/catch_test_macros.hpp>
#include <cpp-sort/metrics/projections.h>
#include <cpp-sort/sorters/selection_sorter.h>
#include <cpp-sort/sorters/std_sorter.h>
#include <testing-tools/algorithm.h>
#include <testing-tools/distributions.h>
#include <testing-tools/span.h>
#include <testing-tools/wrapper.h>

using wrapper = generic_wrapper<int>;
Expand Down Expand Up @@ -66,7 +65,7 @@ TEST_CASE( "metrics::projections with span",
auto distribution = dist::shuffled{};
distribution(std::back_inserter(collection), 65, 0);

auto res = sorter(make_span(collection));
auto res = sorter(std::ranges::subrange(collection));
CHECK( res == 4160 );
CHECK( std::is_sorted(collection.begin(), collection.end()) );
}
Expand All @@ -77,7 +76,7 @@ TEST_CASE( "metrics::projections with span",
auto distribution = dist::shuffled{};
distribution(std::back_inserter(collection), 80, 0);

auto res = sorter(make_span(collection), &wrapper::value);
auto res = sorter(std::ranges::subrange(collection), &wrapper::value);
CHECK( res == 6320 );
CHECK( helpers::is_sorted(collection.begin(), collection.end(),
std::less<>{}, &wrapper::value) );
Expand Down
6 changes: 3 additions & 3 deletions tests/sorters/every_sorter_span.cpp
@@ -1,17 +1,17 @@
/*
* Copyright (c) 2016-2023 Morwenn
* Copyright (c) 2016-2024 Morwenn
* SPDX-License-Identifier: MIT
*/
#include <algorithm>
#include <iterator>
#include <span>
#include <vector>
#include <catch2/catch_template_test_macros.hpp>
#include <cpp-sort/sorters.h>
#include <cpp-sort/utility/buffer.h>
#include <cpp-sort/utility/functional.h>
#include <testing-tools/distributions.h>
#include <testing-tools/old_sorters.h>
#include <testing-tools/span.h>

TEMPLATE_TEST_CASE( "test every sorter with temporary span", "[sorters][span]",
old_default_sorter,
Expand Down Expand Up @@ -58,6 +58,6 @@ TEMPLATE_TEST_CASE( "test every sorter with temporary span", "[sorters][span]",
distribution(std::back_inserter(collection), 491, -125);

TestType sorter;
sorter(make_span(collection));
sorter(std::span(collection));
CHECK( std::is_sorted(collection.begin(), collection.end()) );
}
51 changes: 0 additions & 51 deletions tests/testing-tools/span.h

This file was deleted.

0 comments on commit e537e0a

Please sign in to comment.