Exemplo n.º 1
0
    def test7positive_number_zero_padding(self):
        """In this testcase the positive Integer equivalence class in combination with the zero padding, which represents the padding
        equivalence class, is tested."""
        match_context = MatchContext(b'00025537.21 uid=2')
        decimal_float_value_me = DecimalFloatValueModelElement(
            None, DecimalFloatValueModelElement.SIGN_TYPE_NONE,
            DecimalFloatValueModelElement.PAD_TYPE_ZERO,
            DecimalFloatValueModelElement.EXP_TYPE_NONE)
        match_element = decimal_float_value_me.get_match_element(
            None, match_context)
        self.assertNotEqual(match_element, None,
                            self.match_element_should_exist)
        self.assertEqual(match_element.get_match_string(), b'00025537.21',
                         self.match_element_unexpected_result)
        self.assertEqual(match_element.get_match_object(), 25537.21,
                         self.match_element_unexpected_value)

        match_context = MatchContext(self.positive_string)
        match_element = decimal_float_value_me.get_match_element(
            None, match_context)
        self.assertNotEqual(match_element, None,
                            self.match_element_should_exist)
        self.assertEqual(match_element.get_match_string(), b'25537.21',
                         self.match_element_unexpected_result)
        self.assertEqual(match_element.get_match_object(), 25537.21,
                         self.match_element_unexpected_value)
Exemplo n.º 2
0
    def test5sign_type_mandatory_none_padding(self):
        """This testcase represents the equivalence class of all numbers with a mandatory sign in combination with no padding. It unit
        the correctness of the Path usage for all integers with a mandatory sign without padding."""
        match_context = MatchContext(self.negative_string)
        decimal_float_value_me = DecimalFloatValueModelElement(
            None, DecimalFloatValueModelElement.SIGN_TYPE_MANDATORY,
            DecimalFloatValueModelElement.PAD_TYPE_NONE,
            DecimalFloatValueModelElement.EXP_TYPE_NONE)
        match_element = decimal_float_value_me.get_match_element(
            None, match_context)
        self.assertNotEqual(match_element, None,
                            self.match_element_should_exist)
        self.assertEqual(match_element.get_match_string(),
                         self.negative_number,
                         self.match_element_unexpected_result)
        self.assertEqual(match_element.get_match_object(), -25537.21,
                         self.match_element_unexpected_value)

        match_context = MatchContext(b'+25537 uid=2')
        match_element = decimal_float_value_me.get_match_element(
            None, match_context)
        self.assertNotEqual(match_element, None,
                            self.match_element_should_exist)
        self.assertEqual(match_element.get_match_string(), b'+25537',
                         self.match_element_unexpected_result)
        self.assertEqual(match_element.get_match_object(), 25537,
                         self.match_element_unexpected_value)
Exemplo n.º 3
0
    def test13get_match_element_match_context_input_validation(self):
        """Check if an exception is raised, when other classes than MatchContext are used in get_match_element."""
        model_element = DecimalFloatValueModelElement(self.id_)
        data = b"123.22"
        model_element.get_match_element(self.path, DummyMatchContext(data))
        model_element.get_match_element(self.path, MatchContext(data))

        self.assertRaises(AttributeError, model_element.get_match_element,
                          self.path, MatchElement(self.path, data, None, None))
        self.assertRaises(AttributeError, model_element.get_match_element,
                          self.path, data)
        self.assertRaises(AttributeError, model_element.get_match_element,
                          self.path, data.decode())
        self.assertRaises(AttributeError, model_element.get_match_element,
                          self.path, True)
        self.assertRaises(AttributeError, model_element.get_match_element,
                          self.path, 123)
        self.assertRaises(AttributeError, model_element.get_match_element,
                          self.path, 123.22)
        self.assertRaises(AttributeError, model_element.get_match_element,
                          self.path, None)
        self.assertRaises(AttributeError, model_element.get_match_element,
                          self.path, [])
        self.assertRaises(AttributeError, model_element.get_match_element,
                          self.path, {"key": MatchContext(data)})
        self.assertRaises(AttributeError, model_element.get_match_element,
                          self.path, set())
        self.assertRaises(AttributeError, model_element.get_match_element,
                          self.path, ())
        self.assertRaises(AttributeError, model_element.get_match_element,
                          self.path, model_element)
