From 43c46090cf294788fb25e4426798f4170eca62f4 Mon Sep 17 00:00:00 2001 From: Tim Neumann Date: Tue, 16 Feb 2016 21:10:32 +0100 Subject: [PATCH] add XHR::SetRequestHeader Step 3 unit test --- tests/unit/script/dom/xmlhttprequest.rs | 27 +++++++++++++++++++++++++ tests/unit/script/lib.rs | 1 + 2 files changed, 28 insertions(+) create mode 100644 tests/unit/script/dom/xmlhttprequest.rs diff --git a/tests/unit/script/dom/xmlhttprequest.rs b/tests/unit/script/dom/xmlhttprequest.rs new file mode 100644 index 00000000000..f9d4ebc25e8 --- /dev/null +++ b/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"); +} diff --git a/tests/unit/script/lib.rs b/tests/unit/script/lib.rs index fd5bea0f718..8270d8542d7 100644 --- a/tests/unit/script/lib.rs +++ b/tests/unit/script/lib.rs @@ -11,4 +11,5 @@ extern crate util; #[cfg(test)] mod dom { mod bindings; mod blob; + mod xmlhttprequest; }