| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 |
|
| 19 | (define-module (test-base64)
|
| 20 | #:use-module (guix base64)
|
| 21 | #:use-module (rnrs bytevectors)
|
| 22 | #:use-module (srfi srfi-64))
|
| 23 |
|
| 24 | (define (string->base64 str)
|
| 25 | (base64-encode (string->utf8 str)))
|
| 26 |
|
| 27 | |
| 28 |
|
| 29 | (test-begin "base64")
|
| 30 |
|
| 31 | (test-equal "empty string"
|
| 32 | (string->base64 "")
|
| 33 | "")
|
| 34 |
|
| 35 | (test-equal "f"
|
| 36 | (string->base64 "f")
|
| 37 | "Zg==")
|
| 38 |
|
| 39 | (test-equal "fo"
|
| 40 | (string->base64 "fo")
|
| 41 | "Zm8=")
|
| 42 |
|
| 43 | (test-equal "foo"
|
| 44 | (string->base64 "foo")
|
| 45 | "Zm9v")
|
| 46 |
|
| 47 | (test-equal "foob"
|
| 48 | (string->base64 "foob")
|
| 49 | "Zm9vYg==")
|
| 50 |
|
| 51 | (test-equal "fooba"
|
| 52 | (string->base64 "fooba")
|
| 53 | "Zm9vYmE=")
|
| 54 |
|
| 55 | (test-equal "foobar"
|
| 56 | (string->base64 "foobar")
|
| 57 | "Zm9vYmFy")
|
| 58 |
|
| 59 | (test-end "base64")
|