aboutsummaryrefslogtreecommitdiff
path: root/tests/ui.scm
diff options
context:
space:
mode:
Diffstat (limited to 'tests/ui.scm')
-rw-r--r--tests/ui.scm25
1 files changed, 24 insertions, 1 deletions
diff --git a/tests/ui.scm b/tests/ui.scm
index 08ee3967a8..886223ef54 100644
--- a/tests/ui.scm
+++ b/tests/ui.scm
@@ -1,5 +1,5 @@
;;; GNU Guix --- Functional package management for GNU
-;;; Copyright © 2013 Ludovic Courtès <ludo@gnu.org>
+;;; Copyright © 2013, 2014 Ludovic Courtès <ludo@gnu.org>
;;;
;;; This file is part of GNU Guix.
;;;
@@ -166,6 +166,29 @@ interface, and powerful string processing.")
#f
(string->duration "d"))
+(test-equal "size->number, bytes"
+ 42
+ (size->number "42"))
+
+(test-equal "size->number, MiB"
+ (* 42 (expt 2 20))
+ (size->number "42MiB"))
+
+(test-equal "size->number, GiB"
+ (* 3 (expt 2 30))
+ (size->number "3GiB"))
+
+(test-equal "size->number, 1.2GiB"
+ (inexact->exact (round (* 1.2 (expt 2 30))))
+ (size->number "1.2GiB"))
+
+(test-assert "size->number, invalid unit"
+ (catch 'quit
+ (lambda ()
+ (size->number "9X"))
+ (lambda args
+ #t)))
+
(test-end "ui")