about summary refs log tree commit diff
path: root/compiler/rustc_data_structures/src/small_str
diff options
context:
space:
mode:
authorTomasz Miąsko <tomasz.miasko@gmail.com>2022-03-03 00:00:00 +0000
committerTomasz Miąsko <tomasz.miasko@gmail.com>2022-03-04 16:57:34 +0100
commit725c11ef3c6a40e7d9a7c9a8ea65f72b9448d1e0 (patch)
tree9bfc7946be6a27fb5eaa6a67b8f23070945d6fc1 /compiler/rustc_data_structures/src/small_str
parentea0a31ff0c19c14583239848a7737e453aef3cee (diff)
downloadrust-725c11ef3c6a40e7d9a7c9a8ea65f72b9448d1e0.tar.gz
rust-725c11ef3c6a40e7d9a7c9a8ea65f72b9448d1e0.zip
Add SmallStr
Diffstat (limited to 'compiler/rustc_data_structures/src/small_str')
-rw-r--r--compiler/rustc_data_structures/src/small_str/tests.rs20
1 files changed, 20 insertions, 0 deletions
diff --git a/compiler/rustc_data_structures/src/small_str/tests.rs b/compiler/rustc_data_structures/src/small_str/tests.rs
new file mode 100644
index 00000000000..7635a9b7204
--- /dev/null
+++ b/compiler/rustc_data_structures/src/small_str/tests.rs
@@ -0,0 +1,20 @@
+use super::*;
+
+#[test]
+fn empty() {
+    let s = SmallStr::<1>::new();
+    assert!(s.empty());
+    assert_eq!("", s.as_str());
+    assert!(!s.spilled());
+}
+
+#[test]
+fn from_iter() {
+    let s = ["aa", "bb", "cc"].iter().collect::<SmallStr<6>>();
+    assert_eq!("aabbcc", s.as_str());
+    assert!(!s.spilled());
+
+    let s = ["aa", "bb", "cc", "dd"].iter().collect::<SmallStr<6>>();
+    assert_eq!("aabbccdd", s.as_str());
+    assert!(s.spilled());
+}