MCPcopy Create free account
hub / github.com/apache/arrow-rs / test_strong_count

Function test_strong_count

arrow-buffer/src/buffer/immutable.rs:1058–1082  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1056
1057 #[test]
1058 fn test_strong_count() {
1059 let buffer = Buffer::from_iter(std::iter::repeat_n(0_u8, 100));
1060 assert_eq!(buffer.strong_count(), 1);
1061
1062 let buffer2 = buffer.clone();
1063 assert_eq!(buffer.strong_count(), 2);
1064
1065 let buffer3 = buffer2.clone();
1066 assert_eq!(buffer.strong_count(), 3);
1067
1068 drop(buffer);
1069 assert_eq!(buffer2.strong_count(), 2);
1070 assert_eq!(buffer3.strong_count(), 2);
1071
1072 // Strong count does not increase on move
1073 let capture = move || {
1074 assert_eq!(buffer3.strong_count(), 2);
1075 };
1076
1077 capture();
1078 assert_eq!(buffer2.strong_count(), 2);
1079
1080 drop(capture);
1081 assert_eq!(buffer2.strong_count(), 1);
1082 }
1083}

Callers

nothing calls this directly

Calls 2

from_iterFunction · 0.70
cloneMethod · 0.45

Tested by

no test coverage detected