about summary refs log tree commit diff
path: root/src/libcoretest
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2014-12-24 06:31:13 +0000
committerbors <bors@rust-lang.org>2014-12-24 06:31:13 +0000
commite64a8193b02ce72ef183274994a25eae281cb89c (patch)
tree567f36abeae55ab43a31ec2391de0beedef7ffc9 /src/libcoretest
parent96a3c7c6a051ab2f5fc01fe9e686f7fffcc87c61 (diff)
parente82215d4e28cc8376a3623673c00f1f65f588927 (diff)
downloadrust-e64a8193b02ce72ef183274994a25eae281cb89c.tar.gz
rust-e64a8193b02ce72ef183274994a25eae281cb89c.zip
auto merge of #19858 : nick29581/rust/ranges, r=aturon
Closes #19794

r? @aturon for the first patch
r? @nikomatsakis for the rest
Diffstat (limited to 'src/libcoretest')
-rw-r--r--src/libcoretest/ops.rs33
1 files changed, 33 insertions, 0 deletions
diff --git a/src/libcoretest/ops.rs b/src/libcoretest/ops.rs
index 447fd1c699d..a8889ce9e34 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,35 @@ 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 };
+    let mut count = 0u;
+    for (i, ri) in r.enumerate() {
+        assert!(ri == i + 2);
+        assert!(ri >= 2u && ri < 10u);
+        count += 1;
+    }
+    assert!(count == 8);
+}
+
+#[test]
+fn test_range_from() {
+    let r = RangeFrom { start: 2u };
+    let mut count = 0u;
+    for (i, ri) in r.take(10).enumerate() {
+        assert!(ri == i + 2);
+        assert!(ri >= 2u && ri < 12u);
+        count += 1;
+    }
+    assert!(count == 10);
+}
+
+#[test]
+fn test_full_range() {
+    // Not much to test.
+    let _ = FullRange;
+}