summaryrefslogtreecommitdiff
path: root/src/fixed_string/test.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/fixed_string/test.rs')
-rw-r--r--src/fixed_string/test.rs43
1 files changed, 43 insertions, 0 deletions
diff --git a/src/fixed_string/test.rs b/src/fixed_string/test.rs
new file mode 100644
index 0000000..1e3be42
--- /dev/null
+++ b/src/fixed_string/test.rs
@@ -0,0 +1,43 @@
+// Copyright 2024 Gabriel Bjørnager Jensen.
+//
+// This file is part of bzipper.
+//
+// bzipper is free software: you can redistribute
+// it and/or modify it under the terms of the GNU
+// Lesser General Public License as published by
+// the Free Software Foundation, either version 3
+// of the License, or (at your option) any later
+// version.
+//
+// bzipper is distributed in the hope that it will
+// be useful, but WITHOUT ANY WARRANTY; without
+// even the implied warranty of MERCHANTABILITY or
+// FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Less-
+// er General Public License along with bzipper. If
+// not, see <https://www.gnu.org/licenses/>.
+
+use crate::FixedString;
+
+use std::cmp::Ordering;
+
+#[test]
+fn test_fixed_string() {
+ let str0 = FixedString::<0xC>::new("Hello there!").unwrap();
+ let str1 = FixedString::<0xE>::new("MEIN_GRO\u{1E9E}_GOTT").unwrap();
+ let str2 = FixedString::<0x5>::new("Hello").unwrap();
+
+ assert_eq!(str0.partial_cmp(&str0), Some(Ordering::Equal));
+ assert_eq!(str0.partial_cmp(&str1), Some(Ordering::Less));
+ assert_eq!(str0.partial_cmp(&str2), Some(Ordering::Greater));
+
+ assert_eq!(str1.partial_cmp(&str0), Some(Ordering::Greater));
+ assert_eq!(str1.partial_cmp(&str1), Some(Ordering::Equal));
+ assert_eq!(str1.partial_cmp(&str2), Some(Ordering::Greater));
+
+ assert_eq!(str2.partial_cmp(&str0), Some(Ordering::Less));
+ assert_eq!(str2.partial_cmp(&str1), Some(Ordering::Less));
+ assert_eq!(str2.partial_cmp(&str2), Some(Ordering::Equal));
+}