]>
Commit | Line | Data |
---|---|---|
1 | #include <config.h> | |
2 | ||
3 | #include <apt-pkg/install-progress.h> | |
4 | ||
5 | #include <string> | |
6 | ||
7 | #include <gtest/gtest.h> | |
8 | ||
9 | TEST(InstallProgressTest, FancyGetTextProgressStr) | |
10 | { | |
11 | APT::Progress::PackageManagerFancy p; | |
12 | ||
13 | EXPECT_EQ(60, p.GetTextProgressStr(0.5, 60).size()); | |
14 | EXPECT_EQ("[#.]", p.GetTextProgressStr(0.5, 4)); | |
15 | EXPECT_EQ("[..........]", p.GetTextProgressStr(0.0, 12)); | |
16 | EXPECT_EQ("[#.........]", p.GetTextProgressStr(0.1, 12)); | |
17 | EXPECT_EQ("[####......]", p.GetTextProgressStr(0.4999, 12)); | |
18 | EXPECT_EQ("[#####.....]", p.GetTextProgressStr(0.5001, 12)); | |
19 | EXPECT_EQ("[#########.]", p.GetTextProgressStr(0.9, 12)); | |
20 | EXPECT_EQ("[##########]", p.GetTextProgressStr(1.0, 12)); | |
21 | ||
22 | // deal with incorrect inputs gracefully (or should we die instead?) | |
23 | EXPECT_EQ("[..........]", p.GetTextProgressStr(-1.0, 12)); | |
24 | EXPECT_EQ("[##########]", p.GetTextProgressStr(2.0, 12)); | |
25 | } |