Skip to content

Should (Not) Be Equal As Integers and Convert To Integer should accept also hex, octal and binary numbers #808

Closed

Description

@spooning

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.

Activity

  1. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 27 Mar 2011

    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.

  2. added this to the 2.6 milestone on Jun 29, 2014
  3. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 5 May 2011

    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/Hex keywords might be a good idea but that requires a separate issue.

  4. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 6 May 2011

    Convert to Binary/Octal/Hex is issue 836 . I also added issue 835 about supporting prefixes with integer variables like ${0xFF} and ${0b1010}.

  5. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 6 May 2011

    Janne said this looks good.

  6. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 7 May 2011

    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:

    ${result} =  Convert to Integer  0b10  base=16
    

    I reverted the decision and now explicit base always wins over possible prefix.

  7. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 7 May 2011

    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.

  8. spooning commented on Jun 29, 2014

    @spooning
    ContributorAuthor

    Originally submitted to Google Code by @pekkaklarck on 13 Jun 2011

    Included into 2.6 alpha 1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions