about summary refs log tree commit diff
path: root/src/libcoretest
diff options
context:
space:
mode:
authorNick Cameron <ncameron@mozilla.com>2014-12-13 16:58:48 +1300
committerNick Cameron <ncameron@mozilla.com>2014-12-24 09:12:45 +1300
commit21ea66f47ad059279628736b31a3a8bddd2710d3 (patch)
tree69fc30d89fadcfc69bea00673820d50209384408 /src/libcoretest
parent658529467d9d69ac9e09cacf98a6d61d781c2c76 (diff)
downloadrust-21ea66f47ad059279628736b31a3a8bddd2710d3.tar.gz
rust-21ea66f47ad059279628736b31a3a8bddd2710d3.zip
Add structs for ranges to core::ops.
Diffstat (limited to 'src/libcoretest')
-rw-r--r--src/libcoretest/ops.rs27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/libcoretest/ops.rs b/src/libcoretest/ops.rs
index 447fd1c699d..c4acef32ee8 100644
--- a/src/libcoretest/ops.rs
+++ b/src/libcoretest/ops.rs
@@ -9,6 +9,7 @@
 // except according to those terms.
 
 use test::Bencher;
+use core::ops::{Range, FullRange, RangeFrom};
 
 // Overhead of dtors
 
@@ -27,3 +28,29 @@ fn alloc_obj_with_dtor(b: &mut Bencher) {
         HasDtor { _x : 10 };
     })
 }
+
+// Test the Range structs without the syntactic sugar.
+
+#[test]
+fn test_range() {
+    let r = Range { start: 2u, end: 10 };
+    for (i, ri) in r.enumerate() {
+        assert!(ri == i + 2);
+        assert!(ri >= 2u && ri < 10u);
+    }
+}
+
+#[test]
+fn test_range_from() {
+    let r = RangeFrom { start: 2u };
+    for (i, ri) in r.take(10).enumerate() {
+        assert!(ri == i + 2);
+        assert!(ri >= 2u && ri < 12u);
+    }
+}
+
+#[test]
+fn test_full_range() {
+    // Not much to test.
+    let _ = FullRange;
+}