-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathlib.rs
More file actions
98 lines (80 loc) · 2.22 KB
/
lib.rs
File metadata and controls
98 lines (80 loc) · 2.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
use std::path::PathBuf;
pub mod criterion;
// Re-export real world projects from karva_test
pub use karva_test::{
InstalledProject, RealWorldProject, affect_project, get_real_world_projects,
real_world_projects,
};
pub static TRUE_ASSERTIONS: TestFile = TestFile::new(
"test_true_assertions.py",
include_str!("../resources/test_true_assertions.py"),
);
pub static MATH: TestFile =
TestFile::new("test_math.py", include_str!("../resources/test_math.py"));
pub static STRING_CONCATENATION: TestFile = TestFile::new(
"test_string_concatenation.py",
include_str!("../resources/test_string_concatenation.py"),
);
pub static LARGE_SUMMATION: TestFile = TestFile::new(
"test_large_summation.py",
include_str!("../resources/test_large_summation.py"),
);
pub static LARGE_LIST_COMPREHENSION: TestFile = TestFile::new(
"test_large_list_comprehension.py",
include_str!("../resources/test_large_list_comprehension.py"),
);
pub static FIXTURES: TestFile = TestFile::new(
"test_fixtures.py",
include_str!("../resources/test_fixtures.py"),
);
pub static PARAMETRIZE: TestFile = TestFile::new(
"test_parametrize.py",
include_str!("../resources/test_parametrize.py"),
);
#[derive(Debug, Clone)]
pub struct TestCase {
file: TestFile,
}
impl TestCase {
#[must_use]
pub const fn new(file: TestFile) -> Self {
Self { file }
}
#[must_use]
pub const fn code(&self) -> &str {
self.file.code
}
#[must_use]
pub const fn name(&self) -> &str {
self.file.name
}
#[must_use]
pub fn path(&self) -> PathBuf {
PathBuf::from(file!())
.parent()
.expect("Failed to get parent of file")
.parent()
.expect("Failed to get parent of file")
.join("resources")
.join(self.name())
}
}
#[derive(Debug, Clone)]
pub struct TestFile {
name: &'static str,
code: &'static str,
}
impl TestFile {
#[must_use]
pub const fn new(name: &'static str, code: &'static str) -> Self {
Self { name, code }
}
#[must_use]
pub const fn code(&self) -> &str {
self.code
}
#[must_use]
pub const fn name(&self) -> &str {
self.name
}
}