Skip to content

Commit

Permalink
Add tests for ensuring integers are parsed correctly with leading zer…
Browse files Browse the repository at this point in the history
…oes (#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)
  • Loading branch information
Trenly authored Dec 2, 2024
1 parent f97417f commit e0c43c4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/AppInstallerCLITests/Versions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit e0c43c4

Please sign in to comment.