pub fn response_value(&mut self, format: Value, response_value_org: Value) -> bool {
        let mut format = format!("{}", format);
        let response_value = format!("{}", response_value_org);
        let passed: bool;

        if format.len() <= 6 {
            passed = format == response_value
        } else {
            passed = match format.get(0..3).unwrap() {
                "\"{{" => match format.get(format.len() - 3..format.len()).unwrap() {
                    "}}\"" => {
                        format.retain(|c| !c.is_whitespace());

                        match format.find(":") {
                            Some(colon_position) => match format.find("&&") {
                                Some(first_and_position) => {
                                    let comparison = format
                                        .get((first_and_position + 2)..(format.len() - 3))
                                        .unwrap();
                                    let types = format
                                        .get((colon_position + 1)..first_and_position)
                                        .unwrap();

                                    let variable_name = format.get(3..colon_position).unwrap();

                                    let type_checked = self.add_response_variable(
                                        variable_name,
                                        types,
                                        response_value_org,
                                    );

                                    if !type_checked {
                                        return type_checked;
                                    }

                                    let mut js_definitions = self.variables.get_js_definitions();
                                    js_definitions.push_str("if(");
                                    js_definitions.push_str(comparison);
                                    js_definitions
                                        .push_str(") {return true;} else {return false;}");

                                    let output = exec(&js_definitions);

                                    if output == "true" {
                                        true
                                    } else {
                                        false
                                    }
                                }
                                None => {
                                    let variable_name = format.get(3..colon_position).unwrap();
                                    let types =
                                        format.get((colon_position + 1)..format.len() - 3).unwrap();

                                    let type_checked = self.add_response_variable(
                                        variable_name,
                                        types,
                                        response_value_org,
                                    );

                                    type_checked
                                }
                            },
                            None => {
                                let types = format.get(3..(format.len() - 3)).unwrap().split("|");
                                let mut type_matched = false;

                                for var_type in types {
                                    let type_checked = type_check(var_type, &response_value_org);

                                    if type_checked {
                                        type_matched = true;
                                    }
                                }

                                type_matched
                            }
                        }
                    }
                    _ => format == response_value,
                },
                _ => format == response_value,
            };
        }

        self.log_assertion(passed, &format, &response_value);

        passed
    }
/// Matching a single value in the test case and actual response
Matching a single value in the test case and actual response
Matching a single value in the test case and actual response
pub fn response_value(&mut self, format: Value, response_value_org: Value) -> bool {
        let mut format = format!("{}", format);
        let response_value = format!("{}", response_value_org);
        let passed: bool;
        if format.len() <= 6 {
            passed = format == response_value
        } else {
            passed = match format.get(0..3).unwrap() {
                "\"{{" => match format.get(format.len() - 3..format.len()).unwrap() {
                    "}}\"" => {
                        format.retain(|c| !c.is_whitespace());
                        match format.find(":") {
                            Some(colon_position) => match format.find("&&") {
                                Some(first_and_position) => {
                                    let comparison = format
                                        .get((first_and_position + 2)..(format.len() - 3))
                                        .unwrap();
                                    let types = format
                                        .get((colon_position + 1)..first_and_position)
                                        .unwrap();
                                    let variable_name = format.get(3..colon_position).unwrap();
                                    let type_checked = self.add_response_variable(
                                        variable_name,
                                        types,
                                        response_value_org,
                                    );
                                    if !type_checked {
                                        return type_checked;
                                    }
                                    let mut js_definitions = self.variables.get_js_definitions();
                                    js_definitions.push_str("if(");
                                    js_definitions.push_str(comparison);
                                    js_definitions
                                        .push_str(") {return true;} else {return false;}");
                                    let output = exec(&js_definitions);
                                    if output == "true" {
                                        true
                                    } else {
                                        false
                                    }
                                }
                                None => {
                                    let variable_name = format.get(3..colon_position).unwrap();
                                    let types =
                                        format.get((colon_position + 1)..format.len() - 3).unwrap();
                                    let type_checked = self.add_response_variable(
                                        variable_name,
                                        types,
                                        response_value_org,
                                    );
                                    type_checked
                                }
                            },
                            None => {
                                let types = format.get(3..(format.len() - 3)).unwrap().split("|");
                                let mut type_matched = false;
                                for var_type in types {
                                    let type_checked = type_check(var_type, &response_value_org);
                                    if type_checked {
                                        type_matched = true;
                                    }
                                }
                                type_matched
                            }
                        }
                    }
                    _ => format == response_value,
                },
                _ => format == response_value,
            };
        }
        self.log_assertion(passed, &format, &response_value);
        passed
    }
pub fn response_value ( & mut self , format : Value , response_value_org : Value ) -> bool { let mut format = format ! ( " " format ) ; let response_value = format ! ( " " response_value_org ) ; let passed : bool ; if format . len ( ) <= 6 { passed = format == response_value } else { passed = match format . get ( 0 .. 3 ) . unwrap ( ) { " \" " => match format . get ( format . len ( ) - 3 .. format . len ( ) ) . unwrap ( ) { " \" " => { format . retain ( | c | ! c . is_whitespace ( ) ) ; match format . find ( " " ) { Some ( colon_position ) => match format . find ( " " ) { Some ( first_and_position ) => { let comparison = format . get ( ( first_and_position + 2 ) .. ( format . len ( ) - 3 ) ) . unwrap ( ) ; let types = format . get ( ( colon_position + 1 ) .. first_and_position ) . unwrap ( ) ; let variable_name = format . get ( 3 .. colon_position ) . unwrap ( ) ; let type_checked = self . add_response_variable ( variable_name , types , response_value_org , ) ; if ! type_checked { return type_checked ; } let mut js_definitions = self . variables . get_js_definitions ( ) ; js_definitions . push_str ( " " ) ; js_definitions . push_str ( comparison ) ; js_definitions . push_str ( " " ) ; let output = exec ( & js_definitions ) ; if output == " " { true } else { false } } None => { let variable_name = format . get ( 3 .. colon_position ) . unwrap ( ) ; let types = format . get ( ( colon_position + 1 ) .. format . len ( ) - 3 ) . unwrap ( ) ; let type_checked = self . add_response_variable ( variable_name , types , response_value_org , ) ; type_checked } } , None => { let types = format . get ( 3 .. ( format . len ( ) - 3 ) ) . unwrap ( ) . split ( " " ) ; let mut type_matched = false ; for var_type in types { let type_checked = type_check ( var_type , & response_value_org ) ; if type_checked { type_matched = true ; } } type_matched } } } _ => format == response_value , } , _ => format == response_value , } ; } self . log_assertion ( passed , & format , & response_value ) ; passed }
Matching a single value in the test case and actual response
Matching a single value in the test case and actual response
&mut self
format
Value
response_value_org
Value