Is there the ability in Eggplant to check a number for precision format?
So in my scenario I open a file in an editor, copy the data I want, paste it via the remoteClipboard into a variable. At this point I would like to verify the precision of the number. So if I have a number that has a format of 12.4f, I want to verify that the total length of the value is not longer than 12 digits and that the decimal portion is exactly 4 digits.
I have not seen any examples to do this nor can I find any ability in Eggplant to do this. I can get the total length by using the length function but I canât seem to figure out how to check the decimal portion of the number.
Hi paisak,
why not using âassertâ to get the same in one line:
assert <1 to 6 digits, â.â, 4 digits> matches myVar with error âPrecision is correctâ
BR
Having problems again with this issue when dealing with negative numbers. So I tried the following and it did not work:
assert <1 to 6 digits, â.â 4 digits> matches negative myVar with error âPrecision is correctâ and for my example the number I am dealing with is -0.000000 and so it complains that my pattern is not equal to 0. I just want my 1 to 6 digits to be signed. I also tried using signed in the 1 to 6 digits section and I canât get the format right.
Edit: there probably is no number such as -0.000000 but I have to deal with it here. I even added a positive or negative in front of the 1 to 6 digits and it still complains that the pattern does not match -0.000000 even though it does. If the negative number is non-zero then the âmatches negativeâ works fine only.
Hi paisak, the match operator knows this:" maybe a âŚ", so your issue can be handled with assert <maybe a â-â, 1 to 6 digits, â.â 4 digits>
BR