Files
tubestation/servo/tests/unit/script/dom/blob.rs
Cullen Rhodes 44dc9f68ea servo: Merge #11329 - Report use statements that use {} with only one entry (from c-rhodes:11320); r=jdm
Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data:
- [X ] `./mach build -d` does not report any errors
- [X ] `./mach test-tidy --faster` does not report any errors
- [X ] These changes fix #11320  (github issue number if applicable).

Either:
- [X] There are tests for these changes OR
- [ ] These changes do not require tests because _____

Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process.

Source-Repo: https://github.com/servo/servo
Source-Revision: 2f9796fa696e9514280777398467696dd4f004b3
2016-05-27 07:11:17 -05:00

35 lines
996 B
Rust

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use script::dom::blob::DataSlice;
use std::sync::Arc;
#[test]
fn test_data_slice_without_start_end_should_match_buffer_size() {
let bytes = Arc::new(vec![1u8, 2u8, 3u8]);
let data = DataSlice::new(bytes, None, None);
assert_eq!(data.size(), 3);
}
#[test]
fn test_data_slice_should_prevent_reverse_bounds() {
let bytes = Arc::new(vec![1u8, 2, 3, 4, 5]);
let start = Some(3);
let end = Some(1);
let data = DataSlice::new(bytes, start, end);
assert_eq!(data.size(), 0);
}
#[test]
fn test_data_slice_should_respect_correct_bounds() {
let bytes = Arc::new(vec![1u8, 2, 3, 4, 5]);
let start = Some(1);
let end = Some(3);
let data = DataSlice::new(bytes, start, end);
let expected = [2u8, 3];
assert_eq!(&expected, data.get_bytes());
}