-
Notifications
You must be signed in to change notification settings - Fork 119
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
Feature/122 unit tests for strings #429
base: master
Are you sure you want to change the base?
Feature/122 unit tests for strings #429
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please read my comments.
tests/units/StringTest.cpp
Outdated
* Tests makeInt64() which converts a string | ||
* to a int64 | ||
*/ | ||
TEST(StringTest, TestMakeInt64) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be nice to add a case for negative number and positive number with the sign +
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have used the Gtest parameterize feature to parameterize the test in this test case. please take a look if that works for you and I can modify other test cases accordingly. thx
* to a unsigned int64 | ||
*/ | ||
TEST(StringTest, TestMakeUInt64) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would be also nice to add a case, where the uint64_t
is greater or equal to 0x8000'0000'0000'0000 to make sure that the 64-bit conversion is correct.
* to type int32. | ||
*/ | ||
TEST(StringTest, TestMakeInt32) | ||
{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add following cases:
- negative number conversion;
- positive number with
+
sign, likeconstexpr char * test = "+123";
- Other non-standard cases like:
constexpr char * test = "abcd";
constexpr char * test = "123abc";
constexpr char * test = "abc123:'
- Cases with various
radix
:typedef enum class E_Radix : int8_t { RadixAutomatic = 0 //!< Detect automatically , RadixBinary = 2 //!< Binary conversion, conversion base is 2 , RadixOctal = 8 //!< Octal conversion, conversion base is 8 , RadixDecimal = 10 //!< Decimal conversion, conversion base is 10 , RadixHexadecimal = 16 //!< Hexadecimal conversion, conversion base is 16 } eRadix;
- Please also check the value of the
end
parameter after callingmakeXXX
. Here is the syntax:/** * \brief Converts given string of digits to 32-bit integer * \param strDigit The string with digits. Can contain negative or positive sign in front * \param radix The base value when calculate integer. * \param end [out] If not nullptr, on output this contains value of pointer to the next character in strDigit buffer after the numerical value. * \return Returns 32-bit integer **/ static int32_t makeInt32( const char * strDigit, NEString::eRadix radix = NEString::eRadix::RadixDecimal, const char ** end = nullptr );
Ideally, would be nice to have parameterized tests to add various parameters and check outputs. Checkout the parameterized test example of strings in NEStringTest.cpp
. Same is for other makeXXX
tests.
I indeed appreciate very much your help, but then I'll have to rework and nearly overwrite everything to make tests proper :)
Thank you! Looks much better. |
Can be merged? |
Could you please make sure that it is compiled under Visual Studio? I tried locally and get errors.
The builds in this PR passed, because new |
Ah okay. I will take a look. Thanks for pointing out |
@aregtech I forgot to mention that I am using Linux and I was able to build it fine with cmake although it wont be able to build using msbuild right since that is windows specific? |
@harshit496, there is GitHub action workflow to run MSBuild. If you include the file in the MSVS project, it will fail. |
…it496/areg-sdk into feature/122-unit-tests-for-strings
@aregtech I added it to MS build project. where can I find the github action workflow link to see it fail? because currently under the checks tabs on this PR it does not run any jobs. i dont know why |
Hi @harshit496 , This the workflow. Your fork should also have it. As soon as you merge with your Alternatively, you can edit the beginning of name: MSBuild
on:
push: # Keep empty to run on each branch when push the code. Otherwise, use branches: [ master ]
# branches: [ master ]
pull_request:
# branches: [ master ] Then you can test locally. |
No description provided.