Skip to content

Commit 853d5df

Browse files
fixed floating error
1 parent e455550 commit 853d5df

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

taskflow/graph/flow_builder.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ auto FlowBuilder::parallel_for(I beg, I end, I s, C&& c, size_t g) {
183183

184184
using T = std::decay_t<I>;
185185

186-
if((s == 0 && beg != end) || (beg < end && s <= 0) || (beg > end && s >=0) ) {
186+
if((s == 0) || (beg < end && s <= 0) || (beg > end && s >=0) ) {
187187
TF_THROW(Error::FLOW_BUILDER,
188188
"invalid range [", beg, ", ", end, ") with step size ", s
189189
);

unittest/taskflow.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -386,19 +386,18 @@ TEST_CASE("ParallelForOnIndex" * doctest::timeout(300)) {
386386
REQUIRE_THROWS(tf.parallel_for(0.0, 10.0, -1.0, [] (auto) {}));
387387
REQUIRE_THROWS(tf.parallel_for(10.0, 0.0, 0.0, [] (auto) {}));
388388
REQUIRE_THROWS(tf.parallel_for(10.0, 0.0, 1.0, [] (auto) {}));
389+
REQUIRE_THROWS(tf.parallel_for(0, 0, 0, [] (auto) {}));
390+
REQUIRE_THROWS(tf.parallel_for(0u, 0u, 0u, [] (auto) {}));
391+
REQUIRE_THROWS(tf.parallel_for(0.0, 0.0, 0.0, [] (auto) {}));
389392

390393
// graceful case
391394
REQUIRE_NOTHROW(tf.parallel_for(0, 0, -1, [] (auto) {}));
392395
REQUIRE_NOTHROW(tf.parallel_for(0, 0, 1, [] (auto) {}));
393-
REQUIRE_NOTHROW(tf.parallel_for(0, 0, 0, [] (auto) {}));
394396
REQUIRE_NOTHROW(tf.parallel_for(0u, 0u, 1u, [] (auto) {}));
395-
REQUIRE_NOTHROW(tf.parallel_for(0u, 0u, 0u, [] (auto) {}));
396397
REQUIRE_NOTHROW(tf.parallel_for(0.0f, 0.0f, -1.0f, [] (auto) {}));
397398
REQUIRE_NOTHROW(tf.parallel_for(0.0f, 0.0f, 1.0f, [] (auto) {}));
398-
REQUIRE_NOTHROW(tf.parallel_for(0.0f, 0.0f, 0.0f, [] (auto) {}));
399399
REQUIRE_NOTHROW(tf.parallel_for(0.0, 0.0, -1.0, [] (auto) {}));
400400
REQUIRE_NOTHROW(tf.parallel_for(0.0, 0.0, 1.0, [] (auto) {}));
401-
REQUIRE_NOTHROW(tf.parallel_for(0.0, 0.0, 0.0, [] (auto) {}));
402401
};
403402

404403
auto positive_integer_step = [] (unsigned num_workers) {

0 commit comments

Comments
 (0)