diff options
author | Anthony Ramine <n.oxyde@gmail.com> | 2018-01-19 13:18:56 +0100 |
---|---|---|
committer | Anthony Ramine <n.oxyde@gmail.com> | 2018-01-20 15:36:24 +0100 |
commit | ea924e398faafc29fafa83312e87410a3575f723 (patch) | |
tree | 1e619d3e640c9b56cf4753fe5683e27bd97811a0 /components/net_traits/tests/image.rs | |
parent | 697b9e2b87147a0f3767226c52097549d65b96da (diff) | |
download | servo-ea924e398faafc29fafa83312e87410a3575f723.tar.gz servo-ea924e398faafc29fafa83312e87410a3575f723.zip |
Merge net_traits and net_traits_tests
Diffstat (limited to 'components/net_traits/tests/image.rs')
-rw-r--r-- | components/net_traits/tests/image.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/components/net_traits/tests/image.rs b/components/net_traits/tests/image.rs new file mode 100644 index 00000000000..238fae97050 --- /dev/null +++ b/components/net_traits/tests/image.rs @@ -0,0 +1,26 @@ +/* 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/. */ + +extern crate net_traits; + +use net_traits::image::base::detect_image_format; + +#[test] +fn test_supported_images() { + let gif1 = [b'G', b'I', b'F', b'8', b'7', b'a']; + let gif2 = [b'G', b'I', b'F', b'8', b'9', b'a']; + let jpeg = [0xff, 0xd8, 0xff]; + let png = [0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A]; + let bmp = [0x42, 0x4D]; + let ico = [0x00, 0x00, 0x01, 0x00]; + let junk_format = [0x01, 0x02, 0x03, 0x04, 0x05]; + + assert!(detect_image_format(&gif1).is_ok()); + assert!(detect_image_format(&gif2).is_ok()); + assert!(detect_image_format(&jpeg).is_ok()); + assert!(detect_image_format(&png).is_ok()); + assert!(detect_image_format(&bmp).is_ok()); + assert!(detect_image_format(&ico).is_ok()); + assert!(detect_image_format(&junk_format).is_err()); +} |