-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⚗️ (stl): Test std::ranges support for arm-gcc + clang
- Loading branch information
Showing
8 changed files
with
376 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Leka - LekaOS | ||
// Copyright 2022 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#pragma once | ||
|
||
#include <ranges> | ||
|
||
namespace leka::utils::ranges { | ||
|
||
struct SequenceFromTo { | ||
int start; | ||
int end; | ||
}; | ||
|
||
constexpr auto sequence(const SequenceFromTo seq) | ||
{ | ||
auto values = std::ranges::views::iota(seq.start, seq.end + 1); | ||
return values; | ||
} | ||
|
||
struct SequenceFromSize { | ||
int from; | ||
int size; | ||
}; | ||
|
||
constexpr auto sequence(const SequenceFromSize seq) | ||
{ | ||
auto values = std::ranges::views::iota(seq.from, seq.from + seq.size); | ||
return values; | ||
} | ||
|
||
} // namespace leka::utils::ranges |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,3 +7,4 @@ | |
#include "CastUtils.h" | ||
#include "MathUtils.h" | ||
#include "MemoryUtils.h" | ||
#include "RangesUtils.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
// Leka - LekaOS | ||
// Copyright 2022 APF France handicap | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
#include "Utils.h" | ||
#include "gtest/gtest.h" | ||
|
||
using namespace leka::utils::ranges; | ||
|
||
TEST(RangesTests, fromStart0ToEnd5) | ||
{ | ||
auto expected = std::to_array({0, 1, 2, 3, 4, 5}); | ||
|
||
auto i = 0; | ||
for (auto value: sequence({.start = 0, .end = 5})) { | ||
EXPECT_EQ(value, expected.at(i)); | ||
++i; | ||
} | ||
|
||
EXPECT_EQ(i, 5 + 1) << "Loop ran " << i << " times, should run " << 5 + 1 << " times"; | ||
} | ||
|
||
TEST(RangesTests, fromStart10ToEnd20) | ||
{ | ||
auto expected = std::to_array({10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20}); | ||
|
||
auto i = 0; | ||
for (auto value: sequence({.start = 10, .end = 20})) { | ||
EXPECT_EQ(value, expected.at(i)); | ||
++i; | ||
} | ||
|
||
EXPECT_EQ(i, 10 + 1) << "Loop ran " << i << " times, should run " << 10 + 1 << " times"; | ||
} | ||
|
||
TEST(RangesTests, fromStart0ToEnd0) | ||
{ | ||
auto expected = std::to_array({0}); | ||
|
||
auto i = 0; | ||
for (auto value: sequence({.start = 0, .end = 0})) { | ||
EXPECT_EQ(value, expected.at(i)); | ||
++i; | ||
} | ||
|
||
EXPECT_EQ(i, 1) << "Loop ran " << i << " times, should run " << 0 + 1 << " times"; | ||
} | ||
|
||
TEST(RangesTests, fromStart1ToEnd1) | ||
{ | ||
auto expected = std::to_array({1}); | ||
|
||
auto i = 0; | ||
for (auto value: sequence({.start = 1, .end = 1})) { | ||
EXPECT_EQ(value, expected.at(i)); | ||
++i; | ||
} | ||
|
||
EXPECT_EQ(i, 1) << "Loop ran " << i << " times, should run " << 0 + 1 << " times"; | ||
} | ||
|
||
TEST(RangesTests, from0Size5) | ||
{ | ||
auto expected = std::to_array({0, 1, 2, 3, 4}); | ||
|
||
auto i = 0; | ||
for (auto value: sequence({.from = 0, .size = 5})) { | ||
EXPECT_EQ(value, expected.at(i)); | ||
++i; | ||
} | ||
|
||
EXPECT_EQ(i, 5) << "Loop ran " << i << " times, should run " << 5 << " times"; | ||
} | ||
|
||
TEST(RangesTests, from10Size10) | ||
{ | ||
auto expected = std::to_array({10, 11, 12, 13, 14, 15, 16, 17, 18, 19}); | ||
|
||
auto i = 0; | ||
for (auto value: sequence({.from = 10, .size = 10})) { | ||
EXPECT_EQ(value, expected.at(i)); | ||
++i; | ||
} | ||
|
||
EXPECT_EQ(i, 10) << "Loop ran " << i << " times, should run " << 10 << " times"; | ||
} | ||
|
||
TEST(RangesTests, from0Size0) | ||
{ | ||
auto expected = std::to_array({0}); | ||
|
||
auto i = 0; | ||
for (auto value: sequence({.from = 0, .size = 0})) { | ||
EXPECT_EQ(value, expected.at(i)); | ||
++i; | ||
} | ||
|
||
EXPECT_EQ(i, 0) << "Loop ran " << i << " times, should run " << 0 << " times"; | ||
} | ||
|
||
TEST(RangesTests, from0Size1) | ||
{ | ||
auto expected = std::to_array({0}); | ||
|
||
auto i = 0; | ||
for (auto value: sequence({.from = 0, .size = 1})) { | ||
EXPECT_EQ(value, expected.at(i)); | ||
++i; | ||
} | ||
|
||
EXPECT_EQ(i, 1) << "Loop ran " << i << " times, should run " << 1 << " times"; | ||
} | ||
|
||
TEST(RangesTests, from1Size0) | ||
{ | ||
auto expected = std::to_array({1}); | ||
|
||
auto i = 0; | ||
for (auto value: sequence({.from = 1, .size = 0})) { | ||
EXPECT_EQ(value, expected.at(i)); | ||
++i; | ||
} | ||
|
||
EXPECT_EQ(i, 0) << "Loop ran " << i << " times, should run " << 0 << " times"; | ||
} | ||
|
||
TEST(RangesTests, from1Size1) | ||
{ | ||
auto expected = std::to_array({1}); | ||
|
||
auto i = 0; | ||
for (auto value: sequence({.from = 1, .size = 1})) { | ||
EXPECT_EQ(value, expected.at(i)); | ||
++i; | ||
} | ||
|
||
EXPECT_EQ(i, 1) << "Loop ran " << i << " times, should run " << 1 << " times"; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# Leka - LekaOS | ||
# Copyright 2022 APF France handicap | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
register_functional_test( | ||
TARGET | ||
functional_ut_std_features | ||
|
||
INCLUDE_DIRECTORIES | ||
|
||
SOURCES | ||
suite_std_ranges.cpp | ||
|
||
LINK_LIBRARIES | ||
) |
Oops, something went wrong.