Skip to content

Commit 4930ae4

Browse files
committed
initial commit
0 parents  commit 4930ae4

File tree

9 files changed

+94
-0
lines changed

9 files changed

+94
-0
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
2+
target/
3+

Cargo.lock

+11
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[workspace]
2+
resolver = "2"
3+
4+
members = ["plib"
5+
, "truefalse"]
6+

plib/Cargo.toml

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
[package]
2+
name = "plib"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]

plib/src/lib.rs

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub fn add(left: usize, right: usize) -> usize {
2+
left + right
3+
}
4+
5+
#[cfg(test)]
6+
mod tests {
7+
use super::*;
8+
9+
#[test]
10+
fn it_works() {
11+
let result = add(2, 2);
12+
assert_eq!(result, 4);
13+
}
14+
}

truefalse/Cargo.toml

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
[package]
2+
name = "truefalse"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
[[bin]]
7+
name = "true"
8+
path = "src/true.rs"
9+
10+
[[bin]]
11+
name = "false"
12+
path = "src/false.rs"
13+

truefalse/src/false.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
std::process::exit(1);
3+
}

truefalse/src/true.rs

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
fn main() {
2+
std::process::exit(0);
3+
}

truefalse/tests/integration.rs

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
use std::process::Command;
2+
3+
#[test]
4+
fn test_false_exit_code() {
5+
let workspace_target = std::env::current_dir()
6+
.unwrap()
7+
.parent()
8+
.unwrap() // Move up to the workspace root from the current package directory
9+
.join("target/debug/false"); // Adjust the path to the binary
10+
11+
let output = Command::new(workspace_target)
12+
.output()
13+
.expect("Failed to execute command");
14+
15+
assert!(!output.status.success());
16+
assert_eq!(output.status.code(), Some(1));
17+
}
18+
19+
#[test]
20+
fn test_true_exit_code() {
21+
let workspace_target = std::env::current_dir()
22+
.unwrap()
23+
.parent()
24+
.unwrap() // Move up to the workspace root from the current package directory
25+
.join("target/debug/true"); // Adjust the path to the binary
26+
27+
let output = Command::new(workspace_target)
28+
.output()
29+
.expect("Failed to execute command");
30+
31+
assert!(output.status.success());
32+
assert_eq!(output.status.code(), Some(0));
33+
}

0 commit comments

Comments
 (0)