You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

26 lines
878 B

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