• Devlin Cronin's avatar
    [base] Add explicit tests for leading zeros in base::Version · 85511ccf
    Devlin Cronin authored
    base::Version is interesting. It is treated as (up to) four dot-
    separated integers. However, because these are parsed individually,
    leading zeros in each component are ignored. This leads to some
    interesting (potentially unexpected) behavior:
    - v1.01 is equivalent to v1.1
    - v1.01's string representation is "1.1"
    - v1.02 is greater than v1.1
    
    Additionally, leading zeros are not allowed in the first component,
    though they are allowed in subsequent components. That is, v01.1 is
    invalid.
    
    Add unittests to cover these cases, and make them more explicit.
    
    Bug: None
    Change-Id: Ia8cc6ec988fdef7f6c2b41c93e7468781a458591
    Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2233495Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
    Commit-Queue: Devlin <rdevlin.cronin@chromium.org>
    Cr-Commit-Position: refs/heads/master@{#775808}
    85511ccf
version_unittest.cc 5.75 KB