summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMichael Vogt <mvo@ubuntu.com>2014-04-01 12:21:46 +0200
committerMichael Vogt <mvo@ubuntu.com>2014-04-01 12:21:46 +0200
commit035a31392a094a92eeff4371c56fae893d49991b (patch)
treeac2fc35bc682876806401347f69af727d74d3774 /test
parenta78578a9bfabf9c1b5a84e8f26fa5f193a56cb76 (diff)
parent8bc31a93c391eaa31864534553348870901d2dd9 (diff)
Merge remote-tracking branch 'mvo/feature/more-fancy-progress' into debian/sid
Diffstat (limited to 'test')
-rw-r--r--test/libapt/install_progress_test.cc30
-rw-r--r--test/libapt/makefile6
2 files changed, 36 insertions, 0 deletions
diff --git a/test/libapt/install_progress_test.cc b/test/libapt/install_progress_test.cc
new file mode 100644
index 000000000..be1a3411e
--- /dev/null
+++ b/test/libapt/install_progress_test.cc
@@ -0,0 +1,30 @@
+#include <config.h>
+
+#include <apt-pkg/install-progress.h>
+
+#include <string>
+
+#include "assert.h"
+
+int main() {
+ APT::Progress::PackageManagerFancy p;
+ std::string s;
+
+ s= p.GetTextProgressStr(0.5, 60);
+ equals(s.size(), 60);
+
+ s= p.GetTextProgressStr(0.5, 4);
+ equals(s, "[#.]");
+
+ s= p.GetTextProgressStr(0.1, 12);
+ equals(s, "[#.........]");
+
+ s= p.GetTextProgressStr(0.9, 12);
+ equals(s, "[#########.]");
+
+ // deal with incorrect inputs gracefully (or should we die instead?)
+ s= p.GetTextProgressStr(-999, 12);
+ equals(s, "");
+
+ return 0;
+}
diff --git a/test/libapt/makefile b/test/libapt/makefile
index 66d6ea783..e03b5e6aa 100644
--- a/test/libapt/makefile
+++ b/test/libapt/makefile
@@ -123,3 +123,9 @@ SLIBS = -lapt-pkg
SOURCE = sourcelist_test.cc
include $(PROGRAM_H)
+# test install-progress
+PROGRAM = InstallProgress${BASENAME}
+SLIBS = -lapt-pkg
+SOURCE = install_progress_test.cc
+include $(PROGRAM_H)
+