Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add functions for tox crate version information #477

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions tox/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,39 @@ pub use tox_core as core;
pub use tox_crypto as crypto;
pub use tox_encryptsave as encryptsave;
pub use tox_packet as packet;

pub fn crate_version() -> String {
antis81 marked this conversation as resolved.
Show resolved Hide resolved
env!("CARGO_PKG_VERSION").to_string()
}
pub fn crate_version_major() -> u32 {
env!("CARGO_PKG_VERSION_MAJOR").parse().expect("Invalid major version")
}
pub fn crate_version_minor() -> u32 {
env!("CARGO_PKG_VERSION_MINOR").parse().expect("Invalid minor version")
}
pub fn crate_version_patch() -> u32 {
env!("CARGO_PKG_VERSION_PATCH").parse().expect("Invalid patch version")
}

#[cfg(test)]
mod tests {
#[test]
fn crate_version_is_not_empty() {
assert_ne!(crate::crate_version(), "");
}

#[test]
fn crate_version_major() {
crate::crate_version_major();
antis81 marked this conversation as resolved.
Show resolved Hide resolved
}

#[test]
fn crate_version_minor() {
crate::crate_version_minor();
}

#[test]
fn crate_version_patch() {
crate::crate_version_patch();
}
}
Loading