Exemplo n.º 4
0
    def test13mandatory_none_padding_exponent(self):
        match_context = MatchContext(b'+25537.21e10 uid=2')
        decimal_float_value_me = DecimalFloatValueModelElement(
            None, DecimalFloatValueModelElement.SIGN_TYPE_MANDATORY,
            DecimalFloatValueModelElement.PAD_TYPE_NONE,
            DecimalFloatValueModelElement.EXP_TYPE_MANDATORY)
        match_element = decimal_float_value_me.get_match_element(
            None, match_context)
        self.assertNotEqual(match_element, None,
                            self.match_element_should_exist)
        self.assertEqual(match_element.get_match_string(), b'+25537.21e10',
                         self.match_element_unexpected_result)
        self.assertEqual(match_element.get_match_object(),
                         25537.21 * math.pow(10, 10),
                         self.match_element_unexpected_value)

        match_context = MatchContext(b'+25537.21e uid=2')
        decimal_float_value_me = DecimalFloatValueModelElement(
            None, DecimalFloatValueModelElement.SIGN_TYPE_MANDATORY,
            DecimalFloatValueModelElement.PAD_TYPE_NONE,
            DecimalFloatValueModelElement.EXP_TYPE_MANDATORY)
        match_element = decimal_float_value_me.get_match_element(
            None, match_context)
        self.assertEqual(match_element, None,
                         self.match_element_should_not_exist)
