🎉 initial commit
This commit is contained in:
22
test_data/complex_example.rs
Normal file
22
test_data/complex_example.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
fn process_data(data:Vec<i32>)->HashMap<i32,i32>{
|
||||
let mut result=HashMap::new();
|
||||
for(index,value)in data.iter().enumerate(){
|
||||
result.insert(index as i32,*value*2);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests{
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_process_data(){
|
||||
let input=vec![1,2,3,4,5];
|
||||
let result=process_data(input);
|
||||
assert_eq!(result.get(&0),Some(&2));
|
||||
assert_eq!(result.get(&1),Some(&4));
|
||||
}
|
||||
}
|
||||
19
test_data/complex_example.rs.snap
Normal file
19
test_data/complex_example.rs.snap
Normal file
@@ -0,0 +1,19 @@
|
||||
use std::collections::HashMap;
|
||||
fn process_data(data: Vec<i32>) -> HashMap<i32, i32> {
|
||||
let mut result = HashMap::new();
|
||||
for (index, value) in data.iter().enumerate() {
|
||||
result.insert(index as i32, *value * 2);
|
||||
}
|
||||
result
|
||||
}
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[test]
|
||||
fn test_process_data() {
|
||||
let input = vec![1, 2, 3, 4, 5];
|
||||
let result = process_data(input);
|
||||
assert_eq!(result.get(& 0), Some(& 2));
|
||||
assert_eq!(result.get(& 1), Some(& 4));
|
||||
}
|
||||
}
|
||||
5
test_data/simple_function.rs
Normal file
5
test_data/simple_function.rs
Normal file
@@ -0,0 +1,5 @@
|
||||
fn main(){println!("Hello, world!");}
|
||||
|
||||
fn add(a:i32,b:i32)->i32{
|
||||
a+b
|
||||
}
|
||||
6
test_data/simple_function.rs.snap
Normal file
6
test_data/simple_function.rs.snap
Normal file
@@ -0,0 +1,6 @@
|
||||
fn main() {
|
||||
println!("Hello, world!");
|
||||
}
|
||||
fn add(a: i32, b: i32) -> i32 {
|
||||
a + b
|
||||
}
|
||||
11
test_data/struct_with_impl.rs
Normal file
11
test_data/struct_with_impl.rs
Normal file
@@ -0,0 +1,11 @@
|
||||
struct Person{name:String,age:u32}
|
||||
|
||||
impl Person{
|
||||
fn new(name:String,age:u32)->Self{
|
||||
Self{name,age}
|
||||
}
|
||||
|
||||
fn greet(&self){
|
||||
println!("Hello, my name is {} and I'm {} years old.",self.name,self.age);
|
||||
}
|
||||
}
|
||||
12
test_data/struct_with_impl.rs.snap
Normal file
12
test_data/struct_with_impl.rs.snap
Normal file
@@ -0,0 +1,12 @@
|
||||
struct Person {
|
||||
name: String,
|
||||
age: u32,
|
||||
}
|
||||
impl Person {
|
||||
fn new(name: String, age: u32) -> Self {
|
||||
Self { name, age }
|
||||
}
|
||||
fn greet(&self) {
|
||||
println!("Hello, my name is {} and I'm {} years old.", self.name, self.age);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user