Skip to content

Commit

Permalink
rust/series: 3rd iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
vpayno committed Sep 20, 2023
1 parent f790ce6 commit ba7334c
Show file tree
Hide file tree
Showing 5 changed files with 163 additions and 251 deletions.
114 changes: 32 additions & 82 deletions rust/series/coverage-annotations.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,100 +27,50 @@
27| 15| match (sequence, span) {
28| 15| (_, span) if span == 0 => {
^3
29| | // this corner case, with_zero_length, doesn't make sense
29| | // this corner case, with_zero_length, doesn't make sense, why isn't the data just an empty vector?
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 => {
32| 12| (sequence, span) if sequence.len() < span => {
^6
42| 6| vec![]
43| | }
44| 3| _ => series_main(sequence, span),
45| | }
46| 15|}
33| | // corner case ignored by tests
34| 6| vec![]
35| | }
36| 6| _ => sequence
37| 6| .chars()
38| 6| .collect::<Vec<char>>()
39| 6| .windows(span)
40| 15| .map(|x| x.iter().collect::<String>())
------------------
| series::series::{closure#0}:
| 40| 15| .map(|x| x.iter().collect::<String>())
------------------
| Unexecuted instantiation: series::series::{closure#0}
------------------
41| 6| .collect(),
42| | }
43| 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
| 29| | // this corner case, with_zero_length, doesn't make sense, why isn't the data just an empty vector?
| 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 => {
| 32| 12| (sequence, span) if sequence.len() < span => {
| ^6
| 42| 6| vec![]
| 43| | }
| 44| 3| _ => series_main(sequence, span),
| 45| | }
| 46| 15|}
| 33| | // corner case ignored by tests
| 34| 6| vec![]
| 35| | }
| 36| 6| _ => sequence
| 37| 6| .chars()
| 38| 6| .collect::<Vec<char>>()
| 39| 6| .windows(span)
| 40| 6| .map(|x| x.iter().collect::<String>())
| 41| 6| .collect(),
| 42| | }
| 43| 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
54| 15| if remaining < span || index + span > sequence.len() {
^12
55| 3| break;
56| 12| }
57| 12| remaining -= 1;
58| 12|
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_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
| 54| 15| if remaining < span || index + span > sequence.len() {
| ^12
| 55| 3| break;
| 56| 12| }
| 57| 12| remaining -= 1;
| 58| 12|
| 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_main
------------------
6 changes: 2 additions & 4 deletions rust/series/coverage-missing-lines.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@ 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 23 2 91.30% 2 0 100.00% 27 1 96.30% 0 0 -
/home/vpayno/git_vpayno/exercism-workspace/rust/series/src/lib.rs 11 0 100.00% 2 0 100.00% 14 0 100.00% 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
TOTAL 11 0 100.00% 2 0 100.00% 14 0 100.00% 0 0 -

42 changes: 14 additions & 28 deletions rust/series/report.lcov
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
SF:/home/vpayno/git_vpayno/exercism-workspace/rust/series/src/lib.rs
FN:48,_RNvCs3hVIKtMrduI_6series11series_main
FN:40,_RNCNvCs3hVIKtMrduI_6series6series0B3_
FN:26,_RNvCs3hVIKtMrduI_6series6series
FN:48,_RNvCsfpoSPjMhDZV_6series11series_main
FN:40,_RNCNvCsfpoSPjMhDZV_6series6series0B3_
FN:26,_RNvCsfpoSPjMhDZV_6series6series
FNDA:1,_RNvCs3hVIKtMrduI_6series11series_main
FNDA:5,_RNCNvCs3hVIKtMrduI_6series6series0B3_
FNDA:5,_RNvCs3hVIKtMrduI_6series6series
FNDA:0,_RNvCsfpoSPjMhDZV_6series11series_main
FNDA:0,_RNCNvCsfpoSPjMhDZV_6series6series0B3_
FNDA:0,_RNvCsfpoSPjMhDZV_6series6series
FNF:2
FNH:2
Expand All @@ -14,30 +14,16 @@ DA:27,5
DA:28,5
DA:30,1
DA:32,4
DA:34,0
DA:36,4
DA:38,1
DA:41,3
DA:42,2
DA:44,1
DA:46,5
DA:48,1
DA:49,1
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:60,4
DA:61,4
DA:64,1
DA:65,1
DA:34,2
DA:36,2
DA:37,2
DA:38,2
DA:39,2
DA:40,5
DA:41,2
DA:43,5
BRF:0
BRH:0
LF:27
LH:26
LF:14
LH:14
end_of_record
Loading

0 comments on commit ba7334c

Please sign in to comment.