summaryrefslogtreecommitdiff
path: root/src/test
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2016-07-22 21:18:41 -0400
committerGitHub <noreply@github.com>2016-07-22 21:18:41 -0400
commit31b14fdb6f2f018a9d67c9303aac9903b4227dbd (patch)
treeb44e75dc5b0fff27ad008fbea11d7bdcc994bd12 /src/test
parentc907cba919a1e9840859296f192f3a55345ff29c (diff)
parent487ddeb8bc1a05816802adb2d5a9dc4416b386fe (diff)
Merge pull request #3777 from poettering/id128-rework
uuid/id128 code rework
Diffstat (limited to 'src/test')
-rw-r--r--src/test/test-id128.c14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/test/test-id128.c b/src/test/test-id128.c
index 96aa008c06..324c7a2019 100644
--- a/src/test/test-id128.c
+++ b/src/test/test-id128.c
@@ -26,6 +26,7 @@
#include "macro.h"
#include "string-util.h"
#include "util.h"
+#include "id128-util.h"
#define ID128_WALDI SD_ID128_MAKE(01, 02, 03, 04, 05, 06, 07, 08, 09, 0a, 0b, 0c, 0d, 0e, 0f, 10)
#define STR_WALDI "0102030405060708090a0b0c0d0e0f10"
@@ -33,7 +34,7 @@
int main(int argc, char *argv[]) {
sd_id128_t id, id2;
- char t[33];
+ char t[33], q[37];
_cleanup_free_ char *b = NULL;
assert_se(sd_id128_randomize(&id) == 0);
@@ -57,6 +58,17 @@ int main(int argc, char *argv[]) {
printf("waldi2: %s\n", b);
assert_se(streq(t, b));
+ printf("waldi3: %s\n", id128_to_uuid_string(ID128_WALDI, q));
+ assert_se(streq(q, UUID_WALDI));
+
+ b = mfree(b);
+ assert_se(asprintf(&b, ID128_UUID_FORMAT_STR, SD_ID128_FORMAT_VAL(ID128_WALDI)) == 36);
+ printf("waldi4: %s\n", b);
+ assert_se(streq(q, b));
+
+ assert_se(sd_id128_from_string(STR_WALDI, &id) >= 0);
+ assert_se(sd_id128_equal(id, ID128_WALDI));
+
assert_se(sd_id128_from_string(UUID_WALDI, &id) >= 0);
assert_se(sd_id128_equal(id, ID128_WALDI));