Dever v0.0.2
This commit is contained in:
commit
e6e175ebcf
816 files changed
+120349
No files matched your search
@@ -0,0 +1,33 @@
|
||||
use dever_runtime::value::uuid::Uuid;
|
||||
let lower = "550e8400-e29b-41d4-a716-446655440000";
|
||||
let upper = "550E8400-E29B-41D4-A716-446655440000";
|
||||
let value = @parseUuid@(upper).unwrap();
|
||||
assert_eq!(std::mem::size_of::<Uuid>(), 16);
|
||||
assert!(!std::mem::needs_drop::<Uuid>());
|
||||
assert_eq!(@writeUuid@(value), lower);
|
||||
assert!(@sameUuid@(value, @parseUuid@(lower).unwrap()));
|
||||
let map = @mapUuid@(value, @parseUuid@(lower).unwrap());
|
||||
assert_eq!(map.len(), 1);
|
||||
assert_eq!(@lookupUuid@(&map, value), Some(2));
|
||||
assert_eq!(@lookupUuid@(&map, @parseUuid@("00000000-0000-0000-0000-000000000000").unwrap()), None);
|
||||
assert_eq!(@readUuid@(upper).unwrap(), value);
|
||||
for text in ["", "550e8400e29b41d4a716446655440000", "{550e8400-e29b-41d4-a716-446655440000}", "urn:uuid:550e8400-e29b-41d4-a716-446655440000", "00000000-0000-0000-0000-00000000000-", "é0e8400-e29b-41d4-a716-446655440000"] {
|
||||
assert_eq!(@parseUuid@(text), None, "{text}");
|
||||
assert!(@readUuid@(text).is_err());
|
||||
}
|
||||
for index in 0..36 {
|
||||
let mut text = lower.as_bytes().to_vec();
|
||||
text[index] = if [8, 13, 18, 23].contains(&index) { b'0' } else { b'-' };
|
||||
assert_eq!(@parseUuid@(std::str::from_utf8(&text).unwrap()), None);
|
||||
}
|
||||
for text in ["00000000-0000-0000-0000-000000000000", "ffffffff-ffff-ffff-ffff-ffffffffffff"] {
|
||||
assert_eq!(@writeUuid@(@parseUuid@(text).unwrap()), text);
|
||||
}
|
||||
let id = @Identifier@ { f0: value, f1: Some(value) };
|
||||
assert_eq!(@uuidJson@(&id).unwrap(), id);
|
||||
@allocation_counter@
|
||||
let before = ALLOCATIONS.load(Ordering::Relaxed);
|
||||
assert_eq!(@parseUuid@(std::hint::black_box(upper)), Some(value));
|
||||
assert!(@sameUuid@(value, std::hint::black_box(value)));
|
||||
assert_eq!(@lookupUuid@(&map, value), Some(2));
|
||||
assert_eq!(ALLOCATIONS.load(Ordering::Relaxed) - before, 0);
|
||||
Reference in new issue
Block a user