Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for long long integers as native types #1142

Merged
merged 9 commits into from
Aug 12, 2018

Commits on Aug 11, 2018

  1. add support for long long integers as native types

    When testing code that needs to work on both 64-bit platforms and 32-bit
    platforms, the long integer may not guarantee 64bits of width on the
    32-bit platform. This makes testing calls which take and return 64bit
    values difficult, as the test framework can't handle these natively.
    
    Add support for long long integers, so that test code can natively
    handle these larger values.
    
    Note, to avoid ABI compatibility issues, use cpputest_longlong and
    cpputest_ulonglong. This ensures the virtual function tables are the
    same whether long long support is enabled or disabled.
    
    With this patch, if long long support is disabled in CppUTest, then the
    mock withParameter and returnParameter functions will fail indicating
    that the long long support is not enabled.
    
    Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
    jacob-keller committed Aug 11, 2018
    Configuration menu
    Copy the full SHA
    6e90b18 View commit details
    Browse the repository at this point in the history
  2. return 0 for the actual call traces

    Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
    jacob-keller committed Aug 11, 2018
    Configuration menu
    Copy the full SHA
    684d528 View commit details
    Browse the repository at this point in the history
  3. consistently typecast when converting sign of a value

    Use long long int, instead of long int, and type cast only when we are
    converting from a signed to an unsigned type, or vice versa.
    
    Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
    jacob-keller committed Aug 11, 2018
    Configuration menu
    Copy the full SHA
    0faa126 View commit details
    Browse the repository at this point in the history
  4. use a consistent order for the comparisons of other integer types

    Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
    jacob-keller committed Aug 11, 2018
    Configuration menu
    Copy the full SHA
    2ee5bda View commit details
    Browse the repository at this point in the history
  5. use correct accessor when returning long long int value

    Otherwise we will inadvertently return a potentially smaller sized
    value, resulting in incorrect return values.
    
    This fixes tests on various 32 bit platforms.
    
    Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
    jacob-keller committed Aug 11, 2018
    Configuration menu
    Copy the full SHA
    0cedfc2 View commit details
    Browse the repository at this point in the history
  6. use correct longInt accessor in equality test

    We incorrectly accessed the longLongIntValue_ section of the union when
    comparing a lont int and an unsigned long long int.
    
    This resulted in incorrect behavior on some 32bit platforms. This is
    likely due to the union not being zero initialized.
    
    Fix this by using the correct accessor, longIntValue_.
    
    Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
    jacob-keller committed Aug 11, 2018
    Configuration menu
    Copy the full SHA
    33ac61d View commit details
    Browse the repository at this point in the history
  7. remove unnecessary <climits> header

    It was originally added due to thinking we needed it for ULLONG_MAX
    definitions. Technically, we probably *do* need it, but it likely gets
    included through some other file.
    
    Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
    jacob-keller committed Aug 11, 2018
    Configuration menu
    Copy the full SHA
    cfe36d6 View commit details
    Browse the repository at this point in the history
  8. fix incorrect #ifdef for CPPUTEST_USE_LONG_LONG

    Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
    jacob-keller committed Aug 11, 2018
    Configuration menu
    Copy the full SHA
    1170768 View commit details
    Browse the repository at this point in the history
  9. move related MockParameterTests together

    Combined all of the mismatched long long and other type tests into one
    block. This reduces the number of checks for CPPUTEST_USE_LONG_LONG, and
    hopefully makes the code easier to read.
    
    I chose not to move the expectOne*ParameterAndValue tests, because these
    are not related to the mismatched type tests, and I wanted to keep
    similar tests together. Moving them would make the test layout a bit
    more confusing.
    
    Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
    jacob-keller committed Aug 11, 2018
    Configuration menu
    Copy the full SHA
    233f864 View commit details
    Browse the repository at this point in the history