From 3c20d0902e04d2d4e50d427dd10dbaeedf838156 Mon Sep 17 00:00:00 2001 From: Floris Bruynooghe Date: Sun, 3 Apr 2022 20:18:20 +0200 Subject: [PATCH] Add explicit tests for special ContactId values Turns out some FFI users don't use the constants. Scary. --- src/contact.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/contact.rs b/src/contact.rs index 4c4eb3058..9f10db254 100644 --- a/src/contact.rs +++ b/src/contact.rs @@ -1479,6 +1479,17 @@ mod tests { use crate::message::Message; use crate::test_utils::{self, TestContext}; + #[test] + fn test_contact_id_values() { + // Some FFI users need to have the values of these fixed, how naughty. But let's + // make sure we don't modify them anyway. + assert_eq!(ContactId::UNDEFINED.to_u32(), 0); + assert_eq!(ContactId::SELF.to_u32(), 1); + assert_eq!(ContactId::INFO.to_u32(), 2); + assert_eq!(ContactId::DEVICE.to_u32(), 5); + assert_eq!(ContactId::LAST_SPECIAL.to_u32(), 9); + } + #[test] fn test_may_be_valid_addr() { assert_eq!(may_be_valid_addr(""), false);