forked from eclipse-iceoryx/iceoryx2
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[eclipse-iceoryx#475] Make PackageVersion independent of env vars
- Loading branch information
Showing
3 changed files
with
46 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Copyright (c) 2024 Contributors to the Eclipse Foundation | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information regarding copyright ownership. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Apache Software License 2.0 which is available at | ||
// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
// which is available at https://opensource.org/licenses/MIT. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
use iceoryx2_bb_elementary::package_version::PackageVersion; | ||
use iceoryx2_bb_testing::assert_that; | ||
|
||
#[test] | ||
fn package_version_works() { | ||
let major = option_env!("CARGO_PKG_VERSION_MAJOR") | ||
.and_then(|s| s.parse::<u16>().ok()) | ||
.expect("Contains a valid major version number."); | ||
let minor = option_env!("CARGO_PKG_VERSION_MINOR") | ||
.and_then(|s| s.parse::<u16>().ok()) | ||
.expect("Contains a valid minor version number."); | ||
let patch = option_env!("CARGO_PKG_VERSION_PATCH") | ||
.and_then(|s| s.parse::<u16>().ok()) | ||
.expect("Contains a valid patch version number."); | ||
|
||
let sut = PackageVersion::get(); | ||
|
||
assert_that!(sut.major(), eq major); | ||
assert_that!(sut.minor(), eq minor); | ||
assert_that!(sut.patch(), eq patch); | ||
|
||
assert_that!(major == 0 && minor == 0 && patch == 0, eq false); | ||
} |