You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@nifi.apache.org by GitBox <gi...@apache.org> on 2020/10/01 14:27:23 UTC
[GitHub] [nifi-minifi-cpp] szaszm opened a new pull request #918: MINIFICPP-1383 fix indiv_ceil
szaszm opened a new pull request #918:
URL: https://github.com/apache/nifi-minifi-cpp/pull/918
Thank you for submitting a contribution to Apache NiFi - MiNiFi C++.
In order to streamline the review of the contribution we ask you
to ensure the following steps have been taken:
### For all changes:
- [x] Is there a JIRA ticket associated with this PR? Is it referenced
in the commit message?
- [x] Does your PR title start with MINIFICPP-XXXX where XXXX is the JIRA number you are trying to resolve? Pay particular attention to the hyphen "-" character.
- [x] Has your PR been rebased against the latest commit within the target branch (typically main)?
- [ ] Is your initial contribution a single, squashed commit?
### For code changes:
- [x] If adding new dependencies to the code, are these dependencies licensed in a way that is compatible for inclusion under [ASF 2.0](http://www.apache.org/legal/resolved.html#category-a)?
- [x] If applicable, have you updated the LICENSE file?
- [x] If applicable, have you updated the NOTICE file?
### For documentation related changes:
- [x] Have you ensured that format looks appropriate for the output in which it is rendered?
### Note:
Please ensure that once the PR is submitted, you check GitHub Actions CI results for build issues and submit an update to your PR as soon as possible.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #918: MINIFICPP-1383 fix intdiv_ceil
Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #918:
URL: https://github.com/apache/nifi-minifi-cpp/pull/918#discussion_r501035283
##########
File path: libminifi/test/unit/GeneralUtilsTest.cpp
##########
@@ -32,18 +32,20 @@ TEST_CASE("GeneralUtils::make_unique", "[make_unique]") {
REQUIRE("test string" == *pstr);
}
-TEST_CASE("GeneralUtils::intdiv_ceil", "[intdiv_ceil]") {
- REQUIRE(0 == utils::intdiv_ceil(0, 1));
- REQUIRE(0 == utils::intdiv_ceil(0, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 3));
- REQUIRE(1 == utils::intdiv_ceil(3, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(0 == utils::intdiv_ceil(-1, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-3, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-4, 3));
-}
+static_assert(0 == utils::intdiv_ceil(0, 1), "");
+static_assert(0 == utils::intdiv_ceil(0, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 3), "");
+static_assert(1 == utils::intdiv_ceil(3, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(0 == utils::intdiv_ceil(-1, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-3, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-4, 3), "");
+static_assert(2 == utils::intdiv_ceil(-4, -3), "");
+static_assert(2 == utils::intdiv_ceil(-5, -3), "");
+static_assert(0 == utils::intdiv_ceil(1, -3), "");
+static_assert(-1 == utils::intdiv_ceil(5, -3), "");
Review comment:
I'll survive somehow :) a slight addition would be to include a case that should compile so we could check for false negatives, e.g. if by accident `does_compile<...>::value` always returns `false`, basically a test for the test
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #918: MINIFICPP-1383 fix intdiv_ceil
Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #918:
URL: https://github.com/apache/nifi-minifi-cpp/pull/918#discussion_r498760546
##########
File path: libminifi/test/unit/GeneralUtilsTest.cpp
##########
@@ -32,18 +32,20 @@ TEST_CASE("GeneralUtils::make_unique", "[make_unique]") {
REQUIRE("test string" == *pstr);
}
-TEST_CASE("GeneralUtils::intdiv_ceil", "[intdiv_ceil]") {
- REQUIRE(0 == utils::intdiv_ceil(0, 1));
- REQUIRE(0 == utils::intdiv_ceil(0, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 3));
- REQUIRE(1 == utils::intdiv_ceil(3, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(0 == utils::intdiv_ceil(-1, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-3, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-4, 3));
-}
+static_assert(0 == utils::intdiv_ceil(0, 1), "");
+static_assert(0 == utils::intdiv_ceil(0, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 3), "");
+static_assert(1 == utils::intdiv_ceil(3, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(0 == utils::intdiv_ceil(-1, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-3, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-4, 3), "");
+static_assert(2 == utils::intdiv_ceil(-4, -3), "");
+static_assert(2 == utils::intdiv_ceil(-5, -3), "");
+static_assert(0 == utils::intdiv_ceil(1, -3), "");
+static_assert(-1 == utils::intdiv_ceil(5, -3), "");
Review comment:
Not sure how can I test that division by 0 doesn't compile. Will do the rest.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #918: MINIFICPP-1383 fix intdiv_ceil
Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #918:
URL: https://github.com/apache/nifi-minifi-cpp/pull/918#discussion_r498763931
##########
File path: libminifi/test/unit/GeneralUtilsTest.cpp
##########
@@ -32,18 +32,20 @@ TEST_CASE("GeneralUtils::make_unique", "[make_unique]") {
REQUIRE("test string" == *pstr);
}
-TEST_CASE("GeneralUtils::intdiv_ceil", "[intdiv_ceil]") {
- REQUIRE(0 == utils::intdiv_ceil(0, 1));
- REQUIRE(0 == utils::intdiv_ceil(0, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 3));
- REQUIRE(1 == utils::intdiv_ceil(3, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(0 == utils::intdiv_ceil(-1, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-3, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-4, 3));
-}
+static_assert(0 == utils::intdiv_ceil(0, 1), "");
+static_assert(0 == utils::intdiv_ceil(0, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 3), "");
+static_assert(1 == utils::intdiv_ceil(3, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(0 == utils::intdiv_ceil(-1, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-3, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-4, 3), "");
+static_assert(2 == utils::intdiv_ceil(-4, -3), "");
+static_assert(2 == utils::intdiv_ceil(-5, -3), "");
+static_assert(0 == utils::intdiv_ceil(1, -3), "");
+static_assert(-1 == utils::intdiv_ceil(5, -3), "");
Review comment:
you could SFINAE it:
```
template<int n, int d, typename = void>
struct does_compile : std::false_type {};
template<int n, int d>
struct does_compile<n, d, decltype(intdiv_ceil(n, d))> : std::true_type {};
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #918: MINIFICPP-1383 fix intdiv_ceil
Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #918:
URL: https://github.com/apache/nifi-minifi-cpp/pull/918#discussion_r498763716
##########
File path: libminifi/test/unit/GeneralUtilsTest.cpp
##########
@@ -32,18 +32,20 @@ TEST_CASE("GeneralUtils::make_unique", "[make_unique]") {
REQUIRE("test string" == *pstr);
}
-TEST_CASE("GeneralUtils::intdiv_ceil", "[intdiv_ceil]") {
- REQUIRE(0 == utils::intdiv_ceil(0, 1));
- REQUIRE(0 == utils::intdiv_ceil(0, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 3));
- REQUIRE(1 == utils::intdiv_ceil(3, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(0 == utils::intdiv_ceil(-1, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-3, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-4, 3));
-}
+static_assert(0 == utils::intdiv_ceil(0, 1), "");
+static_assert(0 == utils::intdiv_ceil(0, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 3), "");
+static_assert(1 == utils::intdiv_ceil(3, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
Review comment:
fixed in 585e874
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #918: MINIFICPP-1383 fix intdiv_ceil
Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #918:
URL: https://github.com/apache/nifi-minifi-cpp/pull/918#discussion_r498760546
##########
File path: libminifi/test/unit/GeneralUtilsTest.cpp
##########
@@ -32,18 +32,20 @@ TEST_CASE("GeneralUtils::make_unique", "[make_unique]") {
REQUIRE("test string" == *pstr);
}
-TEST_CASE("GeneralUtils::intdiv_ceil", "[intdiv_ceil]") {
- REQUIRE(0 == utils::intdiv_ceil(0, 1));
- REQUIRE(0 == utils::intdiv_ceil(0, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 3));
- REQUIRE(1 == utils::intdiv_ceil(3, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(0 == utils::intdiv_ceil(-1, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-3, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-4, 3));
-}
+static_assert(0 == utils::intdiv_ceil(0, 1), "");
+static_assert(0 == utils::intdiv_ceil(0, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 3), "");
+static_assert(1 == utils::intdiv_ceil(3, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(0 == utils::intdiv_ceil(-1, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-3, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-4, 3), "");
+static_assert(2 == utils::intdiv_ceil(-4, -3), "");
+static_assert(2 == utils::intdiv_ceil(-5, -3), "");
+static_assert(0 == utils::intdiv_ceil(1, -3), "");
+static_assert(-1 == utils::intdiv_ceil(5, -3), "");
Review comment:
Not sure how can I test that 0 doesn't compile. Will do the rest.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #918: MINIFICPP-1383 fix intdiv_ceil
Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #918:
URL: https://github.com/apache/nifi-minifi-cpp/pull/918#discussion_r501032041
##########
File path: libminifi/test/unit/GeneralUtilsTest.cpp
##########
@@ -32,18 +32,20 @@ TEST_CASE("GeneralUtils::make_unique", "[make_unique]") {
REQUIRE("test string" == *pstr);
}
-TEST_CASE("GeneralUtils::intdiv_ceil", "[intdiv_ceil]") {
- REQUIRE(0 == utils::intdiv_ceil(0, 1));
- REQUIRE(0 == utils::intdiv_ceil(0, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 3));
- REQUIRE(1 == utils::intdiv_ceil(3, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(0 == utils::intdiv_ceil(-1, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-3, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-4, 3));
-}
+static_assert(0 == utils::intdiv_ceil(0, 1), "");
+static_assert(0 == utils::intdiv_ceil(0, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 3), "");
+static_assert(1 == utils::intdiv_ceil(3, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(0 == utils::intdiv_ceil(-1, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-3, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-4, 3), "");
+static_assert(2 == utils::intdiv_ceil(-4, -3), "");
+static_assert(2 == utils::intdiv_ceil(-5, -3), "");
+static_assert(0 == utils::intdiv_ceil(1, -3), "");
+static_assert(-1 == utils::intdiv_ceil(5, -3), "");
Review comment:
I hope you don't mind me setting you as the author as you basically submitted the whole code in b11f101
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #918: MINIFICPP-1383 fix intdiv_ceil
Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #918:
URL: https://github.com/apache/nifi-minifi-cpp/pull/918#discussion_r501032041
##########
File path: libminifi/test/unit/GeneralUtilsTest.cpp
##########
@@ -32,18 +32,20 @@ TEST_CASE("GeneralUtils::make_unique", "[make_unique]") {
REQUIRE("test string" == *pstr);
}
-TEST_CASE("GeneralUtils::intdiv_ceil", "[intdiv_ceil]") {
- REQUIRE(0 == utils::intdiv_ceil(0, 1));
- REQUIRE(0 == utils::intdiv_ceil(0, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 3));
- REQUIRE(1 == utils::intdiv_ceil(3, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(0 == utils::intdiv_ceil(-1, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-3, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-4, 3));
-}
+static_assert(0 == utils::intdiv_ceil(0, 1), "");
+static_assert(0 == utils::intdiv_ceil(0, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 3), "");
+static_assert(1 == utils::intdiv_ceil(3, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(0 == utils::intdiv_ceil(-1, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-3, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-4, 3), "");
+static_assert(2 == utils::intdiv_ceil(-4, -3), "");
+static_assert(2 == utils::intdiv_ceil(-5, -3), "");
+static_assert(0 == utils::intdiv_ceil(1, -3), "");
+static_assert(-1 == utils::intdiv_ceil(5, -3), "");
Review comment:
I hope you don't mind me setting you as the author of b11f101 as you basically submitted the whole code above
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #918: MINIFICPP-1383 fix intdiv_ceil
Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #918:
URL: https://github.com/apache/nifi-minifi-cpp/pull/918#discussion_r498765811
##########
File path: libminifi/test/unit/GeneralUtilsTest.cpp
##########
@@ -32,18 +32,20 @@ TEST_CASE("GeneralUtils::make_unique", "[make_unique]") {
REQUIRE("test string" == *pstr);
}
-TEST_CASE("GeneralUtils::intdiv_ceil", "[intdiv_ceil]") {
- REQUIRE(0 == utils::intdiv_ceil(0, 1));
- REQUIRE(0 == utils::intdiv_ceil(0, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 3));
- REQUIRE(1 == utils::intdiv_ceil(3, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(0 == utils::intdiv_ceil(-1, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-3, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-4, 3));
-}
+static_assert(0 == utils::intdiv_ceil(0, 1), "");
+static_assert(0 == utils::intdiv_ceil(0, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 3), "");
+static_assert(1 == utils::intdiv_ceil(3, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(0 == utils::intdiv_ceil(-1, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-3, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-4, 3), "");
+static_assert(2 == utils::intdiv_ceil(-4, -3), "");
+static_assert(2 == utils::intdiv_ceil(-5, -3), "");
+static_assert(0 == utils::intdiv_ceil(1, -3), "");
+static_assert(-1 == utils::intdiv_ceil(5, -3), "");
Review comment:
```
template<int n, int d, typename = void>
struct does_compile : std::false_type {};
template<int n, int d>
struct does_compile<n, d,
typename std::enable_if<(intdiv_ceil(n, d), true)>::type> : std::true_type {};
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] fgerlits commented on a change in pull request #918: MINIFICPP-1383 fix intdiv_ceil
Posted by GitBox <gi...@apache.org>.
fgerlits commented on a change in pull request #918:
URL: https://github.com/apache/nifi-minifi-cpp/pull/918#discussion_r498752589
##########
File path: libminifi/test/unit/GeneralUtilsTest.cpp
##########
@@ -32,18 +32,20 @@ TEST_CASE("GeneralUtils::make_unique", "[make_unique]") {
REQUIRE("test string" == *pstr);
}
-TEST_CASE("GeneralUtils::intdiv_ceil", "[intdiv_ceil]") {
- REQUIRE(0 == utils::intdiv_ceil(0, 1));
- REQUIRE(0 == utils::intdiv_ceil(0, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 3));
- REQUIRE(1 == utils::intdiv_ceil(3, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(0 == utils::intdiv_ceil(-1, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-3, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-4, 3));
-}
+static_assert(0 == utils::intdiv_ceil(0, 1), "");
+static_assert(0 == utils::intdiv_ceil(0, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 3), "");
+static_assert(1 == utils::intdiv_ceil(3, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
Review comment:
very minor (and old code), but you have the same (4, 3) test twice
##########
File path: libminifi/test/unit/GeneralUtilsTest.cpp
##########
@@ -32,18 +32,20 @@ TEST_CASE("GeneralUtils::make_unique", "[make_unique]") {
REQUIRE("test string" == *pstr);
}
-TEST_CASE("GeneralUtils::intdiv_ceil", "[intdiv_ceil]") {
- REQUIRE(0 == utils::intdiv_ceil(0, 1));
- REQUIRE(0 == utils::intdiv_ceil(0, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 3));
- REQUIRE(1 == utils::intdiv_ceil(3, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(0 == utils::intdiv_ceil(-1, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-3, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-4, 3));
-}
+static_assert(0 == utils::intdiv_ceil(0, 1), "");
+static_assert(0 == utils::intdiv_ceil(0, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 3), "");
+static_assert(1 == utils::intdiv_ceil(3, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(0 == utils::intdiv_ceil(-1, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-3, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-4, 3), "");
+static_assert(2 == utils::intdiv_ceil(-4, -3), "");
+static_assert(2 == utils::intdiv_ceil(-5, -3), "");
+static_assert(0 == utils::intdiv_ceil(1, -3), "");
+static_assert(-1 == utils::intdiv_ceil(5, -3), "");
Review comment:
you could add some more tests:
* (0, negative number)
* evenly divisible but not equal, eg. (6, 2) and variations: (-6, 2), (-6, -2), (6, -2)
* test that division by 0 doesn't compile
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] arpadboda closed pull request #918: MINIFICPP-1383 fix intdiv_ceil
Posted by GitBox <gi...@apache.org>.
arpadboda closed pull request #918:
URL: https://github.com/apache/nifi-minifi-cpp/pull/918
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #918: MINIFICPP-1383 fix intdiv_ceil
Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #918:
URL: https://github.com/apache/nifi-minifi-cpp/pull/918#discussion_r498765811
##########
File path: libminifi/test/unit/GeneralUtilsTest.cpp
##########
@@ -32,18 +32,20 @@ TEST_CASE("GeneralUtils::make_unique", "[make_unique]") {
REQUIRE("test string" == *pstr);
}
-TEST_CASE("GeneralUtils::intdiv_ceil", "[intdiv_ceil]") {
- REQUIRE(0 == utils::intdiv_ceil(0, 1));
- REQUIRE(0 == utils::intdiv_ceil(0, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 3));
- REQUIRE(1 == utils::intdiv_ceil(3, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(0 == utils::intdiv_ceil(-1, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-3, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-4, 3));
-}
+static_assert(0 == utils::intdiv_ceil(0, 1), "");
+static_assert(0 == utils::intdiv_ceil(0, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 3), "");
+static_assert(1 == utils::intdiv_ceil(3, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(0 == utils::intdiv_ceil(-1, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-3, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-4, 3), "");
+static_assert(2 == utils::intdiv_ceil(-4, -3), "");
+static_assert(2 == utils::intdiv_ceil(-5, -3), "");
+static_assert(0 == utils::intdiv_ceil(1, -3), "");
+static_assert(-1 == utils::intdiv_ceil(5, -3), "");
Review comment:
```
template<int n, int d, typename = void>
struct does_compile : std::false_type {};
template<int n, int d>
struct does_compile<n, d,
// we must force evaluation so decltype won't do
typename std::enable_if<(intdiv_ceil(n, d), true)>::type> : std::true_type {};
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] adamdebreceni commented on a change in pull request #918: MINIFICPP-1383 fix intdiv_ceil
Posted by GitBox <gi...@apache.org>.
adamdebreceni commented on a change in pull request #918:
URL: https://github.com/apache/nifi-minifi-cpp/pull/918#discussion_r498765811
##########
File path: libminifi/test/unit/GeneralUtilsTest.cpp
##########
@@ -32,18 +32,20 @@ TEST_CASE("GeneralUtils::make_unique", "[make_unique]") {
REQUIRE("test string" == *pstr);
}
-TEST_CASE("GeneralUtils::intdiv_ceil", "[intdiv_ceil]") {
- REQUIRE(0 == utils::intdiv_ceil(0, 1));
- REQUIRE(0 == utils::intdiv_ceil(0, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 3));
- REQUIRE(1 == utils::intdiv_ceil(3, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(0 == utils::intdiv_ceil(-1, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-3, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-4, 3));
-}
+static_assert(0 == utils::intdiv_ceil(0, 1), "");
+static_assert(0 == utils::intdiv_ceil(0, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 3), "");
+static_assert(1 == utils::intdiv_ceil(3, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(0 == utils::intdiv_ceil(-1, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-3, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-4, 3), "");
+static_assert(2 == utils::intdiv_ceil(-4, -3), "");
+static_assert(2 == utils::intdiv_ceil(-5, -3), "");
+static_assert(0 == utils::intdiv_ceil(1, -3), "");
+static_assert(-1 == utils::intdiv_ceil(5, -3), "");
Review comment:
```
template<int n, int d, typename = void>
struct does_compile : std::false_type {};
template<int n, int d>
struct does_compile<n, d, typename std::enable_if<(intdiv_ceil(n, d), true)>::type> : std::true_type {};
```
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #918: MINIFICPP-1383 fix intdiv_ceil
Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #918:
URL: https://github.com/apache/nifi-minifi-cpp/pull/918#discussion_r503379014
##########
File path: libminifi/test/unit/GeneralUtilsTest.cpp
##########
@@ -32,18 +32,20 @@ TEST_CASE("GeneralUtils::make_unique", "[make_unique]") {
REQUIRE("test string" == *pstr);
}
-TEST_CASE("GeneralUtils::intdiv_ceil", "[intdiv_ceil]") {
- REQUIRE(0 == utils::intdiv_ceil(0, 1));
- REQUIRE(0 == utils::intdiv_ceil(0, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 3));
- REQUIRE(1 == utils::intdiv_ceil(3, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(0 == utils::intdiv_ceil(-1, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-3, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-4, 3));
-}
+static_assert(0 == utils::intdiv_ceil(0, 1), "");
+static_assert(0 == utils::intdiv_ceil(0, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 3), "");
+static_assert(1 == utils::intdiv_ceil(3, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(0 == utils::intdiv_ceil(-1, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-3, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-4, 3), "");
+static_assert(2 == utils::intdiv_ceil(-4, -3), "");
+static_assert(2 == utils::intdiv_ceil(-5, -3), "");
+static_assert(0 == utils::intdiv_ceil(1, -3), "");
+static_assert(-1 == utils::intdiv_ceil(5, -3), "");
Review comment:
done in c26cf15
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [nifi-minifi-cpp] szaszm commented on a change in pull request #918: MINIFICPP-1383 fix intdiv_ceil
Posted by GitBox <gi...@apache.org>.
szaszm commented on a change in pull request #918:
URL: https://github.com/apache/nifi-minifi-cpp/pull/918#discussion_r498763716
##########
File path: libminifi/test/unit/GeneralUtilsTest.cpp
##########
@@ -32,18 +32,20 @@ TEST_CASE("GeneralUtils::make_unique", "[make_unique]") {
REQUIRE("test string" == *pstr);
}
-TEST_CASE("GeneralUtils::intdiv_ceil", "[intdiv_ceil]") {
- REQUIRE(0 == utils::intdiv_ceil(0, 1));
- REQUIRE(0 == utils::intdiv_ceil(0, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 3));
- REQUIRE(1 == utils::intdiv_ceil(3, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(0 == utils::intdiv_ceil(-1, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-3, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-4, 3));
-}
+static_assert(0 == utils::intdiv_ceil(0, 1), "");
+static_assert(0 == utils::intdiv_ceil(0, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 3), "");
+static_assert(1 == utils::intdiv_ceil(3, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
Review comment:
thanks for pointing out, fixed in 585e874
##########
File path: libminifi/test/unit/GeneralUtilsTest.cpp
##########
@@ -32,18 +32,20 @@ TEST_CASE("GeneralUtils::make_unique", "[make_unique]") {
REQUIRE("test string" == *pstr);
}
-TEST_CASE("GeneralUtils::intdiv_ceil", "[intdiv_ceil]") {
- REQUIRE(0 == utils::intdiv_ceil(0, 1));
- REQUIRE(0 == utils::intdiv_ceil(0, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 2));
- REQUIRE(1 == utils::intdiv_ceil(1, 3));
- REQUIRE(1 == utils::intdiv_ceil(3, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(2 == utils::intdiv_ceil(4, 3));
- REQUIRE(0 == utils::intdiv_ceil(-1, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-3, 3));
- REQUIRE(-1 == utils::intdiv_ceil(-4, 3));
-}
+static_assert(0 == utils::intdiv_ceil(0, 1), "");
+static_assert(0 == utils::intdiv_ceil(0, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 2), "");
+static_assert(1 == utils::intdiv_ceil(1, 3), "");
+static_assert(1 == utils::intdiv_ceil(3, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(2 == utils::intdiv_ceil(4, 3), "");
+static_assert(0 == utils::intdiv_ceil(-1, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-3, 3), "");
+static_assert(-1 == utils::intdiv_ceil(-4, 3), "");
+static_assert(2 == utils::intdiv_ceil(-4, -3), "");
+static_assert(2 == utils::intdiv_ceil(-5, -3), "");
+static_assert(0 == utils::intdiv_ceil(1, -3), "");
+static_assert(-1 == utils::intdiv_ceil(5, -3), "");
Review comment:
done in 585e874
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org