-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathmain.cpp
More file actions
54 lines (44 loc) · 1.36 KB
/
main.cpp
File metadata and controls
54 lines (44 loc) · 1.36 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
#include "progress_bar.hpp"
#include <iostream>
#include <thread>
#include <chrono>
int main(){
int n;
/// Example 1 ///
n = 100;
ProgressBar *bar1 = new ProgressBar(n, "Example 1");
for(int i=0;i<=n;++i){
bar1->Progressed(i);
std::this_thread::sleep_for (std::chrono::milliseconds(10));
}
/// Example 2 ///
n = 1000;
ProgressBar *bar2 = new ProgressBar(n, "Example 2");
bar2->SetFrequencyUpdate(10);
bar2->SetStyle("|","-");
//bar2->SetStyle("\u2588", "-"); for linux
std::cout << std::endl;
for(int i=0;i<=n;++i){
bar2->Progressed(i);
std::this_thread::sleep_for(std::chrono::milliseconds(1));
}
n = 5;
ProgressBar bar3(n);
bar3.Progressed(0);
std::this_thread::sleep_for (std::chrono::milliseconds(200));
bar3.Progressed(1);
std::this_thread::sleep_for (std::chrono::milliseconds(200));
bar3.Progressed(2);
std::this_thread::sleep_for (std::chrono::milliseconds(200));
bar3.Progressed(3);
std::this_thread::sleep_for (std::chrono::milliseconds(200));
bar3.Progressed(4);
std::this_thread::sleep_for (std::chrono::milliseconds(200));
bar3.Progressed(5);
// following tests exception error
std::this_thread::sleep_for (std::chrono::milliseconds(200));
bar3.Progressed(6);
std::this_thread::sleep_for (std::chrono::milliseconds(200));
bar3.Progressed(7);
return 0;
}