cpp-common/bt2c: add `format_as()` functions for `Uuid` and `UuidView`
[babeltrace.git] / tests / cpp-common / test-uuid.cpp
diff --git a/tests/cpp-common/test-uuid.cpp b/tests/cpp-common/test-uuid.cpp
new file mode 100644 (file)
index 0000000..a84ed38
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0-only
+ *
+ * Copyright (C) 2024 EfficiOS, Inc.
+ */
+
+#include "cpp-common/bt2c/fmt.hpp"
+#include "cpp-common/bt2c/uuid.hpp"
+#include "cpp-common/vendor/fmt/format.h"
+
+#include "tap/tap.h"
+
+namespace {
+
+constexpr auto uuidStr = "c2281e4a-699b-4b78-903f-2f8407fe2b77";
+const bt2c::Uuid uuid {uuidStr};
+const bt2c::UuidView uuidView {uuid};
+
+void testFormatAs()
+{
+    const auto resUuid = fmt::to_string(uuid);
+    const auto resUuidView = fmt::to_string(uuidView);
+
+    ok(resUuid == uuidStr, "result of format_as() for `Uuid` is expected");
+    ok(resUuidView == uuidStr, "result of format_as() for `UuidView` is expected");
+}
+
+} /* namespace */
+
+int main()
+{
+    plan_tests(2);
+    testFormatAs();
+    return exit_status();
+}
This page took 0.022734 seconds and 4 git commands to generate.