diff options
author | David Gobbi <david.gobbi@gmail.com> | 2023-02-20 15:59:11 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2023-02-20 17:54:43 (GMT) |
commit | aa86e8ddfd6b9dc12e54aeb7e5b5c1503c272c42 (patch) | |
tree | 0a1b71b1a30b144a97d6f54647f6507b67a1f152 /Tests/CMakeLib/testSystemTools.cxx | |
parent | 7e730d8f7f7af927a52cd1b7668c64b4c82daa4a (diff) | |
download | CMake-aa86e8ddfd6b9dc12e54aeb7e5b5c1503c272c42.zip CMake-aa86e8ddfd6b9dc12e54aeb7e5b5c1503c272c42.tar.gz CMake-aa86e8ddfd6b9dc12e54aeb7e5b5c1503c272c42.tar.bz2 |
Remove component size limit for version comparisons
The VersionCompare() function converted version components to
'unsigned long' prior to comparing them. Any version components
too large for 'unsigned long' were treated as equal to ULONG_MAX.
This impacted operators like VERSION_GREATER, VERSION_LESS, and
VERSION_EQUAL. The new code does not limit the length of the
version components for valid comparisons.
Diffstat (limited to 'Tests/CMakeLib/testSystemTools.cxx')
-rw-r--r-- | Tests/CMakeLib/testSystemTools.cxx | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/Tests/CMakeLib/testSystemTools.cxx b/Tests/CMakeLib/testSystemTools.cxx index 1d5db1c..0f0c025 100644 --- a/Tests/CMakeLib/testSystemTools.cxx +++ b/Tests/CMakeLib/testSystemTools.cxx @@ -61,8 +61,26 @@ int testSystemTools(int /*unused*/, char* /*unused*/[]) "VersionCompareEqual different length"); cmAssert(cmSystemTools::VersionCompareGreater("6.2.1", "6.2"), "VersionCompareGreater different length"); - cmAssert(cmSystemTools::VersionCompareGreater("3.141592653", "3.14159265"), - "VersionCompareGreater more digits"); + cmAssert( + !cmSystemTools::VersionCompareEqual( + "3.14159265358979323846264338327950288419716939937510582097494459230", + "3.14159265358979323846264338327950288419716939937510582097494459231"), + "VersionCompareEqual long number"); + cmAssert( + !cmSystemTools::VersionCompareGreater( + "3.14159265358979323846264338327950288419716939937510582097494459230", + "3.14159265358979323846264338327950288419716939937510582097494459231"), + "VersionCompareGreater long number"); + cmAssert( + !cmSystemTools::VersionCompareEqual( + "3.141592653589793238462643383279502884197169399375105820974944592307", + "3.14159265358979323846264338327950288419716939937510582097494459231"), + "VersionCompareEqual more digits"); + cmAssert( + cmSystemTools::VersionCompareGreater( + "3.141592653589793238462643383279502884197169399375105820974944592307", + "3.14159265358979323846264338327950288419716939937510582097494459231"), + "VersionCompareGreater more digits"); // ---------------------------------------------------------------------- // Test cmSystemTools::strverscmp |