You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Should (Not) Be Equal As Integers and Convert To Integer should accept also hex, octal and binary numbers #808
Originally submitted to Google Code by teemuahola7 on 26 Mar 2011
At the moment if string is given to 'Should Be Equal As Integers' keyword as a hexadecimal (e.g. 0x11223344) format, error "'0x11223344' cannot be converted to an integer: ValueError: invalid literal for int() with base 10: '0x11223344'" is raised.
Sometimes hexadecimals are more readable than 10-base numbers, so the keyword should accept also hexas.
Finally, we should also change Convert To Integer to handle base and prefixes the same way. Should (Not) Be Equal As Integers actually use that keyword internally so there's only one place to edit in the code. Related to this, I wonder should Convert To Integer also be able to convert numbers hex, octal and binary, or should we possibly add separate keywords for these conversions.
I had earlier implemented this so that possible prefix wins over explicit base.
I realized that this wasn't a good idea because, for example, following
would give result 2 when you would expect 2832:
${result} = Convert to Integer 0b10 base=16
I reverted the decision and now explicit base always wins over possible prefix.
Activity
spooning commentedon Jun 29, 2014
Sounds fair. It would probably be a good idea to allow passing the base explicitly (then you could also compare binary or octal numbers) but '0x' prefix could still indicate hex number if no base is given. We could also support '0o' and '0b' prefixes for octal and binary numbers, respectively, similarly as Python 2.6 and newer:
http://www.python.org/dev/peps/pep-3127
Finally, we should also change Convert To Integer to handle base and prefixes the same way. Should (Not) Be Equal As Integers actually use that keyword internally so there's only one place to edit in the code. Related to this, I wonder should Convert To Integer also be able to convert numbers hex, octal and binary, or should we possibly add separate keywords for these conversions.
spooning commentedon Jun 29, 2014
This issue was updated by revision 5eaa46cc43a3.
I would say this feature is done. But it would be even better if Janne could say that after code and documentation review.
Implementing separate
Convert to Binary/Octal/Hexkeywords might be a good idea but that requires a separate issue.spooning commentedon Jun 29, 2014
Convert to Binary/Octal/Hexis issue 836 . I also added issue 835 about supporting prefixes with integer variables like ${0xFF} and ${0b1010}.spooning commentedon Jun 29, 2014
Janne said this looks good.
spooning commentedon Jun 29, 2014
This issue was updated by revision f70318543b28.
I had earlier implemented this so that possible prefix wins over explicit base.
I realized that this wasn't a good idea because, for example, following
would give result 2 when you would expect 2832:
I reverted the decision and now explicit base always wins over possible prefix.
spooning commentedon Jun 29, 2014
This issue was updated by revision 558bc76f24dd.
Made Convert To Integer space-insensitive. Now e.g. 'FF 00 | 16' and '1000 1010 | 2' are valid inputs.
spooning commentedon Jun 29, 2014
Included into 2.6 alpha 1.