Skip to content

Commit

Permalink
rust/series: 2nd iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
vpayno committed Sep 20, 2023
1 parent c88ddba commit f790ce6
Show file tree
Hide file tree
Showing 5 changed files with 248 additions and 231 deletions.
166 changes: 91 additions & 75 deletions rust/series/coverage-annotations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,87 +24,103 @@
24| |/// assert_eq!(got, want);
25| |/// ```
26| 15|pub fn series(sequence: &str, span: usize) -> Vec<String> {
27| 15| if span == 0 {
28| | // this corner case, with_zero_length, doesn't make sense
29| 3| return vec!["".to_string(); sequence.len() + 1];
30| 12| }
31| 12|
32| 12| if sequence.is_empty() {
33| | // why are we returning a vector with empty strings?
34| 0| return vec!["".to_string(); sequence.len()];
35| 12| }
36| 12|
37| 12| if sequence.len() == span {
38| | // this corner case makes sense
39| 3| return vec![sequence.to_string()];
40| 9| }
41| 9|
42| 9| // corner case ignored by tests
43| 9| if sequence.len() < span {
44| 6| return vec![];
45| 3| }
46| 3|
47| 3| // only one test to test the logic of the program?
48| 3| let mut groups: Vec<String> = vec![];
49| 3| let mut remaining: usize = sequence.len();
50| |
51| 15| for (index, _) in sequence.chars().enumerate() {
27| 15| match (sequence, span) {
28| 15| (_, span) if span == 0 => {
^3
29| | // this corner case, with_zero_length, doesn't make sense
30| 3| vec!["".to_string(); sequence.len() + 1]
31| | }
32| 12| (sequence, _) if sequence.is_empty() => {
^0
33| | // why are we returning a vector with empty strings?
34| 0| vec!["".to_string(); sequence.len()]
35| | }
36| 12| (sequence, span) if sequence.len() == span => {
^3
37| | // this corner case makes sense
38| 3| vec![sequence.to_string()]
39| | }
40| | // corner case ignored by tests
41| 9| (sequence, span) if sequence.len() < span => {
^6
42| 6| vec![]
43| | }
44| 3| _ => series_main(sequence, span),
45| | }
46| 15|}
------------------
| series::series:
| 26| 15|pub fn series(sequence: &str, span: usize) -> Vec<String> {
| 27| 15| match (sequence, span) {
| 28| 15| (_, span) if span == 0 => {
| ^3
| 29| | // this corner case, with_zero_length, doesn't make sense
| 30| 3| vec!["".to_string(); sequence.len() + 1]
| 31| | }
| 32| 12| (sequence, _) if sequence.is_empty() => {
| ^0
| 33| | // why are we returning a vector with empty strings?
| 34| 0| vec!["".to_string(); sequence.len()]
| 35| | }
| 36| 12| (sequence, span) if sequence.len() == span => {
| ^3
| 37| | // this corner case makes sense
| 38| 3| vec![sequence.to_string()]
| 39| | }
| 40| | // corner case ignored by tests
| 41| 9| (sequence, span) if sequence.len() < span => {
| ^6
| 42| 6| vec![]
| 43| | }
| 44| 3| _ => series_main(sequence, span),
| 45| | }
| 46| 15|}
------------------
| Unexecuted instantiation: series::series
------------------
47| |
48| 3|fn series_main(sequence: &str, span: usize) -> Vec<String> {
49| 3| // only one test to test the logic of the program?
50| 3| let mut groups: Vec<String> = vec![];
51| 3| let mut remaining: usize = sequence.len();
52| |
53| 15| for (index, _) in sequence.chars().enumerate() {
^3
52| 15| if remaining < span || index + span > sequence.len() {
54| 15| if remaining < span || index + span > sequence.len() {
^12
53| 3| break;
54| 12| }
55| 12| remaining -= 1;
56| 12|
57| 12| let group: String = sequence[index..span + index].to_string();
55| 3| break;
56| 12| }
57| 12| remaining -= 1;
58| 12|
59| 12| groups.push(group);
60| | }
61| |
62| 3| groups
63| 15|}
59| 12| let group: String = sequence[index..span + index].to_string();
60| 12|
61| 12| groups.push(group);
62| | }
63| |
64| 3| groups
65| 3|}
------------------
| series::series:
| 26| 15|pub fn series(sequence: &str, span: usize) -> Vec<String> {
| 27| 15| if span == 0 {
| 28| | // this corner case, with_zero_length, doesn't make sense
| 29| 3| return vec!["".to_string(); sequence.len() + 1];
| 30| 12| }
| 31| 12|
| 32| 12| if sequence.is_empty() {
| 33| | // why are we returning a vector with empty strings?
| 34| 0| return vec!["".to_string(); sequence.len()];
| 35| 12| }
| 36| 12|
| 37| 12| if sequence.len() == span {
| 38| | // this corner case makes sense
| 39| 3| return vec![sequence.to_string()];
| 40| 9| }
| 41| 9|
| 42| 9| // corner case ignored by tests
| 43| 9| if sequence.len() < span {
| 44| 6| return vec![];
| 45| 3| }
| 46| 3|
| 47| 3| // only one test to test the logic of the program?
| 48| 3| let mut groups: Vec<String> = vec![];
| 49| 3| let mut remaining: usize = sequence.len();
| 50| |
| 51| 15| for (index, _) in sequence.chars().enumerate() {
| series::series_main:
| 48| 3|fn series_main(sequence: &str, span: usize) -> Vec<String> {
| 49| 3| // only one test to test the logic of the program?
| 50| 3| let mut groups: Vec<String> = vec![];
| 51| 3| let mut remaining: usize = sequence.len();
| 52| |
| 53| 15| for (index, _) in sequence.chars().enumerate() {
| ^3
| 52| 15| if remaining < span || index + span > sequence.len() {
| 54| 15| if remaining < span || index + span > sequence.len() {
| ^12
| 53| 3| break;
| 54| 12| }
| 55| 12| remaining -= 1;
| 56| 12|
| 57| 12| let group: String = sequence[index..span + index].to_string();
| 55| 3| break;
| 56| 12| }
| 57| 12| remaining -= 1;
| 58| 12|
| 59| 12| groups.push(group);
| 60| | }
| 61| |
| 62| 3| groups
| 63| 15|}
| 59| 12| let group: String = sequence[index..span + index].to_string();
| 60| 12|
| 61| 12| groups.push(group);
| 62| | }
| 63| |
| 64| 3| groups
| 65| 3|}
------------------
| Unexecuted instantiation: series::series
| Unexecuted instantiation: series::series_main
------------------
4 changes: 2 additions & 2 deletions rust/series/coverage-missing-lines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ Running: cargo llvm-cov --no-clean --all-features --workspace --show-missing-lin

