summaryrefslogtreecommitdiff
path: root/test/pkuuid.cpp
diff options
context:
space:
mode:
authorJonathan Bradley <jcb@pikum.xyz>2025-03-27 16:13:10 -0400
committerJonathan Bradley <jcb@pikum.xyz>2025-03-27 16:13:10 -0400
commitc65204648f0a81cce25c12c6dcd58d76810ac303 (patch)
tree4634f98672d00e321ab19d51629af130f1a27fbf /test/pkuuid.cpp
parentbe07962dc264b732f9facafec7bbe4019bf91ad2 (diff)
pkuuid: add << and >> for const char *
Diffstat (limited to 'test/pkuuid.cpp')
-rw-r--r--test/pkuuid.cpp74
1 files changed, 71 insertions, 3 deletions
diff --git a/test/pkuuid.cpp b/test/pkuuid.cpp
index da59264..35c099f 100644
--- a/test/pkuuid.cpp
+++ b/test/pkuuid.cpp
@@ -144,11 +144,29 @@ main(int argc, char *argv[])
// >>
{
- struct pk_uuid id;
- std::istringstream ssi("017f22e2-79b0-7cc3-98c4-dc0c0c07398f");
+ struct pk_uuid id = pk_uuid_max;
+ std::istringstream ssi("017f22e2-79b0-7cc3-98c4-dc0c0c07398fX");
ssi >> id;
+
+ fprintf(stdout, "\n");
+ fprintf(stdout, "[%s] leftovers: ", __FILE__);
ssi >> std::cout.rdbuf();
+ std::cout << std::endl;
+ fprintf(stdout, "[%s] excpected: 017f22e2-79b0-7cc3-98c4-dc0c0c07398f\n", __FILE__);
+ fprintf(stdout, "[%s] result : " pk_uuid_printf_format "\n", __FILE__, pk_uuid_printf_var(id));
+
+ for (int i = 0; i < 16; ++i) {
+ if (example_id.uuid[i] != id.uuid[i]) return 1;
+ }
+ }
+
+ // >>
+ {
+ struct pk_uuid id = pk_uuid_max;
+ const char *ssi = "017f22e2-79b0-7cc3-98c4-dc0c0c07398f";
+
+ ssi >> id;
fprintf(stdout, "\n");
fprintf(stdout, "[%s] excpected: 017f22e2-79b0-7cc3-98c4-dc0c0c07398f\n", __FILE__);
@@ -159,9 +177,59 @@ main(int argc, char *argv[])
}
}
- // >> err
+ // <<
{
struct pk_uuid id;
+ const char *ssi = "017f22e2-79b0-7cc3-98c4-dc0c0c07398f";
+
+ id << ssi;
+
+ fprintf(stdout, "\n");
+ fprintf(stdout, "[%s] excpected: 017f22e2-79b0-7cc3-98c4-dc0c0c07398f\n", __FILE__);
+ fprintf(stdout, "[%s] result : " pk_uuid_printf_format "\n", __FILE__, pk_uuid_printf_var(id));
+
+ for (int i = 0; i < 16; ++i) {
+ if (example_id.uuid[i] != id.uuid[i]) return 1;
+ }
+ }
+
+ // >>
+ {
+ struct pk_uuid id = pk_uuid_max;
+ const char *ssi = "017f22e2-79b0-7cc3-98c4-dc0c0c07398fX";
+
+ const char *res = ssi >> id;
+
+ fprintf(stdout, "\n");
+ fprintf(stdout, "[%s] leftovers: %.2s\n", __FILE__, res);
+ fprintf(stdout, "[%s] excpected: 017f22e2-79b0-7cc3-98c4-dc0c0c07398f\n", __FILE__);
+ fprintf(stdout, "[%s] result : " pk_uuid_printf_format "\n", __FILE__, pk_uuid_printf_var(id));
+
+ if (res[0] != 'X') exit(1);
+ for (int i = 0; i < 16; ++i) {
+ if (example_id.uuid[i] != id.uuid[i]) return 1;
+ }
+ }
+
+ // >> err
+ {
+ struct pk_uuid id = example_id;
+ const char *ssi = "gnud";
+
+ ssi >> id;
+
+ fprintf(stdout, "\n");
+ fprintf(stdout, "[%s] excpected: 00000000-0000-0000-0000-000000000000\n", __FILE__);
+ fprintf(stdout, "[%s] result : " pk_uuid_printf_format "\n", __FILE__, pk_uuid_printf_var(id));
+
+ for (int i = 0; i < 16; ++i) {
+ if (pk_uuid_zed.uuid[i] != id.uuid[i]) return 1;
+ }
+ }
+
+ // >> err
+ {
+ struct pk_uuid id = example_id;
std::istringstream ssi("gnud");
ssi >> id;