aboutsummaryrefslogtreecommitdiffstats
path: root/rust/tests/test_fcid.rs
diff options
context:
space:
mode:
authorBryan Newbold <bnewbold@robocracy.org>2018-07-20 14:33:09 -0700
committerBryan Newbold <bnewbold@robocracy.org>2018-07-20 14:33:09 -0700
commitb4eb110bd880f78c5da578fe897ae97d4c734984 (patch)
tree2eef3aeef360e548680c431abb2b5547f4242632 /rust/tests/test_fcid.rs
parente4c1514294443b9e6f6ed716dcad5ebec64c3af8 (diff)
downloadfatcat-b4eb110bd880f78c5da578fe897ae97d4c734984.tar.gz
fatcat-b4eb110bd880f78c5da578fe897ae97d4c734984.zip
rust: base32 encoded idents
Diffstat (limited to 'rust/tests/test_fcid.rs')
-rw-r--r--rust/tests/test_fcid.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/rust/tests/test_fcid.rs b/rust/tests/test_fcid.rs
new file mode 100644
index 00000000..c9f6c00d
--- /dev/null
+++ b/rust/tests/test_fcid.rs
@@ -0,0 +1,20 @@
+extern crate fatcat;
+extern crate uuid;
+
+use fatcat::api_helpers::{fcid2uuid, uuid2fcid};
+use uuid::Uuid;
+
+#[test]
+fn test_fcid_conversions() {
+ let test_uuid = Uuid::parse_str("86daea5b-1b6b-432a-bb67-ea97795f80fe").unwrap();
+ let test_fcid = "q3nouwy3nnbsvo3h5klxsx4a7y";
+
+ assert_eq!(test_fcid, uuid2fcid(&test_uuid));
+ assert_eq!(test_uuid, fcid2uuid(test_fcid).unwrap());
+ assert_eq!(test_uuid, fcid2uuid(&test_fcid.to_uppercase()).unwrap());
+ assert_eq!(test_uuid, fcid2uuid(&uuid2fcid(&test_uuid)).unwrap());
+
+ assert_eq!(false, fcid2uuid("asdf").is_ok());
+ assert_eq!(false, fcid2uuid("q3nouwy3nnbsvo3h5klx").is_ok());
+ assert_eq!(false, fcid2uuid("10Oouwy3nnbsvo3h5klxsx4a7y").is_ok());
+}