Exemplo n.º 5
0
    def test9negative_number_blank_padding(self):
        """In this testcase the negative Integer equivalence class in combination with the blank character padding, which represents the
        padding equivalence class, is tested."""
        match_context = MatchContext(b'- 25537.21 uid=2')
        decimal_float_value_me = DecimalFloatValueModelElement(
            None, DecimalFloatValueModelElement.SIGN_TYPE_OPTIONAL,
            DecimalFloatValueModelElement.PAD_TYPE_BLANK,
            DecimalFloatValueModelElement.EXP_TYPE_NONE)
        match_element = decimal_float_value_me.get_match_element(
            None, match_context)
        self.assertNotEqual(match_element, None,
                            self.match_element_should_exist)
        self.assertEqual(match_element.get_match_string(), b'- 25537.21',
                         self.match_element_unexpected_result)
        self.assertEqual(match_element.get_match_object(), -25537.21,
                         self.match_element_unexpected_value)

        match_context = MatchContext(self.negative_string)
        match_element = decimal_float_value_me.get_match_element(
            None, match_context)
        self.assertNotEqual(match_element, None,
                            self.match_element_should_exist)
        self.assertEqual(match_element.get_match_string(),
                         self.negative_number,
                         self.match_element_unexpected_result)
        self.assertEqual(match_element.get_match_object(), -25537.21,
                         self.match_element_unexpected_value)
    def test12mandatory_zero_padding_no_match(self):
        """In this testcase the mandatory sign equivalence class in combination with the zero padding is tested with no match expected."""
        match_context = MatchContext(b'00025537.21 uid=2')
        decimal_float_value_me = DecimalFloatValueModelElement(
            None, DecimalFloatValueModelElement.SIGN_TYPE_MANDATORY, DecimalFloatValueModelElement.PAD_TYPE_ZERO,
            DecimalFloatValueModelElement.EXP_TYPE_NONE)
        match_element = decimal_float_value_me.get_match_element(None, match_context)
        self.assertEqual(match_element, None, self.match_element_should_not_exist)

        match_context = MatchContext(self.positive_string)
        match_element = decimal_float_value_me.get_match_element(None, match_context)
        self.assertEqual(match_element, None, self.match_element_should_not_exist)
    def test13mandatory_none_padding_exponent(self):
        """In this testcase the mandatory sign equivalence class in combination with the None padding and exponent type mandatory."""
        match_context = MatchContext(b'+25537.21e10 uid=2')
        decimal_float_value_me = DecimalFloatValueModelElement(
            None, DecimalFloatValueModelElement.SIGN_TYPE_MANDATORY, DecimalFloatValueModelElement.PAD_TYPE_NONE,
            DecimalFloatValueModelElement.EXP_TYPE_MANDATORY)
        match_element = decimal_float_value_me.get_match_element(None, match_context)
        self.assertNotEqual(match_element, None, self.match_element_should_exist)
        self.assertEqual(match_element.get_match_string(), b'+25537.21e10', self.match_element_unexpected_result)
        self.assertEqual(match_element.get_match_object(), 25537.21 * math.pow(10, 10), self.match_element_unexpected_value)

        match_context = MatchContext(b'+25537.21e uid=2')
        decimal_float_value_me = DecimalFloatValueModelElement(
            None, DecimalFloatValueModelElement.SIGN_TYPE_MANDATORY, DecimalFloatValueModelElement.PAD_TYPE_NONE,
            DecimalFloatValueModelElement.EXP_TYPE_MANDATORY)
        match_element = decimal_float_value_me.get_match_element(None, match_context)
        self.assertEqual(match_element, None, self.match_element_should_not_exist)
 def test6sign_type_mandatory_none_padding_no_match(self):
     """
     This testcase represents the equivalence class of all numbers with a mandatory sign in combination with no padding.
     It tests the correctness of the Path usage for all integers with a mandatory sign without padding, when no match is found.
     """
     match_context = MatchContext(self.positive_string)
     decimal_float_value_me = DecimalFloatValueModelElement(
         None, DecimalFloatValueModelElement.SIGN_TYPE_MANDATORY, DecimalFloatValueModelElement.PAD_TYPE_NONE,
         DecimalFloatValueModelElement.EXP_TYPE_NONE)
     match_element = decimal_float_value_me.get_match_element(None, match_context)
     self.assertEqual(match_element, None, self.match_element_should_not_exist)
 def test4negative_number_none_padding_no_match(self):
     """
     This testcase represents the equivalence class of negative numbers in combination with no padding.
     It tests the correctness of the path usage for all negative integers without padding, when no match is found.
     """
     match_context = MatchContext(b'- 25537.21 uid=2')
     decimal_float_value_me = DecimalFloatValueModelElement(
         None, DecimalFloatValueModelElement.SIGN_TYPE_NONE, DecimalFloatValueModelElement.PAD_TYPE_NONE,
         DecimalFloatValueModelElement.EXP_TYPE_NONE)
     match_element = decimal_float_value_me.get_match_element(None, match_context)
     self.assertEqual(match_element, None, self.match_element_should_not_exist)
 def test10negative_number_blank_padding_no_match(self):
     """
     In this testcase the negative Integer equivalence class in combination with the blank character padding is tested.
     No match expected.
     """
     match_context = MatchContext(b' -25537 uid=2')
     decimal_float_value_me = DecimalFloatValueModelElement(
         None, DecimalFloatValueModelElement.SIGN_TYPE_OPTIONAL, DecimalFloatValueModelElement.PAD_TYPE_BLANK,
         DecimalFloatValueModelElement.EXP_TYPE_NONE)
     match_element = decimal_float_value_me.get_match_element(None, match_context)
     self.assertEqual(match_element, None, self.match_element_should_not_exist)
