-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
698 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,5 @@ | ||
//! Tests for plain code files using legacy VSI fingerprints. | ||
use std::io::Cursor; | ||
|
||
use pretty_assertions::assert_eq; | ||
|
||
use fingerprint::*; | ||
|
@@ -11,7 +9,7 @@ use fingerprint::*; | |
/// | ||
/// ```ignore | ||
/// let content = b"hello world"; | ||
/// let combined = Combined::from_stream(&mut Cursor::new(content)).expect("fingerprint"); | ||
/// let combined = Combined::from_buffer(&content).expect("fingerprint"); | ||
/// assert_fingerprint_eq!(Kind::RawSha256, content, combined); | ||
/// assert_fingerprint_eq!(Kind::CommentStrippedSha256, content, combined); | ||
/// ``` | ||
|
@@ -69,15 +67,15 @@ fn combined_getters() { | |
#[test] | ||
fn fingerprints_binary_file() { | ||
let content = vec![1, 2, 3, 0, 1, 2, 3]; | ||
let combined = Combined::from_stream(&mut Cursor::new(content.clone())).expect("fingerprint"); | ||
let combined = Combined::from_buffer(&content).expect("fingerprint"); | ||
assert_fingerprint_eq!(Kind::RawSha256, &content, combined); | ||
assert_fingerprint_eq!(Kind::CommentStrippedSha256, None, combined); | ||
} | ||
|
||
#[test] | ||
fn fingerprints_text_file() { | ||
let content = b"hello world"; | ||
let combined = Combined::from_stream(&mut Cursor::new(content)).expect("fingerprint"); | ||
let combined = Combined::from_buffer(content).expect("fingerprint"); | ||
assert_fingerprint_eq!(Kind::RawSha256, content, combined); | ||
assert_fingerprint_eq!(Kind::CommentStrippedSha256, content, combined); | ||
} | ||
|
@@ -88,7 +86,7 @@ fn fingerprints_text_file_stripping_cr() { | |
let content_cs = b"hello world\nanother line\na final line"; | ||
let without_cr = b"hello world\nanother line\na final line\n"; | ||
|
||
let combined = Combined::from_stream(&mut Cursor::new(content)).expect("fingerprint"); | ||
let combined = Combined::from_buffer(content).expect("fingerprint"); | ||
assert_fingerprint_eq!(Kind::RawSha256, without_cr, combined); | ||
assert_fingerprint_eq!(Kind::CommentStrippedSha256, content_cs, combined); | ||
} | ||
|
@@ -97,15 +95,15 @@ fn fingerprints_text_file_stripping_cr() { | |
fn fingerprints_binary_file_appearing_as_text() { | ||
// Sourced from `[email protected]:chromium/chromium.git` at `tools/origin_trials/eftest.key` on commit 49249345609d505c8bb8b0b5a42ff4b68b9e6d41. | ||
let content = include_bytes!("../../testdata/eftest.key"); | ||
let combined = Combined::from_stream(&mut Cursor::new(content)).expect("fingerprint"); | ||
let combined = Combined::from_buffer(content).expect("fingerprint"); | ||
assert_fingerprint_eq!(Kind::RawSha256, content, combined); | ||
assert_fingerprint_eq!(Kind::CommentStrippedSha256, None, combined); | ||
} | ||
|
||
#[test] | ||
fn comment_stripped_does_not_fingerprint_binary_file() { | ||
let content = vec![1, 2, 3, 0, 1, 2, 3]; | ||
let combined = Combined::from_stream(&mut Cursor::new(content)).expect("fingerprint"); | ||
let combined = Combined::from_buffer(content).expect("fingerprint"); | ||
assert_fingerprint_eq!(Kind::CommentStrippedSha256, None, combined); | ||
} | ||
|
||
|
@@ -123,7 +121,7 @@ int main() { | |
} | ||
"#; | ||
|
||
let combined = Combined::from_stream(&mut Cursor::new(content)).expect("fingerprint"); | ||
let combined = Combined::from_buffer(content).expect("fingerprint"); | ||
let expected = Content::new( | ||
hex::decode("44fc8f68ab633c7ca0240a66e4ff038c0f2412fe69d14b6f052556edaa1b9160") | ||
.expect("decode hex literal"), | ||
|
Oops, something went wrong.