diff options
author | Brad King <brad.king@kitware.com> | 2019-04-11 16:56:32 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2019-04-11 16:56:32 (GMT) |
commit | f0948499f6b47a7a856aef3334a8d8a38c1265d5 (patch) | |
tree | 4f2ac14d379cf7b4f57c92416593f2ef6e2c54cb /Tests/CMakeLib | |
parent | a550e2d6e48798d342a5ba7436013c6aa6ce5151 (diff) | |
download | CMake-f0948499f6b47a7a856aef3334a8d8a38c1265d5.zip CMake-f0948499f6b47a7a856aef3334a8d8a38c1265d5.tar.gz CMake-f0948499f6b47a7a856aef3334a8d8a38c1265d5.tar.bz2 |
cmSystemTools: Fix StringToULong to reject negative numbers
Fixes: #19161
Diffstat (limited to 'Tests/CMakeLib')
-rw-r--r-- | Tests/CMakeLib/testSystemTools.cxx | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Tests/CMakeLib/testSystemTools.cxx b/Tests/CMakeLib/testSystemTools.cxx index 96a4819..121e639 100644 --- a/Tests/CMakeLib/testSystemTools.cxx +++ b/Tests/CMakeLib/testSystemTools.cxx @@ -93,5 +93,22 @@ int testSystemTools(int /*unused*/, char* /*unused*/ []) if (!failed) { cmPassed("cmSystemTools::strverscmp working"); } + + // ---------------------------------------------------------------------- + // Test cmSystemTools::StringToULong + { + unsigned long value; + cmAssert(cmSystemTools::StringToULong("1", &value) && value == 1, + "StringToULong parses a decimal integer."); + cmAssert(cmSystemTools::StringToULong(" 1", &value) && value == 1, + "StringToULong parses a decimal integer after whitespace."); + cmAssert(!cmSystemTools::StringToULong("-1", &value), + "StringToULong rejects a negative number."); + cmAssert(!cmSystemTools::StringToULong(" -1", &value), + "StringToULong rejects a negative number after whitespace."); + cmAssert(!cmSystemTools::StringToULong("1x", &value), + "StringToULong rejects trailing content."); + } + return failed; } |