Exemplo n.º 11
0
 def test8positive_number_zero_padding_no_match(self):
     """In this testcase the positive Integer equivalence class in combination with the zero padding, which represents the padding
     equivalence class, is tested with no match expected."""
     match_context = MatchContext(b' 00025537.21 uid=2')
     decimal_float_value_me = DecimalFloatValueModelElement(
         None, DecimalFloatValueModelElement.SIGN_TYPE_NONE,
         DecimalFloatValueModelElement.PAD_TYPE_ZERO,
         DecimalFloatValueModelElement.EXP_TYPE_NONE)
     match_element = decimal_float_value_me.get_match_element(
         None, match_context)
     self.assertEqual(match_element, None,
                      self.match_element_should_not_exist)
 def test3negative_number_none_padding(self):
     """
     This testcase represents the equivalence class of negative numbers in combination with no padding.
     It tests the correctness of the path usage for all negative integers without padding.
     """
     match_context = MatchContext(self.negative_string)
     decimal_float_value_me = DecimalFloatValueModelElement(
         None, DecimalFloatValueModelElement.SIGN_TYPE_OPTIONAL, DecimalFloatValueModelElement.PAD_TYPE_NONE,
         DecimalFloatValueModelElement.EXP_TYPE_NONE)
     match_element = decimal_float_value_me.get_match_element(None, match_context)
     self.assertNotEqual(match_element, None, self.match_element_should_exist)
     self.assertEqual(match_element.get_match_string(), self.negative_number, self.match_element_unexpected_result)
     self.assertEqual(match_element.get_match_object(), -25537.21, self.match_element_unexpected_value)
    def test11mandatory_zero_padding(self):
        """In this testcase the mandatory sign equivalence class in combination with the zero padding is tested."""
        match_context = MatchContext(b'+00025537.21 uid=2')
        decimal_float_value_me = DecimalFloatValueModelElement(
            None, DecimalFloatValueModelElement.SIGN_TYPE_MANDATORY, DecimalFloatValueModelElement.PAD_TYPE_ZERO,
            DecimalFloatValueModelElement.EXP_TYPE_NONE)
        match_element = decimal_float_value_me.get_match_element(None, match_context)
        self.assertNotEqual(match_element, None, self.match_element_should_exist)
        self.assertEqual(match_element.get_match_string(), b'+00025537.21', self.match_element_unexpected_result)
        self.assertEqual(match_element.get_match_object(), 25537.21, self.match_element_unexpected_value)

        match_context = MatchContext(b'-00025537.21 uid=2')
        match_element = decimal_float_value_me.get_match_element(None, match_context)
        self.assertNotEqual(match_element, None, self.match_element_should_exist)
        self.assertEqual(match_element.get_match_string(), b'-00025537.21', self.match_element_unexpected_result)
        self.assertEqual(match_element.get_match_object(), -25537.21, self.match_element_unexpected_value)

        match_context = MatchContext(b'+25537.21 uid=2')
        match_element = decimal_float_value_me.get_match_element(None, match_context)
        self.assertNotEqual(match_element, None, self.match_element_should_exist)
        self.assertEqual(match_element.get_match_string(), b'+25537.21', self.match_element_unexpected_result)
        self.assertEqual(match_element.get_match_object(), 25537.21, self.match_element_unexpected_value)
Exemplo n.º 14
0
    def test3get_match_element_default_values(self):
        """Test valid float values with default values of value_sign_type, value_pad_type and exponent_type."""
        decimal_float_value_me = DecimalFloatValueModelElement(
            self.id_, DecimalFloatValueModelElement.SIGN_TYPE_NONE,
            DecimalFloatValueModelElement.PAD_TYPE_NONE,
            DecimalFloatValueModelElement.EXP_TYPE_NONE)
        data = b"22.25 some string."
        value = b"22.25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 22.25, None)

        data = b"0.25 some string."
        value = b"0.25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 0.25, None)

        data = b"22 some string."
        value = b"22"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 22, None)

        data = b"22.12.2021 some string."
        value = b"22.12"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 22.12, None)

        data = b"22. some string"
        value = b"22."
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 22.0, None)

        data = b"0 some string"
        value = b"0"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 0, None)
Exemplo n.º 15
0
    def test6get_match_element_optional_zero_values_no_match(self):
        """Test not matching values with default values of value_sign_type, value_pad_type and exponent_type."""
        decimal_float_value_me = DecimalFloatValueModelElement(
            self.id_, DecimalFloatValueModelElement.SIGN_TYPE_OPTIONAL,
            DecimalFloatValueModelElement.PAD_TYPE_ZERO,
            DecimalFloatValueModelElement.EXP_TYPE_OPTIONAL)
        data = b"+22.25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"22,25"
        value = b"22"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 22, None)

        data = b".25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b" 25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"  25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"e+10"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)
Exemplo n.º 16
0
    def test4get_match_element_default_values_no_match(self):
        """Test not matching values with default values of value_sign_type, value_pad_type and exponent_type."""
        decimal_float_value_me = DecimalFloatValueModelElement(
            self.id_, DecimalFloatValueModelElement.SIGN_TYPE_NONE,
            DecimalFloatValueModelElement.PAD_TYPE_NONE,
            DecimalFloatValueModelElement.EXP_TYPE_NONE)
        data = b"+22.25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"-22.25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"22,25"
        value = b"22"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 22, None)

        data = b".25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"025"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"0025"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b" 25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"  25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"1e-5"
        value = b"1"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 1, None)

        data = b"e+10"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"1e+0"
        value = b"1"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 1, None)

        data = b"00"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)
