Skip to content

Commit

Permalink
add XHR::SetRequestHeader Step 3 unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
TimNN committed Feb 23, 2016
1 parent fac4c31 commit 43c4609
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
27 changes: 27 additions & 0 deletions tests/unit/script/dom/xmlhttprequest.rs
@@ -0,0 +1,27 @@
/* 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::xmlhttprequest::trim_http_whitespace;

#[test]
fn test_trim_http_whitespace() {
fn test_trim(in_: &[u8], out: &[u8]) {
let b = trim_http_whitespace(in_);
assert_eq!(b, out);
}

test_trim(b"", b"");

test_trim(b" ", b"");
test_trim(b"a", b"a");
test_trim(b" a", b"a");
test_trim(b"a ", b"a");
test_trim(b" a ", b"a");

test_trim(b"\t", b"");
test_trim(b"a", b"a");
test_trim(b"\ta", b"a");
test_trim(b"a\t", b"a");
test_trim(b"\ta\t", b"a");
}
1 change: 1 addition & 0 deletions tests/unit/script/lib.rs
Expand Up @@ -11,4 +11,5 @@ extern crate util;
#[cfg(test)] mod dom {
mod bindings;
mod blob;
mod xmlhttprequest;
}

0 comments on commit 43c4609

Please sign in to comment.