mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
cargo fmt
This commit is contained in:
@@ -422,3 +422,31 @@ pub fn match_single_do_co_mo_prefixed_field(
|
||||
) -> Option<String> {
|
||||
matchSinglePrefixedField(prefix, raw_text, ';', trim)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::{
|
||||
client::result::{ParsedClientResult, TextParsedRXingResult},
|
||||
RXingResult,
|
||||
};
|
||||
|
||||
use super::parse_result_with_parser;
|
||||
|
||||
#[test]
|
||||
fn test_single_parser() {
|
||||
let result: RXingResult = RXingResult::new(
|
||||
"text",
|
||||
vec![12, 23, 54, 23],
|
||||
Vec::new(),
|
||||
crate::BarcodeFormat::EAN_13,
|
||||
);
|
||||
let p_res = parse_result_with_parser(&result, |_| {
|
||||
Some(ParsedClientResult::TextResult(TextParsedRXingResult::new(
|
||||
String::from("parsed with parser"),
|
||||
String::from("en/us"),
|
||||
)))
|
||||
})
|
||||
.unwrap();
|
||||
assert_eq!(p_res.to_string(), "parsed with parser");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,11 +51,13 @@ pub fn parse(theRXingResult: &crate::RXingResult) -> Option<super::ParsedClientR
|
||||
return None;
|
||||
}
|
||||
let rawText = rawText_unstripped[WIFI_TEST.len()..].to_owned();
|
||||
let ssid = ResultParser::matchSinglePrefixedField("S:", &rawText, ';', false).unwrap_or_default();
|
||||
let ssid =
|
||||
ResultParser::matchSinglePrefixedField("S:", &rawText, ';', false).unwrap_or_default();
|
||||
if ssid.is_empty() {
|
||||
return None;
|
||||
}
|
||||
let pass = ResultParser::matchSinglePrefixedField("P:", &rawText, ';', false).unwrap_or_default();
|
||||
let pass =
|
||||
ResultParser::matchSinglePrefixedField("P:", &rawText, ';', false).unwrap_or_default();
|
||||
let n_type =
|
||||
if let Some(nt) = ResultParser::matchSinglePrefixedField("T:", &rawText, ';', false) {
|
||||
nt
|
||||
@@ -82,9 +84,12 @@ pub fn parse(theRXingResult: &crate::RXingResult) -> Option<super::ParsedClientR
|
||||
String::default()
|
||||
};
|
||||
|
||||
let identity = ResultParser::matchSinglePrefixedField("I:", &rawText, ';', false).unwrap_or_default();
|
||||
let anonymousIdentity = ResultParser::matchSinglePrefixedField("A:", &rawText, ';', false).unwrap_or_default();
|
||||
let eapMethod = ResultParser::matchSinglePrefixedField("E:", &rawText, ';', false).unwrap_or_default();
|
||||
let identity =
|
||||
ResultParser::matchSinglePrefixedField("I:", &rawText, ';', false).unwrap_or_default();
|
||||
let anonymousIdentity =
|
||||
ResultParser::matchSinglePrefixedField("A:", &rawText, ';', false).unwrap_or_default();
|
||||
let eapMethod =
|
||||
ResultParser::matchSinglePrefixedField("E:", &rawText, ';', false).unwrap_or_default();
|
||||
|
||||
Some(ParsedClientResult::WiFiResult(
|
||||
WifiParsedRXingResult::with_details(
|
||||
|
||||
Reference in New Issue
Block a user