Exemplo n.º 17
0
    def test8get_match_element_mandatory_blank_values_no_match(self):
        """Test not matching values with default values of value_sign_type, value_pad_type and exponent_type."""
        decimal_float_value_me = DecimalFloatValueModelElement(
            self.id_, DecimalFloatValueModelElement.SIGN_TYPE_MANDATORY,
            DecimalFloatValueModelElement.PAD_TYPE_BLANK,
            DecimalFloatValueModelElement.EXP_TYPE_MANDATORY)
        data = b"22.25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"+  22.25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"-  22.25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"+22,25"
        value = b"+22"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 22, None)

        data = b"22,25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"22.12.2021 some string."
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b".25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b" +25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b" -25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"025"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"0025"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"e+10"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)

        data = b"00"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_no_match_results(data, match_element, match_context)
Exemplo n.º 18
0
    def test7get_match_element_mandatory_blank_values(self):
        """Test valid float values with "mandatory" or "blank" values of value_sign_type, value_pad_type and exponent_type."""
        decimal_float_value_me = DecimalFloatValueModelElement(
            self.id_, DecimalFloatValueModelElement.SIGN_TYPE_MANDATORY,
            DecimalFloatValueModelElement.PAD_TYPE_BLANK,
            DecimalFloatValueModelElement.EXP_TYPE_MANDATORY)
        data = b"+22.25 some string."
        value = b"+22.25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 22.25, None)

        data = b"-22.25 some string."
        value = b"-22.25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, -22.25, None)

        data = b"+0.25 some string."
        value = b"+0.25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 0.25, None)

        data = b"+22 some string."
        value = b"+22"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 22, None)

        data = b"+22. some string"
        value = b"+22."
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 22.0, None)

        data = b"+ 25 some string"
        value = b"+ 25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 25, None)

        data = b"- 25 some string"
        value = b"- 25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, -25, None)

        data = b"+1e-5 some string"
        value = b"+1e-5"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 1e-5, None)

        data = b"+1e+0 some string"
        value = b"+1e+0"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 1, None)

        data = b"+ 1e+0 some string"
        value = b"+ 1e+0"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 1, None)

        data = b"+0 some string"
        value = b"+0"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 0, None)
Exemplo n.º 19
0
    def test5get_match_element_optional_zero_values(self):
        """Test valid float values with "optional" or "zero" values of value_sign_type, value_pad_type and exponent_type."""
        decimal_float_value_me = DecimalFloatValueModelElement(
            self.id_, DecimalFloatValueModelElement.SIGN_TYPE_OPTIONAL,
            DecimalFloatValueModelElement.PAD_TYPE_ZERO,
            DecimalFloatValueModelElement.EXP_TYPE_OPTIONAL)
        data = b"22.25 some string."
        value = b"22.25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 22.25, None)

        data = b"-22.25 some string."
        value = b"-22.25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, -22.25, None)

        data = b"0.25 some string."
        value = b"0.25"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 0.25, None)

        data = b"22 some string."
        value = b"22"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 22, None)

        data = b"22.12.2021 some string."
        value = b"22.12"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 22.12, None)

        data = b"22. some string"
        value = b"22."
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 22.0, None)

        data = b"025 some string"
        value = b"025"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 25, None)

        data = b"0025 some string"
        value = b"0025"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 25, None)

        data = b"0025.22 some string"
        value = b"0025.22"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 25.22, None)

        data = b"1e-5 some string"
        value = b"1e-5"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 1e-5, None)

        data = b"1e+0 some string"
        value = b"1e+0"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 1, None)

        data = b"0 some string"
        value = b"0"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 0, None)

        data = b"00 some string"
        value = b"00"
        match_context = DummyMatchContext(data)
        match_element = decimal_float_value_me.get_match_element(
            self.path, match_context)
        self.compare_match_results(data, match_element, match_context,
                                   self.id_, self.path, value, 0, None)