forked from ChicoState/UnitTestPractice
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPractice.cpp.gcov
More file actions
178 lines (178 loc) · 6.38 KB
/
Practice.cpp.gcov
File metadata and controls
178 lines (178 loc) · 6.38 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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
-: 0:Source:Practice.cpp
-: 0:Graph:Practice.gcno
-: 0:Data:Practice.gcda
-: 0:Runs:1
-: 0:Programs:1
-: 1:#include "Practice.h"
-: 2:#include <string>
-: 3:
-: 4:using std::string;
-: 5:
-: 6:// Receive three integers and rearrange their values so that they are in
-: 7:// descending order from greatest (first) to least (third)
function _ZN8Practice14sortDescendingERiS0_S0_ called 4 returned 100% blocks executed 95%
4: 8:void Practice::sortDescending(int & first, int & second, int & third)
-: 9:{
-: 10: int biggest, middle, smallest;
4: 11: if( second > third && second > first )
branch 0 taken 25% (fallthrough)
branch 1 taken 75%
branch 2 taken 0% (fallthrough)
branch 3 taken 100%
-: 12: {
#####: 13: biggest = second;
-: 14: }
4: 15: else if( third > second && third > first )
branch 0 taken 50% (fallthrough)
branch 1 taken 50%
branch 2 taken 100% (fallthrough)
branch 3 taken 0%
-: 16: {
2: 17: biggest = third;
-: 18: }
-: 19: else
-: 20: {
2: 21: biggest = first;
-: 22: }
4: 23: if( second < third && second < first )
branch 0 taken 50% (fallthrough)
branch 1 taken 50%
branch 2 taken 50% (fallthrough)
branch 3 taken 50%
-: 24: {
1: 25: smallest = second;
-: 26: }
3: 27: else if( third < second && third < first )
branch 0 taken 33% (fallthrough)
branch 1 taken 67%
branch 2 taken 100% (fallthrough)
branch 3 taken 0%
-: 28: {
1: 29: smallest = third;
-: 30: }
-: 31: else
-: 32: {
2: 33: smallest = first;
-: 34: }
4: 35: if( first != biggest && first != smallest ){
branch 0 taken 50% (fallthrough)
branch 1 taken 50%
branch 2 taken 50% (fallthrough)
branch 3 taken 50%
1: 36: middle = first;
-: 37: }
3: 38: else if( second != biggest && second != smallest ){
branch 0 taken 67% (fallthrough)
branch 1 taken 33%
branch 2 taken 100% (fallthrough)
branch 3 taken 0%
2: 39: middle = second;
-: 40: }
-: 41: else{
1: 42: middle = third;
-: 43: }
4: 44: first = biggest;
4: 45: second = middle;
4: 46: third = smallest;
4: 47:}
-: 48:
-: 49:// Receive a string and return whether or not it is strictly a palindrome,
-: 50:// where it is spelled the same backwards and forwards when considering every
-: 51:// character in the string, but disregarding case ('x' is the same as 'X')
function _ZN8Practice12isPalindromeENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE called 3 returned 100% blocks executed 100%
3: 52:bool Practice::isPalindrome(string input)
-: 53:{
17: 54: for(unsigned int i=0; i < input.size(); i++)
call 0 returned 100%
branch 1 taken 82% (fallthrough)
branch 2 taken 18%
-: 55: {
14: 56: if( input[i] < 'A' || input[i] > 'Z' )
call 0 returned 100%
branch 1 taken 100% (fallthrough)
branch 2 taken 0%
call 3 returned 100%
branch 4 taken 86% (fallthrough)
branch 5 taken 14%
branch 6 taken 86% (fallthrough)
branch 7 taken 14%
-: 57: {
-: 58: //change lower case to upper case
12: 59: input[i] = input[i] - ('a' - 'A');
call 0 returned 100%
call 1 returned 100%
-: 60: }
-: 61: }
-: 62:
3: 63: bool match = false;
-: 64:
10: 65: for(unsigned int i=0; i < input.size()/2; i++)
call 0 returned 100%
branch 1 taken 70% (fallthrough)
branch 2 taken 30%
-: 66: {
7: 67: if( input[i] == input[input.size()-1-i] )
call 0 returned 100%
call 1 returned 100%
call 2 returned 100%
branch 3 taken 71% (fallthrough)
branch 4 taken 29%
5: 68: match = true;
-: 69: else
2: 70: match = false;
-: 71: }
3: 72: return match;
-: 73:}
-: 74:
-: 75:// This function receives a string and counts how many times the same character
-: 76:// is repeated at the beginning of the string, before any other characters. The
-: 77:// function is case sensative so 'Z' is different than 'z'.
function _ZN8Practice22count_starting_repeatsENSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE called 7 returned 100% blocks executed 100%
7: 78:int Practice::count_starting_repeats(string word)
-: 79:{
7: 80: int repetition = 0;
7: 81: int index = 0;
-: 82: char letter;
-: 83:
7: 84: if( word.length() > 0 )
call 0 returned 100%
branch 1 taken 86% (fallthrough)
branch 2 taken 14%
6: 85: letter = word[0];
call 0 returned 100%
-: 86:
11: 87: for(unsigned int i=1; i < word.length(); i++){
call 0 returned 100%
branch 1 taken 82% (fallthrough)
branch 2 taken 18%
9: 88: if( word[i] == letter ){
call 0 returned 100%
branch 1 taken 44% (fallthrough)
branch 2 taken 56%
4: 89: repetition++;
-: 90: } else {
5: 91: break;
-: 92: }
-: 93: }
-: 94:
7: 95: return repetition;
-: 96:}
-: 97:
-: 98:// Receives an array that represents the hours someone sleeps each night of the week
-: 99:// (as an array of seven integers) and returns a pointer to locate the first instance
-: 100:// of an "all nighter" in the array (a day with 0 hours sleep) and returns the pointer.
-: 101:// However, if there are no such days found, the function should return nullptr.
function _ZN8Practice10allnighterEPi called 0 returned 0% blocks executed 0%
#####: 102:int* Practice::allnighter(int sleep[7])
-: 103:{
-: 104: /*
-: 105: int *p;
-: 106: for(int i=0; i < 7; i++) {
-: 107: if(sleep[i] == 0) {
-: 108: *p = &i;
-: 109: return *p;
-: 110: }
-: 111: }
-: 112: return nullptr;
-: 113: */
#####: 114:}