diff --git a/src/morethantext/cachetype.rs b/src/morethantext/cachetype.rs index 6a18eaf..14b4c77 100644 --- a/src/morethantext/cachetype.rs +++ b/src/morethantext/cachetype.rs @@ -62,6 +62,7 @@ impl CacheType { Ok(CacheType::Raw(str::from_utf8(&output).unwrap().to_string())) } "DBMap" => Ok(CacheType::DBMap(Databases::new())), + "TableMap" => Ok(CacheType::TableMap), _ => Err(DBError::new("data corruption")), } } @@ -178,4 +179,21 @@ mod enum_ctype { let holder = CacheType::TableMap; assert_eq!(holder.entry_type(), "TableMap"); } + + #[test] + fn get_new_database_bytes() { + let holder = CacheType::TableMap; + let mut expected = "TableMap".as_bytes().to_vec(); + expected.push(0); + let output = holder.to_bytes(); + assert_eq!(output, expected); + } + + #[test] + fn from_new_database_bytes() { + let mut data = "TableMap".as_bytes().to_vec(); + data.push(0); + let output = CacheType::from_bytes(data).unwrap(); + assert_eq!(output.entry_type(), "TableMap"); + } }