mkleen commented on code in PR #22358:
URL: https://github.com/apache/datafusion/pull/22358#discussion_r3273597225
##########
datafusion/common/src/heap_size.rs:
##########
@@ -558,4 +589,173 @@ mod tests {
assert_eq!(heap_size, heap_size_with_clones);
}
+
+ #[test]
+ fn test_arc_dyn() {
+ let a1: Arc<dyn DFHeapSize> = Arc::new(String::from("hello"));
+ let baseline = size(&a1);
+
+ let a2 = Arc::clone(&a1);
+ let mut ctx = DFHeapSizeCtx::default();
+ let with_clones = a1.heap_size(&mut ctx) + a2.heap_size(&mut ctx);
+ assert_eq!(baseline, with_clones);
+ }
+
+ #[test]
+ fn test_primitives() {
+ assert_eq!(size(&true), 0);
+ assert_eq!(size(&0u8), 0);
+ assert_eq!(size(&0u16), 0);
+ assert_eq!(size(&0u32), 0);
+ assert_eq!(size(&0u64), 0);
+ assert_eq!(size(&0usize), 0);
+ assert_eq!(size(&0i8), 0);
+ assert_eq!(size(&0i16), 0);
+ assert_eq!(size(&0i32), 0);
+ assert_eq!(size(&0i64), 0);
+ assert_eq!(size(&0i128), 0);
+ assert_eq!(size(&i256::ZERO), 0);
+ assert_eq!(size(&0f32), 0);
+ assert_eq!(size(&0f64), 0);
+ assert_eq!(size(&f16::from_f32(0.0)), 0);
+ }
+
+ #[test]
+ fn test_string() {
+ let mut s = String::with_capacity(32);
+ s.push_str("hello");
+ assert_eq!(size(&s), 32);
+
+ let empty = String::new();
+ assert_eq!(size(&empty), 0);
+ }
+
+ #[test]
+ fn test_str() {
+ let s: &str = "hello";
Review Comment:
Ok, this makes sense. let's remove this test.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]