FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
16fa-github-workshop/TimeDriver.cpp at master · dvcoders/16fa-github-workshop · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
dvcoders
/
16fa-github-workshop
Public
Notifications
You must be signed in to change notification settings
Fork
13
Star
2
Code
Issues
9
Pull requests
3
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Issues
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
16fa-github-workshop
/
TimeDriver.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
56 lines (42 loc) · 2 KB
Breadcrumbs
16fa-github-workshop
/
TimeDriver.cpp
Copy path
File metadata and controls
56 lines (42 loc) · 2 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
//
Uses and tests Time class
#
include
<
iostream
>
using
namespace
std
;
#
include
"
Time.h
"
#
include
"
Time.h
"
//
test ifndef
string
should
(string test,
bool
passed) {
//
Check or cross if pass or fail respectivly
string prefix = (passed ?
"
\u2714
"
:
"
\u2718
"
);
return
prefix +
"
Should
"
+ test;
}
int
main
() {
Time time;
//
Test setters and getters
cout <<
"
Hours:
"
<< endl;
cout <<
should
(
"
default to 0
"
, time.
getHours
() ==
0
) << endl;
cout <<
should
(
"
return true for positive input (4)
"
, time.
setHours
(
4
) ==
true
) << endl;
cout <<
should
(
"
now be 4
"
, time.
getHours
() ==
4
) << endl;
cout <<
should
(
"
return false for negative input (-1)
"
, time.
setHours
(-
1
) ==
false
) << endl;
cout <<
should
(
"
be 0 after invalid input
"
, time.
getHours
() ==
0
) << endl;
cout <<
"
Minutes:
"
<< endl;
cout <<
should
(
"
default to 0
"
, time.
getMinutes
() ==
0
) << endl;
cout <<
should
(
"
return true for positive input (10)
"
, time.
setMinutes
(
10
) ==
true
) << endl;
cout <<
should
(
"
now be 10
"
, time.
getMinutes
() ==
10
) << endl;
cout <<
should
(
"
return false for negative input (-1)
"
, time.
setMinutes
(-
1
) ==
false
) << endl;
cout <<
should
(
"
be 0 after invalid input
"
, time.
getMinutes
() ==
0
) << endl;
cout <<
"
Seconds:
"
<< endl;
cout <<
should
(
"
default to 0
"
, time.
getSeconds
() ==
0
) << endl;
cout <<
should
(
"
return true for positive input (30)
"
, time.
setSeconds
(
30
) ==
true
) << endl;
cout <<
should
(
"
now be 30
"
, time.
getSeconds
() ==
30
) << endl;
cout <<
should
(
"
return false for negative input (-1)
"
, time.
setSeconds
(-
1
) ==
false
) << endl;
cout <<
should
(
"
be 0 after invalid input
"
, time.
getSeconds
() ==
0
) << endl;
time.
setHours
(
4
);
time.
setMinutes
(
10
);
time.
setSeconds
(
30
);
//
Test methods
cout << endl;
cout <<
"
Total time (4h 10m 30s):
"
<< endl;
cout <<
should
(
"
be 4.175 hours
"
, time.
timeInHours
() ==
4.175
) << endl;
cout <<
should
(
"
be 250.5 minutes
"
, time.
timeInMinutes
() ==
250.5
) << endl;
cout <<
should
(
"
be 15030 seconds
"
, time.
timeInSeconds
() ==
15030.0
) << endl;
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL