Skip to content

Commit 2cb0a11

Browse files
ankddevlpil
authored andcommitted
test: add test cases for Version display function
1 parent 74275ad commit 2cb0a11

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

compiler-cli/src/add.rs

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,3 +133,36 @@ fn version_to_string(version: &Version) -> String {
133133
}
134134
text
135135
}
136+
137+
#[test]
138+
fn displays_simple_version_correctly() {
139+
let version = Version {
140+
major: 1,
141+
minor: 23,
142+
patch: 4,
143+
pre: vec![],
144+
build: None,
145+
};
146+
147+
let displayed = version_to_string(&version);
148+
149+
assert_eq!(displayed, "1.23.4");
150+
}
151+
152+
#[test]
153+
fn displays_full_version_correctly() {
154+
let version = Version {
155+
major: 1,
156+
minor: 23,
157+
patch: 4,
158+
pre: vec![
159+
Identifier::Numeric(123),
160+
Identifier::AlphaNumeric("123abc".to_string()),
161+
],
162+
build: Some("12345abc".to_string()),
163+
};
164+
165+
let displayed = version_to_string(&version);
166+
167+
assert_eq!(displayed, "1.23.4-123.123abc+12345abc");
168+
}

0 commit comments

Comments
 (0)