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
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_gcd_of_strings() {
let result = gcd_of_strings(String::from("ABCABC"), String::from("ABC"));
assert_eq!(result.is_some(), true);
assert_eq!(result.unwrap(), "ABC");
let result1 = gcd_of_strings(String::from("HAHA"), String::from("ABC"));
assert_eq!(result1.is_none(), true);
}
#[test]
fn test_gcd() {
let result = gcd(8, 4);
assert_eq!(result, 4);
let result1 = gcd(8, 6);
assert_eq!(result1, 2);
}
}
pub fn gcd_of_strings(str1: String, str2: String) -> Option<String> {
let str1_len = str1.len();
let str2_len = str2.len();
return Some(String::from("ABC"));
}
pub fn gcd(int1: i32, int2: i32) -> i32 {
if int1 % int2 == 0 {
return int2;
} else {
return gcd(int2, int1 % int2);
}
}