diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2022-04-13 17:48:13 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2022-04-14 09:58:00 +0200 |
commit | fc2413e9a8f509bc6835cae473bf5053728c419a (patch) | |
tree | 80aefd0b4aba4ca9e18a4732a6c48c64c8b05928 /binaryurp | |
parent | 5bfbb64cb9ae102e5a1f5b4cd020d0cd006d0a92 (diff) |
Pick better variable types
...tweaking the code slightly to guarantee that j will always be non-negative
Change-Id: Ie8ba450884cc8b12e0caa79b4d75f95dd96cc120
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132993
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
Diffstat (limited to 'binaryurp')
-rw-r--r-- | binaryurp/qa/test-cache.cxx | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/binaryurp/qa/test-cache.cxx b/binaryurp/qa/test-cache.cxx index c024f1f711d6..c4696f78395f 100644 --- a/binaryurp/qa/test-cache.cxx +++ b/binaryurp/qa/test-cache.cxx @@ -17,6 +17,10 @@ * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ +#include <sal/config.h> + +#include <cstddef> + #include <sal/types.h> #include <cppunit/TestAssert.h> #include <cppunit/TestFixture.h> @@ -39,13 +43,13 @@ private: // cf. jurt/test/com/sun/star/lib/uno/protocols/urp/Cache_Test.java: void Test::testNothingLostFromLruList() { int a[8]; - for (int i = 0; i != int(std::size(a)); ++i) { - for (int j = 0; j != i; ++j) { + for (std::size_t i = 0; i != std::size(a); ++i) { + for (std::size_t j = 0; j != i; ++j) { a[j] = 0; } for (;;) { binaryurp::Cache< int > c(4); - for (int k = 0; k != i; ++k) { + for (std::size_t k = 0; k != i; ++k) { bool f; c.add(a[k], &f); } @@ -53,15 +57,15 @@ void Test::testNothingLostFromLruList() { CPPUNIT_ASSERT_EQUAL( 6, c.add(-1, &f) + c.add(-2, &f) + c.add(-3, &f) + c.add(-4, &f)); - int j = i - 1; - while (j >= 0 && a[j] == 3) { + std::size_t j = i; + while (j != 0 && a[j - 1] == 3) { --j; } - if (j < 0) { + if (j == 0) { break; } - ++a[j]; - for (int k = j + 1; k != i; ++k) { + ++a[j - 1]; + for (std::size_t k = j; k != i; ++k) { a[k] = 0; } } |