diff --git a/lib/src/key/az.rs b/lib/src/key/az.rs index 228da1a8..9f88e7d4 100644 --- a/lib/src/key/az.rs +++ b/lib/src/key/az.rs @@ -58,7 +58,20 @@ mod tests { "test", ); let enc = Az::encode(&val).unwrap(); + assert_eq!(enc, b"/*ns\0*db\0!aztest\0"); let dec = Az::decode(&enc).unwrap(); assert_eq!(val, dec); } + + #[test] + fn prefix() { + let val = super::prefix("namespace", "database"); + assert_eq!(val, b"/*namespace\0*database\0!az\0"); + } + + #[test] + fn suffix() { + let val = super::suffix("namespace", "database"); + assert_eq!(val, b"/*namespace\0*database\0!az\xff"); + } } diff --git a/lib/src/key/bc.rs b/lib/src/key/bc.rs index 64e1c9ae..327515c7 100644 --- a/lib/src/key/bc.rs +++ b/lib/src/key/bc.rs @@ -41,18 +41,21 @@ impl<'a> Bc<'a> { #[cfg(test)] mod tests { + #[test] fn key() { use super::*; #[rustfmt::skip] let val = Bc::new( - "test", - "test", - "test", - "test", + "testns", + "testdb", + "testtb", + "testix", 7 ); let enc = Bc::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0*testtb\0!bctestix\0*\0\0\0\0\0\0\0\x07"); + let dec = Bc::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/bd.rs b/lib/src/key/bd.rs index a40e4cdf..3a83304d 100644 --- a/lib/src/key/bd.rs +++ b/lib/src/key/bd.rs @@ -52,13 +52,19 @@ mod tests { use super::*; #[rustfmt::skip] let val = Bd::new( - "test", - "test", - "test", - "test", + "testns", + "testdb", + "testtb", + "testix", Some(7) ); let enc = Bd::encode(&val).unwrap(); + assert_eq!( + enc, + b"/*testns\0*testdb\0*testtb\0!bdtestix\0*\ + \x01\ + \0\0\0\0\0\0\0\x07" + ); let dec = Bd::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/bf.rs b/lib/src/key/bf.rs index 673c8261..833310b5 100644 --- a/lib/src/key/bf.rs +++ b/lib/src/key/bf.rs @@ -57,14 +57,21 @@ mod tests { fn key() { #[rustfmt::skip] let val = Bf::new( - "test", - "test", - "test", - "test", - 1, - 2 + "testns", + "testdb", + "testtb", + "testix", + 7, + 13 ); let enc = Bf::encode(&val).unwrap(); + assert_eq!( + enc, + b"/*testns\0*testdb\0*testtb\0!bftestix\0*\ + \0\0\0\0\0\0\0\x07\ + \0\0\0\0\0\0\0\x0d" + ); + let dec = Bf::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/bi.rs b/lib/src/key/bi.rs index 31d5f841..944e8ce9 100644 --- a/lib/src/key/bi.rs +++ b/lib/src/key/bi.rs @@ -46,13 +46,19 @@ mod tests { use super::*; #[rustfmt::skip] let val = Bi::new( - "test", - "test", - "test", - "test", + "testns", + "testdb", + "testtb", + "testix", 7 ); let enc = Bi::encode(&val).unwrap(); + assert_eq!( + enc, + b"/*testns\0*testdb\0*testtb\0!bitestix\0*\ + \0\0\0\0\0\0\0\x07" + ); + let dec = Bi::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/bk.rs b/lib/src/key/bk.rs index 6e06443c..d33fb7da 100644 --- a/lib/src/key/bk.rs +++ b/lib/src/key/bk.rs @@ -46,13 +46,15 @@ mod tests { use super::*; #[rustfmt::skip] let val = Bk::new( - "test", - "test", - "test", - "test", + "testns", + "testdb", + "testtb", + "testix", 7 ); let enc = Bk::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0*testtb\0!bktestix\0*\0\0\0\0\0\0\0\x07"); + let dec = Bk::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/bl.rs b/lib/src/key/bl.rs index 2dd22bd7..9babeffd 100644 --- a/lib/src/key/bl.rs +++ b/lib/src/key/bl.rs @@ -52,13 +52,20 @@ mod tests { use super::*; #[rustfmt::skip] let val = Bl::new( - "test", - "test", - "test", - "test", + "testns", + "testdb", + "testtb", + "testix", Some(7) ); let enc = Bl::encode(&val).unwrap(); + assert_eq!( + enc, + b"/*testns\0*testdb\0*testtb\0!bltestix\0*\ + \x01\ + \0\0\0\0\0\0\0\x07" + ); + let dec = Bl::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/bo.rs b/lib/src/key/bo.rs index 9953e06c..eb63d897 100644 --- a/lib/src/key/bo.rs +++ b/lib/src/key/bo.rs @@ -56,13 +56,18 @@ mod tests { use super::*; #[rustfmt::skip] let val = Bo::new( - "test", - "test", - "test", - "test", + "testns", + "testdb", + "testtb", + "testix", 1,2 ); let enc = Bo::encode(&val).unwrap(); + assert_eq!( + enc, + b"/*testns\0*testdb\0*testtb\0!botestix\0*\0\0\0\0\0\0\0\x01\0\0\0\0\0\0\0\x02" + ); + let dec = Bo::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/bp.rs b/lib/src/key/bp.rs index 539a0ae6..6bb95bd2 100644 --- a/lib/src/key/bp.rs +++ b/lib/src/key/bp.rs @@ -52,13 +52,20 @@ mod tests { use super::*; #[rustfmt::skip] let val = Bp::new( - "test", - "test", - "test", - "test", + "testns", + "testdb", + "testtb", + "testix", Some(7) ); let enc = Bp::encode(&val).unwrap(); + assert_eq!( + enc, + b"/*testns\0*testdb\0*testtb\0!bptestix\0*\ + \x01\ + \0\0\0\0\0\0\0\x07" + ); + let dec = Bp::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/bs.rs b/lib/src/key/bs.rs index bbe947ea..3baa6caf 100644 --- a/lib/src/key/bs.rs +++ b/lib/src/key/bs.rs @@ -41,12 +41,14 @@ mod tests { use super::*; #[rustfmt::skip] let val = Bs::new( - "test", - "test", - "test", - "test", + "testns", + "testdb", + "testtb", + "testix", ); let enc = Bs::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0*testtb\0!bstestix\0"); + let dec = Bs::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/bt.rs b/lib/src/key/bt.rs index 30c8ef26..eee3a61b 100644 --- a/lib/src/key/bt.rs +++ b/lib/src/key/bt.rs @@ -52,13 +52,19 @@ mod tests { use super::*; #[rustfmt::skip] let val = Bt::new( - "test", - "test", - "test", - "test", + "testns", + "testdb", + "testtb", + "testix", Some(7) ); let enc = Bt::encode(&val).unwrap(); + assert_eq!( + enc, + b"/*testns\0*testdb\0*testtb\0!bttestix\0*\ + \x01\ + \0\0\0\0\0\0\0\x07" + ); let dec = Bt::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/bu.rs b/lib/src/key/bu.rs index f86c3175..7e9f51dc 100644 --- a/lib/src/key/bu.rs +++ b/lib/src/key/bu.rs @@ -46,13 +46,15 @@ mod tests { use super::*; #[rustfmt::skip] let val = Bu::new( - "test", - "test", - "test", - "test", + "testns", + "testdb", + "testtb", + "testix", 7 ); let enc = Bu::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0*testtb\0!butestix\0*\0\0\0\0\0\0\0\x07"); + let dec = Bu::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/database.rs b/lib/src/key/database.rs index bad01bd9..8ab677fc 100644 --- a/lib/src/key/database.rs +++ b/lib/src/key/database.rs @@ -33,10 +33,12 @@ mod tests { use super::*; #[rustfmt::skip] let val = Database::new( - "test", - "test", + "testns", + "testdb", ); let enc = Database::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0"); + let dec = Database::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/db.rs b/lib/src/key/db.rs index b2a55780..fb4de51f 100644 --- a/lib/src/key/db.rs +++ b/lib/src/key/db.rs @@ -49,11 +49,25 @@ mod tests { use super::*; #[rustfmt::skip] let val = Db::new( - "test", - "test", + "testns", + "testdb", ); let enc = Db::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0!dbtestdb\0"); + let dec = Db::decode(&enc).unwrap(); assert_eq!(val, dec); } + + #[test] + fn test_prefix() { + let val = super::prefix("testns"); + assert_eq!(val, b"/*testns\0!db\0") + } + + #[test] + fn test_suffix() { + let val = super::suffix("testns"); + assert_eq!(val, b"/*testns\0!db\xff") + } } diff --git a/lib/src/key/dl.rs b/lib/src/key/dl.rs index 88b5a479..9888b3ea 100644 --- a/lib/src/key/dl.rs +++ b/lib/src/key/dl.rs @@ -53,11 +53,13 @@ mod tests { use super::*; #[rustfmt::skip] let val = Dl::new( - "test", - "test", - "test", + "testns", + "testdb", + "testdl", ); let enc = Dl::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0!dltestdl\0"); + let dec = Dl::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/dt.rs b/lib/src/key/dt.rs index 20dc5b6c..956aae78 100644 --- a/lib/src/key/dt.rs +++ b/lib/src/key/dt.rs @@ -53,12 +53,26 @@ mod tests { use super::*; #[rustfmt::skip] let val = Dt::new( - "test", - "test", - "test", + "testns", + "testdb", + "testtk", ); let enc = Dt::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\x00*testdb\x00!dttesttk\x00"); + let dec = Dt::decode(&enc).unwrap(); assert_eq!(val, dec); } + + #[test] + fn test_prefix() { + let val = super::prefix("testns", "testdb"); + assert_eq!(val, b"/*testns\0*testdb\0!dt\0"); + } + + #[test] + fn test_suffix() { + let val = super::suffix("testns", "testdb"); + assert_eq!(val, b"/*testns\0*testdb\0!dt\xff"); + } } diff --git a/lib/src/key/ev.rs b/lib/src/key/ev.rs index 2517295a..1f7c3fc2 100644 --- a/lib/src/key/ev.rs +++ b/lib/src/key/ev.rs @@ -57,13 +57,27 @@ mod tests { use super::*; #[rustfmt::skip] let val = Ev::new( - "test", - "test", - "test", - "test", + "testns", + "testdb", + "testtb", + "testev", ); let enc = Ev::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\x00*testdb\x00*testtb\x00!evtestev\x00"); + let dec = Ev::decode(&enc).unwrap(); assert_eq!(val, dec); } + + #[test] + fn test_prefix() { + let val = super::prefix("testns", "testdb", "testtb"); + assert_eq!(val, b"/*testns\0*testdb\0*testtb\0!ev\0"); + } + + #[test] + fn test_suffix() { + let val = super::suffix("testns", "testdb", "testtb"); + assert_eq!(val, b"/*testns\0*testdb\0*testtb\0!ev\xff"); + } } diff --git a/lib/src/key/fc.rs b/lib/src/key/fc.rs index 4cac00bc..c9310496 100644 --- a/lib/src/key/fc.rs +++ b/lib/src/key/fc.rs @@ -53,12 +53,25 @@ mod tests { use super::*; #[rustfmt::skip] let val = Fc::new( - "test", - "test", - "test", + "testns", + "testdb", + "testfc", ); let enc = Fc::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\x00*testdb\x00!fntestfc\x00"); let dec = Fc::decode(&enc).unwrap(); assert_eq!(val, dec); } + + #[test] + fn test_prefix() { + let val = super::prefix("testns", "testdb"); + assert_eq!(val, b"/*testns\0*testdb\0!fn\0"); + } + + #[test] + fn test_suffix() { + let val = super::suffix("testns", "testdb"); + assert_eq!(val, b"/*testns\0*testdb\0!fn\xff"); + } } diff --git a/lib/src/key/fd.rs b/lib/src/key/fd.rs index e5d690ed..32fb3963 100644 --- a/lib/src/key/fd.rs +++ b/lib/src/key/fd.rs @@ -57,13 +57,27 @@ mod tests { use super::*; #[rustfmt::skip] let val = Fd::new( - "test", - "test", - "test", - "test", + "testns", + "testdb", + "testtb", + "testfd", ); let enc = Fd::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\x00*testdb\x00*testtb\x00!fdtestfd\x00"); + let dec = Fd::decode(&enc).unwrap(); assert_eq!(val, dec); } + + #[test] + fn test_prefix() { + let val = super::prefix("testns", "testdb", "testtb"); + assert_eq!(val, b"/*testns\0*testdb\0*testtb\0!fd\0"); + } + + #[test] + fn test_suffix() { + let val = super::suffix("testns", "testdb", "testtb"); + assert_eq!(val, b"/*testns\0*testdb\0*testtb\0!fd\xff"); + } } diff --git a/lib/src/key/ft.rs b/lib/src/key/ft.rs index 80d85f38..12b8c0b1 100644 --- a/lib/src/key/ft.rs +++ b/lib/src/key/ft.rs @@ -57,13 +57,27 @@ mod tests { use super::*; #[rustfmt::skip] let val = Ft::new( - "test", - "test", - "test", - "test", + "testns", + "testdb", + "testtb", + "testft", ); let enc = Ft::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\x00*testdb\x00*testtb\x00!fttestft\x00"); + let dec = Ft::decode(&enc).unwrap(); assert_eq!(val, dec); } + + #[test] + fn test_prefix() { + let val = super::prefix("testns", "testdb", "testtb"); + assert_eq!(val, b"/*testns\0*testdb\0*testtb\0!ft\0"); + } + + #[test] + fn test_suffix() { + let val = super::suffix("testns", "testdb", "testtb"); + assert_eq!(val, b"/*testns\0*testdb\0*testtb\0!ft\xff"); + } } diff --git a/lib/src/key/graph.rs b/lib/src/key/graph.rs index 883164b6..5a742693 100644 --- a/lib/src/key/graph.rs +++ b/lib/src/key/graph.rs @@ -188,14 +188,19 @@ mod tests { let fk = Thing::parse("other:test"); #[rustfmt::skip] let val = Graph::new( - "test", - "test", - "test", - "test".into(), + "testns", + "testdb", + "testtb", + "testid".into(), Dir::Out, &fk, ); let enc = Graph::encode(&val).unwrap(); + assert_eq!( + enc, + b"/*testns\0*testdb\0*testtb\x00~\0\0\0\x01testid\0\0\0\0\x01other\0\0\0\0\x01test\0" + ); + let dec = Graph::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/index.rs b/lib/src/key/index.rs index c182c603..64b9a3b5 100644 --- a/lib/src/key/index.rs +++ b/lib/src/key/index.rs @@ -146,14 +146,19 @@ mod tests { use super::*; #[rustfmt::skip] let val = Index::new( - "test", - "test", - "test", - "test", - vec!["test"].into(), - Some("test".into()), + "testns", + "testdb", + "testtb", + "testix", + vec!["testfd1", "testfd2"].into(), + Some("testid".into()), ); let enc = Index::encode(&val).unwrap(); + assert_eq!( + enc, + b"/*testns\0*testdb\0*testtb\0\xa4testix\0\0\0\0\x04testfd1\0\0\0\0\x04testfd2\0\x01\x01\0\0\0\x01testid\0" + ); + let dec = Index::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/ix.rs b/lib/src/key/ix.rs index e5fa314c..5119f06f 100644 --- a/lib/src/key/ix.rs +++ b/lib/src/key/ix.rs @@ -57,12 +57,14 @@ mod tests { use super::*; #[rustfmt::skip] let val = Ix::new( - "test", - "test", - "test", - "test", + "testns", + "testdb", + "testtb", + "testix", ); let enc = Ix::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0*testtb\0!ixtestix\0"); + let dec = Ix::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/kv.rs b/lib/src/key/kv.rs index 3aeb7843..c576c55f 100644 --- a/lib/src/key/kv.rs +++ b/lib/src/key/kv.rs @@ -32,6 +32,8 @@ mod tests { #[rustfmt::skip] let val = Kv::new(); let enc = Kv::encode(&val).unwrap(); + assert_eq!(enc, b"/"); + let dec = Kv::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/namespace.rs b/lib/src/key/namespace.rs index 99f74816..9ae15a96 100644 --- a/lib/src/key/namespace.rs +++ b/lib/src/key/namespace.rs @@ -29,9 +29,11 @@ mod tests { use super::*; #[rustfmt::skip] let val = Namespace::new( - "test", + "testns", ); let enc = Namespace::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0"); + let dec = Namespace::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/nl.rs b/lib/src/key/nl.rs index 5640635a..ddde749c 100644 --- a/lib/src/key/nl.rs +++ b/lib/src/key/nl.rs @@ -49,10 +49,12 @@ mod tests { use super::*; #[rustfmt::skip] let val = Nl::new( - "test", - "test", + "testns", + "testus", ); let enc = Nl::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0!nltestus\0"); + let dec = Nl::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/ns.rs b/lib/src/key/ns.rs index 1dfca4e4..50ade88d 100644 --- a/lib/src/key/ns.rs +++ b/lib/src/key/ns.rs @@ -45,9 +45,11 @@ mod tests { use super::*; #[rustfmt::skip] let val = Ns::new( - "test", + "testns", ); let enc = Ns::encode(&val).unwrap(); + assert_eq!(enc, b"/!nstestns\0"); + let dec = Ns::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/nt.rs b/lib/src/key/nt.rs index d59ed2e4..85b62b4b 100644 --- a/lib/src/key/nt.rs +++ b/lib/src/key/nt.rs @@ -49,10 +49,11 @@ mod tests { use super::*; #[rustfmt::skip] let val = Nt::new( - "test", - "test", + "testns", + "testtk", ); let enc = Nt::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0!nttesttk\0"); let dec = Nt::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/pa.rs b/lib/src/key/pa.rs index 725a9e00..7be71bf4 100644 --- a/lib/src/key/pa.rs +++ b/lib/src/key/pa.rs @@ -53,11 +53,13 @@ mod tests { use super::*; #[rustfmt::skip] let val = Pa::new( - "test", - "test", - "test", + "testns", + "testdb", + "testpa", ); let enc = Pa::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0!patestpa\0"); + let dec = Pa::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/sc.rs b/lib/src/key/sc.rs index 80894694..08b72ebb 100644 --- a/lib/src/key/sc.rs +++ b/lib/src/key/sc.rs @@ -53,11 +53,13 @@ mod tests { use super::*; #[rustfmt::skip] let val = Sc::new( - "test", - "test", - "test", + "testns", + "testdb", + "testsc", ); let enc = Sc::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0!sctestsc\0"); + let dec = Sc::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/scope.rs b/lib/src/key/scope.rs index 71bc14a5..46943ce7 100644 --- a/lib/src/key/scope.rs +++ b/lib/src/key/scope.rs @@ -38,11 +38,13 @@ mod tests { use super::*; #[rustfmt::skip] let val = Scope::new( - "test", - "test", - "test", + "testns", + "testdb", + "testsc", ); let enc = Scope::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0\xb1testsc\0"); + let dec = Scope::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/st.rs b/lib/src/key/st.rs index b86593bd..f7548773 100644 --- a/lib/src/key/st.rs +++ b/lib/src/key/st.rs @@ -58,12 +58,14 @@ mod tests { use super::*; #[rustfmt::skip] let val = St::new( - "test", - "test", - "test", - "test", + "testns", + "testdb", + "testsc", + "testtk", ); let enc = St::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0\xb1testsc\0!sttesttk\0"); + let dec = St::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/table.rs b/lib/src/key/table.rs index 62258cc1..d6fa014a 100644 --- a/lib/src/key/table.rs +++ b/lib/src/key/table.rs @@ -37,11 +37,13 @@ mod tests { use super::*; #[rustfmt::skip] let val = Table::new( - "test", - "test", - "test", + "testns", + "testdb", + "testtb", ); let enc = Table::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0*testtb\0"); + let dec = Table::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/tb.rs b/lib/src/key/tb.rs index ed6c1433..17047324 100644 --- a/lib/src/key/tb.rs +++ b/lib/src/key/tb.rs @@ -53,11 +53,13 @@ mod tests { use super::*; #[rustfmt::skip] let val = Tb::new( - "test", - "test", - "test", + "testns", + "testdb", + "testtb", ); let enc = Tb::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0!tbtesttb\0"); + let dec = Tb::decode(&enc).unwrap(); assert_eq!(val, dec); } diff --git a/lib/src/key/thing.rs b/lib/src/key/thing.rs index c81cd5f4..0edf3daf 100644 --- a/lib/src/key/thing.rs +++ b/lib/src/key/thing.rs @@ -54,12 +54,14 @@ mod tests { use super::*; #[rustfmt::skip] let val = Thing::new( - "test", - "test", - "test", - "test".into(), + "testns", + "testdb", + "testtb", + "testid".into(), ); let enc = Thing::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0*testtb\0*\0\0\0\x01testid\0"); + let dec = Thing::decode(&enc).unwrap(); assert_eq!(val, dec); } @@ -69,16 +71,20 @@ mod tests { // let id1 = "['test']"; let (_, id1) = crate::sql::id::id(id1).expect("Failed to parse the ID"); - let val = Thing::new("test", "test", "test", id1); + let val = Thing::new("testns", "testdb", "testtb", id1); let enc = Thing::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0*testtb\0*\0\0\0\x02\0\0\0\x04test\0\x01"); + let dec = Thing::decode(&enc).unwrap(); assert_eq!(val, dec); println!("---"); // let id2 = "['f8e238f2-e734-47b8-9a16-476b291bd78a']"; let (_, id2) = crate::sql::id::id(id2).expect("Failed to parse the ID"); - let val = Thing::new("test", "test", "test", id2); + let val = Thing::new("testns", "testdb", "testtb", id2); let enc = Thing::encode(&val).unwrap(); + assert_eq!(enc, b"/*testns\0*testdb\0*testtb\0*\0\0\0\x02\0\0\0\x07\xf8\xe2\x38\xf2\xe7\x34\x47\xb8\x9a\x16\x47\x6b\x29\x1b\xd7\x8a\x01"); + let dec = Thing::decode(&enc).unwrap(); assert_eq!(val, dec); println!("---");