Filename Regions Missed Regions Cover Functions Missed Functions Executed Lines Missed Lines Cover Branches Missed Branches Cover
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
/home/vpayno/git_vpayno/exercism-workspace/rust/series/src/lib.rs 17 1 94.12% 1 0 100.00% 32 1 96.88% 0 0 -
/home/vpayno/git_vpayno/exercism-workspace/rust/series/src/lib.rs 23 2 91.30% 2 0 100.00% 27 1 96.30% 0 0 -
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
TOTAL 17 1 94.12% 1 0 100.00% 32 1 96.88% 0 0 -
TOTAL 23 2 91.30% 2 0 100.00% 27 1 96.30% 0 0 -
Uncovered Lines:
/home/vpayno/git_vpayno/exercism-workspace/rust/series/src/lib.rs: 34

47 changes: 23 additions & 24 deletions rust/series/report.lcov
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
SF:/home/vpayno/git_vpayno/exercism-workspace/rust/series/src/lib.rs
FN:48,_RNvCs3hVIKtMrduI_6series11series_main
FN:26,_RNvCs3hVIKtMrduI_6series6series
FN:48,_RNvCsfpoSPjMhDZV_6series11series_main
FN:26,_RNvCsfpoSPjMhDZV_6series6series
FNDA:1,_RNvCs3hVIKtMrduI_6series11series_main
FNDA:5,_RNvCs3hVIKtMrduI_6series6series
FNDA:0,_RNvCsfpoSPjMhDZV_6series11series_main
FNDA:0,_RNvCsfpoSPjMhDZV_6series6series
FNF:1
FNH:1
FNF:2
FNH:2
DA:26,5
DA:27,5
DA:29,1
DA:30,4
DA:31,4
DA:28,5
DA:30,1
DA:32,4
DA:34,0
DA:35,4
DA:36,4
DA:37,4
DA:39,1
DA:40,3
DA:38,1
DA:41,3
DA:42,3
DA:43,3
DA:44,2
DA:45,1
DA:46,1
DA:47,1
DA:42,2
DA:44,1
DA:46,5
DA:48,1
DA:49,1
DA:51,5
DA:52,5
DA:53,1
DA:54,4
DA:55,4
DA:50,1
DA:51,1
DA:53,5
DA:54,5
DA:55,1
DA:56,4
DA:57,4
DA:58,4
DA:59,4
DA:62,1
DA:63,5
DA:60,4
DA:61,4
DA:64,1
DA:65,1
BRF:0
BRH:0
LF:32
LH:31
LF:27
LH:26
end_of_record
Loading

0 comments on commit f790ce6

Please sign in to comment.