Skip to content
Myr

testutil.rs

This file

Path

crates/searcher/src/testutil.rs

797 lines · 26.9 KiB · Rust

Last changed by

Not known.

History of this file

Take it

1use std::io::{self, Write};23use {4    bstr::ByteSlice,5    grep_matcher::{6        LineMatchKind, LineTerminator, Match, Matcher, NoCaptures, NoError,7    },8    regex::bytes::{Regex, RegexBuilder},9};1011use crate::{12    searcher::{BinaryDetection, Searcher, SearcherBuilder},13    sink::{Sink, SinkContext, SinkFinish, SinkMatch},14};1516/// A simple regex matcher.17///18/// This supports setting the matcher's line terminator configuration directly,19/// which we use for testing purposes. That is, the caller explicitly20/// determines whether the line terminator optimization is enabled. (In reality21/// this optimization is detected automatically by inspecting and possibly22/// modifying the regex itself.)23#[derive(Clone, Debug)]24pub(crate) struct RegexMatcher {25    regex: Regex,26    line_term: Option<LineTerminator>,27    every_line_is_candidate: bool,28}2930impl RegexMatcher {31    /// Create a new regex matcher.32    pub(crate) fn new(pattern: &str) -> RegexMatcher {33        let regex = RegexBuilder::new(pattern)34            .multi_line(true) // permits ^ and $ to match at \n boundaries35            .build()36            .unwrap();37        RegexMatcher { regex, line_term: None, every_line_is_candidate: false }38    }3940    /// Forcefully set the line terminator of this matcher.41    ///42    /// By default, this matcher has no line terminator set.43    pub(crate) fn set_line_term(44        &mut self,45        line_term: Option<LineTerminator>,46    ) -> &mut RegexMatcher {47        self.line_term = line_term;48        self49    }5051    /// Whether to return every line as a candidate or not.52    ///53    /// This forces searchers to handle the case of reporting a false positive.54    pub(crate) fn every_line_is_candidate(55        &mut self,56        yes: bool,57    ) -> &mut RegexMatcher {58        self.every_line_is_candidate = yes;59        self60    }61}6263impl Matcher for RegexMatcher {64    type Captures = NoCaptures;65    type Error = NoError;6667    fn find_at(68        &self,69        haystack: &[u8],70        at: usize,71    ) -> Result<Option<Match>, NoError> {72        Ok(self73            .regex74            .find_at(haystack, at)75            .map(|m| Match::new(m.start(), m.end())))76    }7778    fn new_captures(&self) -> Result<NoCaptures, NoError> {79        Ok(NoCaptures::new())80    }8182    fn line_terminator(&self) -> Option<LineTerminator> {83        self.line_term84    }8586    fn find_candidate_line(87        &self,88        haystack: &[u8],89    ) -> Result<Option<LineMatchKind>, NoError> {90        if self.every_line_is_candidate {91            assert!(self.line_term.is_some());92            if haystack.is_empty() {93                return Ok(None);94            }95            // Make it interesting and return the last byte in the current96            // line.97            let i = haystack98                .find_byte(self.line_term.unwrap().as_byte())99                .map(|i| i)100                .unwrap_or(haystack.len() - 1);101            Ok(Some(LineMatchKind::Candidate(i)))102        } else {103            Ok(self.shortest_match(haystack)?.map(LineMatchKind::Confirmed))104        }105    }106}107108/// An implementation of Sink that prints all available information.109///110/// This is useful for tests because it lets us easily confirm whether data111/// is being passed to Sink correctly.112#[derive(Clone, Debug)]113pub(crate) struct KitchenSink(Vec<u8>);114115impl KitchenSink {116    /// Create a new implementation of Sink that includes everything in the117    /// kitchen.118    pub(crate) fn new() -> KitchenSink {119        KitchenSink(vec![])120    }121122    /// Return the data written to this sink.123    pub(crate) fn as_bytes(&self) -> &[u8] {124        &self.0125    }126}127128impl Sink for KitchenSink {129    type Error = io::Error;130131    fn matched(132        &mut self,133        _searcher: &Searcher,134        mat: &SinkMatch<'_>,135    ) -> Result<bool, io::Error> {136        assert!(!mat.bytes().is_empty());137        assert!(mat.lines().count() >= 1);138139        let mut line_number = mat.line_number();140        let mut byte_offset = mat.absolute_byte_offset();141        for line in mat.lines() {142            if let Some(ref mut n) = line_number {143                write!(self.0, "{}:", n)?;144                *n += 1;145            }146147            write!(self.0, "{}:", byte_offset)?;148            byte_offset += line.len() as u64;149            self.0.write_all(line)?;150        }151        Ok(true)152    }153154    fn context(155        &mut self,156        _searcher: &Searcher,157        context: &SinkContext<'_>,158    ) -> Result<bool, io::Error> {159        assert!(!context.bytes().is_empty());160        assert!(context.lines().count() == 1);161162        if let Some(line_number) = context.line_number() {163            write!(self.0, "{}-", line_number)?;164        }165        write!(self.0, "{}-", context.absolute_byte_offset)?;166        self.0.write_all(context.bytes())?;167        Ok(true)168    }169170    fn context_break(171        &mut self,172        _searcher: &Searcher,173    ) -> Result<bool, io::Error> {174        self.0.write_all(b"--\n")?;175        Ok(true)176    }177178    fn finish(179        &mut self,180        _searcher: &Searcher,181        sink_finish: &SinkFinish,182    ) -> Result<(), io::Error> {183        writeln!(self.0, "")?;184        writeln!(self.0, "byte count:{}", sink_finish.byte_count())?;185        if let Some(offset) = sink_finish.binary_byte_offset() {186            writeln!(self.0, "binary offset:{}", offset)?;187        }188        Ok(())189    }190}191192/// A type for expressing tests on a searcher.193///194/// The searcher code has a lot of different code paths, mostly for the195/// purposes of optimizing a bunch of different use cases. The intent of the196/// searcher is to pick the best code path based on the configuration, which197/// means there is no obviously direct way to ask that a specific code path198/// be exercised. Thus, the purpose of this tester is to explicitly check as199/// many code paths that make sense.200///201/// The tester works by assuming you want to test all pertinent code paths.202/// These can be trimmed down as necessary via the various builder methods.203#[derive(Debug)]204pub(crate) struct SearcherTester {205    haystack: String,206    pattern: String,207    filter: Option<::regex::Regex>,208    print_labels: bool,209    expected_no_line_number: Option<String>,210    expected_with_line_number: Option<String>,211    expected_slice_no_line_number: Option<String>,212    expected_slice_with_line_number: Option<String>,213    by_line: bool,214    multi_line: bool,215    invert_match: bool,216    line_number: bool,217    binary: BinaryDetection,218    auto_heap_limit: bool,219    after_context: usize,220    before_context: usize,221    passthru: bool,222}223224impl SearcherTester {225    /// Create a new tester for testing searchers.226    pub(crate) fn new(haystack: &str, pattern: &str) -> SearcherTester {227        SearcherTester {228            haystack: haystack.to_string(),229            pattern: pattern.to_string(),230            filter: None,231            print_labels: false,232            expected_no_line_number: None,233            expected_with_line_number: None,234            expected_slice_no_line_number: None,235            expected_slice_with_line_number: None,236            by_line: true,237            multi_line: true,238            invert_match: false,239            line_number: true,240            binary: BinaryDetection::none(),241            auto_heap_limit: true,242            after_context: 0,243            before_context: 0,244            passthru: false,245        }246    }247248    /// Execute the test. If the test succeeds, then this returns successfully.249    /// If the test fails, then it panics with an informative message.250    pub(crate) fn test(&self) {251        // Check for configuration errors.252        if self.expected_no_line_number.is_none() {253            panic!("an 'expected' string with NO line numbers must be given");254        }255        if self.line_number && self.expected_with_line_number.is_none() {256            panic!(257                "an 'expected' string with line numbers must be given, \258                    or disable testing with line numbers"259            );260        }261262        let configs = self.configs();263        if configs.is_empty() {264            panic!("test configuration resulted in nothing being tested");265        }266        if self.print_labels {267            for config in &configs {268                let labels = vec![269                    format!("reader-{}", config.label),270                    format!("slice-{}", config.label),271                ];272                for label in &labels {273                    if self.include(label) {274                        println!("{}", label);275                    } else {276                        println!("{} (ignored)", label);277                    }278                }279            }280        }281        for config in &configs {282            let label = format!("reader-{}", config.label);283            if self.include(&label) {284                let got = config.search_reader(&self.haystack);285                assert_eq_printed!(config.expected_reader, got, "{}", label);286            }287288            let label = format!("slice-{}", config.label);289            if self.include(&label) {290                let got = config.search_slice(&self.haystack);291                assert_eq_printed!(config.expected_slice, got, "{}", label);292            }293        }294    }295296    /// Set a regex pattern to filter the tests that are run.297    ///298    /// By default, no filter is present. When a filter is set, only test299    /// configurations with a label matching the given pattern will be run.300    ///301    /// This is often useful when debugging tests, e.g., when you want to do302    /// printf debugging and only want one particular test configuration to303    /// execute.304    #[allow(dead_code)]305    pub(crate) fn filter(&mut self, pattern: &str) -> &mut SearcherTester {306        self.filter = Some(::regex::Regex::new(pattern).unwrap());307        self308    }309310    /// When set, the labels for all test configurations are printed before311    /// executing any test.312    ///313    /// Note that in order to see these in tests that aren't failing, you'll314    /// want to use `cargo test -- --nocapture`.315    #[allow(dead_code)]316    pub(crate) fn print_labels(&mut self, yes: bool) -> &mut SearcherTester {317        self.print_labels = yes;318        self319    }320321    /// Set the expected search results, without line numbers.322    pub(crate) fn expected_no_line_number(323        &mut self,324        exp: &str,325    ) -> &mut SearcherTester {326        self.expected_no_line_number = Some(exp.to_string());327        self328    }329330    /// Set the expected search results, with line numbers.331    pub(crate) fn expected_with_line_number(332        &mut self,333        exp: &str,334    ) -> &mut SearcherTester {335        self.expected_with_line_number = Some(exp.to_string());336        self337    }338339    /// Set the expected search results, without line numbers, when performing340    /// a search on a slice. When not present, `expected_no_line_number` is341    /// used instead.342    pub(crate) fn expected_slice_no_line_number(343        &mut self,344        exp: &str,345    ) -> &mut SearcherTester {346        self.expected_slice_no_line_number = Some(exp.to_string());347        self348    }349350    /// Set the expected search results, with line numbers, when performing a351    /// search on a slice. When not present, `expected_with_line_number` is352    /// used instead.353    #[allow(dead_code)]354    pub(crate) fn expected_slice_with_line_number(355        &mut self,356        exp: &str,357    ) -> &mut SearcherTester {358        self.expected_slice_with_line_number = Some(exp.to_string());359        self360    }361362    /// Whether to test search with line numbers or not.363    ///364    /// This is enabled by default. When enabled, the string that is expected365    /// when line numbers are present must be provided. Otherwise, the expected366    /// string isn't required.367    pub(crate) fn line_number(&mut self, yes: bool) -> &mut SearcherTester {368        self.line_number = yes;369        self370    }371372    /// Whether to test search using the line-by-line searcher or not.373    ///374    /// By default, this is enabled.375    pub(crate) fn by_line(&mut self, yes: bool) -> &mut SearcherTester {376        self.by_line = yes;377        self378    }379380    /// Whether to test search using the multi line searcher or not.381    ///382    /// By default, this is enabled.383    #[allow(dead_code)]384    pub(crate) fn multi_line(&mut self, yes: bool) -> &mut SearcherTester {385        self.multi_line = yes;386        self387    }388389    /// Whether to perform an inverted search or not.390    ///391    /// By default, this is disabled.392    pub(crate) fn invert_match(&mut self, yes: bool) -> &mut SearcherTester {393        self.invert_match = yes;394        self395    }396397    /// Whether to enable binary detection on all searches.398    ///399    /// By default, this is disabled.400    pub(crate) fn binary_detection(401        &mut self,402        detection: BinaryDetection,403    ) -> &mut SearcherTester {404        self.binary = detection;405        self406    }407408    /// Whether to automatically attempt to test the heap limit setting or not.409    ///410    /// By default, one of the test configurations includes setting the heap411    /// limit to its minimal value for normal operation, which checks that412    /// everything works even at the extremes. However, in some cases, the heap413    /// limit can (expectedly) alter the output slightly. For example, it can414    /// impact the number of bytes searched when performing binary detection.415    /// For convenience, it can be useful to disable the automatic heap limit416    /// test.417    pub(crate) fn auto_heap_limit(418        &mut self,419        yes: bool,420    ) -> &mut SearcherTester {421        self.auto_heap_limit = yes;422        self423    }424425    /// Set the number of lines to include in the "after" context.426    ///427    /// The default is `0`, which is equivalent to not printing any context.428    pub(crate) fn after_context(429        &mut self,430        lines: usize,431    ) -> &mut SearcherTester {432        self.after_context = lines;433        self434    }435436    /// Set the number of lines to include in the "before" context.437    ///438    /// The default is `0`, which is equivalent to not printing any context.439    pub(crate) fn before_context(440        &mut self,441        lines: usize,442    ) -> &mut SearcherTester {443        self.before_context = lines;444        self445    }446447    /// Whether to enable the "passthru" feature or not.448    ///449    /// When passthru is enabled, it effectively treats all non-matching lines450    /// as contextual lines. In other words, enabling this is akin to451    /// requesting an unbounded number of before and after contextual lines.452    ///453    /// This is disabled by default.454    pub(crate) fn passthru(&mut self, yes: bool) -> &mut SearcherTester {455        self.passthru = yes;456        self457    }458459    /// Return the minimum size of a buffer required for a successful search.460    ///461    /// Generally, this corresponds to the maximum length of a line (including462    /// its terminator), but if context settings are enabled, then this must463    /// include the sum of the longest N lines.464    ///465    /// Note that this must account for whether the test is using multi line466    /// search or not, since multi line search requires being able to fit the467    /// entire haystack into memory.468    fn minimal_heap_limit(&self, multi_line: bool) -> usize {469        if multi_line {470            1 + self.haystack.len()471        } else if self.before_context == 0 && self.after_context == 0 {472            1 + self.haystack.lines().map(|s| s.len()).max().unwrap_or(0)473        } else {474            let mut lens: Vec<usize> =475                self.haystack.lines().map(|s| s.len()).collect();476            lens.sort();477            lens.reverse();478479            let context_count = if self.passthru {480                self.haystack.lines().count()481            } else {482                // Why do we add 2 here? Well, we need to add 1 in order to483                // have room to search at least one line. We add another484                // because the implementation will occasionally include485                // an additional line when handling the context. There's486                // no particularly good reason, other than keeping the487                // implementation simple.488                2 + self.before_context + self.after_context489            };490491            // We add 1 to each line since `str::lines` doesn't include the492            // line terminator.493            lens.into_iter()494                .take(context_count)495                .map(|len| len + 1)496                .sum::<usize>()497        }498    }499500    /// Returns true if and only if the given label should be included as part501    /// of executing `test`.502    ///503    /// Inclusion is determined by the filter specified. If no filter has been504    /// given, then this always returns `true`.505    fn include(&self, label: &str) -> bool {506        let re = match self.filter {507            None => return true,508            Some(ref re) => re,509        };510        re.is_match(label)511    }512513    /// Configs generates a set of all search configurations that should be514    /// tested. The configs generated are based on the configuration in this515    /// builder.516    fn configs(&self) -> Vec<TesterConfig> {517        let mut configs = vec![];518519        let matcher = RegexMatcher::new(&self.pattern);520        let mut builder = SearcherBuilder::new();521        builder522            .line_number(false)523            .invert_match(self.invert_match)524            .binary_detection(self.binary.clone())525            .after_context(self.after_context)526            .before_context(self.before_context)527            .passthru(self.passthru);528529        if self.by_line {530            let mut matcher = matcher.clone();531            let mut builder = builder.clone();532533            let expected_reader =534                self.expected_no_line_number.as_ref().unwrap().to_string();535            let expected_slice = match self.expected_slice_no_line_number {536                None => expected_reader.clone(),537                Some(ref e) => e.to_string(),538            };539            configs.push(TesterConfig {540                label: "byline-noterm-nonumber".to_string(),541                expected_reader: expected_reader.clone(),542                expected_slice: expected_slice.clone(),543                builder: builder.clone(),544                matcher: matcher.clone(),545            });546547            if self.auto_heap_limit {548                builder.heap_limit(Some(self.minimal_heap_limit(false)));549                configs.push(TesterConfig {550                    label: "byline-noterm-nonumber-heaplimit".to_string(),551                    expected_reader: expected_reader.clone(),552                    expected_slice: expected_slice.clone(),553                    builder: builder.clone(),554                    matcher: matcher.clone(),555                });556                builder.heap_limit(None);557            }558559            matcher.set_line_term(Some(LineTerminator::byte(b'\n')));560            configs.push(TesterConfig {561                label: "byline-term-nonumber".to_string(),562                expected_reader: expected_reader.clone(),563                expected_slice: expected_slice.clone(),564                builder: builder.clone(),565                matcher: matcher.clone(),566            });567568            matcher.every_line_is_candidate(true);569            configs.push(TesterConfig {570                label: "byline-term-nonumber-candidates".to_string(),571                expected_reader: expected_reader.clone(),572                expected_slice: expected_slice.clone(),573                builder: builder.clone(),574                matcher: matcher.clone(),575            });576        }577        if self.by_line && self.line_number {578            let mut matcher = matcher.clone();579            let mut builder = builder.clone();580581            let expected_reader =582                self.expected_with_line_number.as_ref().unwrap().to_string();583            let expected_slice = match self.expected_slice_with_line_number {584                None => expected_reader.clone(),585                Some(ref e) => e.to_string(),586            };587588            builder.line_number(true);589            configs.push(TesterConfig {590                label: "byline-noterm-number".to_string(),591                expected_reader: expected_reader.clone(),592                expected_slice: expected_slice.clone(),593                builder: builder.clone(),594                matcher: matcher.clone(),595            });596597            matcher.set_line_term(Some(LineTerminator::byte(b'\n')));598            configs.push(TesterConfig {599                label: "byline-term-number".to_string(),600                expected_reader: expected_reader.clone(),601                expected_slice: expected_slice.clone(),602                builder: builder.clone(),603                matcher: matcher.clone(),604            });605606            matcher.every_line_is_candidate(true);607            configs.push(TesterConfig {608                label: "byline-term-number-candidates".to_string(),609                expected_reader: expected_reader.clone(),610                expected_slice: expected_slice.clone(),611                builder: builder.clone(),612                matcher: matcher.clone(),613            });614        }615        if self.multi_line {616            let mut builder = builder.clone();617            let expected_slice = match self.expected_slice_no_line_number {618                None => {619                    self.expected_no_line_number.as_ref().unwrap().to_string()620                }621                Some(ref e) => e.to_string(),622            };623624            builder.multi_line(true);625            configs.push(TesterConfig {626                label: "multiline-nonumber".to_string(),627                expected_reader: expected_slice.clone(),628                expected_slice: expected_slice.clone(),629                builder: builder.clone(),630                matcher: matcher.clone(),631            });632633            if self.auto_heap_limit {634                builder.heap_limit(Some(self.minimal_heap_limit(true)));635                configs.push(TesterConfig {636                    label: "multiline-nonumber-heaplimit".to_string(),637                    expected_reader: expected_slice.clone(),638                    expected_slice: expected_slice.clone(),639                    builder: builder.clone(),640                    matcher: matcher.clone(),641                });642                builder.heap_limit(None);643            }644        }645        if self.multi_line && self.line_number {646            let mut builder = builder.clone();647            let expected_slice = match self.expected_slice_with_line_number {648                None => self649                    .expected_with_line_number650                    .as_ref()651                    .unwrap()652                    .to_string(),653                Some(ref e) => e.to_string(),654            };655656            builder.multi_line(true);657            builder.line_number(true);658            configs.push(TesterConfig {659                label: "multiline-number".to_string(),660                expected_reader: expected_slice.clone(),661                expected_slice: expected_slice.clone(),662                builder: builder.clone(),663                matcher: matcher.clone(),664            });665666            builder.heap_limit(Some(self.minimal_heap_limit(true)));667            configs.push(TesterConfig {668                label: "multiline-number-heaplimit".to_string(),669                expected_reader: expected_slice.clone(),670                expected_slice: expected_slice.clone(),671                builder: builder.clone(),672                matcher: matcher.clone(),673            });674            builder.heap_limit(None);675        }676        configs677    }678}679680#[derive(Debug)]681struct TesterConfig {682    label: String,683    expected_reader: String,684    expected_slice: String,685    builder: SearcherBuilder,686    matcher: RegexMatcher,687}688689impl TesterConfig {690    /// Execute a search using a reader. This exercises the incremental search691    /// strategy, where the entire contents of the corpus aren't necessarily692    /// in memory at once.693    fn search_reader(&self, haystack: &str) -> String {694        let mut sink = KitchenSink::new();695        let mut searcher = self.builder.build();696        let result = searcher.search_reader(697            &self.matcher,698            haystack.as_bytes(),699            &mut sink,700        );701        if let Err(err) = result {702            let label = format!("reader-{}", self.label);703            panic!("error running '{}': {}", label, err);704        }705        String::from_utf8(sink.as_bytes().to_vec()).unwrap()706    }707708    /// Execute a search using a slice. This exercises the search routines that709    /// have the entire contents of the corpus in memory at one time.710    fn search_slice(&self, haystack: &str) -> String {711        let mut sink = KitchenSink::new();712        let mut searcher = self.builder.build();713        let result = searcher.search_slice(714            &self.matcher,715            haystack.as_bytes(),716            &mut sink,717        );718        if let Err(err) = result {719            let label = format!("slice-{}", self.label);720            panic!("error running '{}': {}", label, err);721        }722        String::from_utf8(sink.as_bytes().to_vec()).unwrap()723    }724}725726#[cfg(test)]727mod tests {728    use super::*;729730    fn m(start: usize, end: usize) -> Match {731        Match::new(start, end)732    }733734    #[test]735    fn empty_line1() {736        let haystack = b"";737        let matcher = RegexMatcher::new(r"^$");738739        assert_eq!(matcher.find_at(haystack, 0), Ok(Some(m(0, 0))));740    }741742    #[test]743    fn empty_line2() {744        let haystack = b"\n";745        let matcher = RegexMatcher::new(r"^$");746747        assert_eq!(matcher.find_at(haystack, 0), Ok(Some(m(0, 0))));748        assert_eq!(matcher.find_at(haystack, 1), Ok(Some(m(1, 1))));749    }750751    #[test]752    fn empty_line3() {753        let haystack = b"\n\n";754        let matcher = RegexMatcher::new(r"^$");755756        assert_eq!(matcher.find_at(haystack, 0), Ok(Some(m(0, 0))));757        assert_eq!(matcher.find_at(haystack, 1), Ok(Some(m(1, 1))));758        assert_eq!(matcher.find_at(haystack, 2), Ok(Some(m(2, 2))));759    }760761    #[test]762    fn empty_line4() {763        let haystack = b"a\n\nb\n";764        let matcher = RegexMatcher::new(r"^$");765766        assert_eq!(matcher.find_at(haystack, 0), Ok(Some(m(2, 2))));767        assert_eq!(matcher.find_at(haystack, 1), Ok(Some(m(2, 2))));768        assert_eq!(matcher.find_at(haystack, 2), Ok(Some(m(2, 2))));769        assert_eq!(matcher.find_at(haystack, 3), Ok(Some(m(5, 5))));770        assert_eq!(matcher.find_at(haystack, 4), Ok(Some(m(5, 5))));771        assert_eq!(matcher.find_at(haystack, 5), Ok(Some(m(5, 5))));772    }773774    #[test]775    fn empty_line5() {776        let haystack = b"a\n\nb\nc";777        let matcher = RegexMatcher::new(r"^$");778779        assert_eq!(matcher.find_at(haystack, 0), Ok(Some(m(2, 2))));780        assert_eq!(matcher.find_at(haystack, 1), Ok(Some(m(2, 2))));781        assert_eq!(matcher.find_at(haystack, 2), Ok(Some(m(2, 2))));782        assert_eq!(matcher.find_at(haystack, 3), Ok(None));783        assert_eq!(matcher.find_at(haystack, 4), Ok(None));784        assert_eq!(matcher.find_at(haystack, 5), Ok(None));785        assert_eq!(matcher.find_at(haystack, 6), Ok(None));786    }787788    #[test]789    fn empty_line6() {790        let haystack = b"a\n";791        let matcher = RegexMatcher::new(r"^$");792793        assert_eq!(matcher.find_at(haystack, 0), Ok(Some(m(2, 2))));794        assert_eq!(matcher.find_at(haystack, 1), Ok(Some(m(2, 2))));795        assert_eq!(matcher.find_at(haystack, 2), Ok(Some(m(2, 2))));796    }797}