winget-cli

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

commit e0c43c4047096977d49a3338e49d6682c34067cd
parent f97417f2ea850757d0a3337be877ac35f371a9ea
Author: Kaleb Luedtke <trenlymc@gmail.com>
Date:   Mon,  2 Dec 2024 15:44:55 -0600

Add tests for ensuring integers are parsed correctly with leading zeroes (#5013)

<!-- To check a checkbox place an "x" between the brackets. e.g: [x] -->

- [x] I have signed the [Contributor License
Agreement](https://cla.opensource.microsoft.com/microsoft/winget-pkgs).
- [ ] This pull request is related to an issue.

I wasn't sure offhand if these versions would parse to be equal. I went
to look at the test cases and found there were no tests that ensured
that leading zeroes were parsed correctly. This PR adds the tests for
clarity

-----

###### Microsoft Reviewers: [Open in
CodeFlow](https://microsoft.github.io/open-pr/?codeflow=https://github.com/microsoft/winget-cli/pull/5013)
Diffstat:
Msrc/AppInstallerCLITests/Versions.cpp | 7+++++++
1 file changed, 7 insertions(+), 0 deletions(-)

diff --git a/src/AppInstallerCLITests/Versions.cpp b/src/AppInstallerCLITests/Versions.cpp @@ -170,9 +170,16 @@ TEST_CASE("VersionCompare", "[versions]") RequireEqual("1.0", "1.0.0"); + // Ensure that integers are parsed correctly when there is a leading zero + RequireEqual("1.2.00.3", "1.2.0.3"); + RequireEqual("1.2.003.4", "1.2.3.4"); + RequireEqual("01.02.03.04", "1.2.3.4"); + RequireEqual("1.2.03-beta", "1.2.3-beta"); + // Ensure whitespace doesn't affect equality RequireEqual("1.0", "1.0 "); RequireEqual("1.0", "1. 0"); + RequireEqual("1.0", "1.0."); // Ensure versions with preambles are sorted correctly RequireEqual("1.0", "Version 1.0");