cancel
Showing results for 
Search instead for 
Did you mean: 

Format for numeric value

SOLVED
Occasional Contributor

Format for numeric value

Hello,

I am trying to specify a property checkpoint for my fild which contains numbers, to check the format, in the code of my desktop application in Delphi is specified #,##0.00, how can i do it with the same format to be checked in my keyword.

Thanks,

2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Hero

Re: Format for numeric value

Now it's clear... so, you're simply wanting to make sure that the contents of the property match a particular format.

So...  When setting up your property checkpoint, one of the options in the "Condition" parameter is "cmpMatches".  When you select that, then in the "Value" parameter, you enter the regular expression for the format you want as a "String", not a code expression.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Community Hero

Re: Format for numeric value

In the blank space in the value field I believe should be the regular expression for the format that you're wanting to check... and yes, it is a "number" techincally, but the wText field in the object is a string property.

You MAY end up not being able to use the built in property check point but might need to write a script routine that you call from within your keyword test to do the validation/check of the contents.  Again, regular expressions are going to be your friend here.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
8 REPLIES 8
Community Hero

Re: Format for numeric value

Have you looked at using aqString.Format in a code expression in your property checkpoint?

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/format.html

 

https://support.smartbear.com/testcomplete/docs/keyword-testing/dialogs/edit-expression.html?q=Code%...


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Occasional Contributor

Re: Format for numeric value

Thanks for your quick response.

I am still trying to resolve my issue, i read all the articles for aqString.Format method but i cannot figure out how to do it. I am sending the printscreens of my error and my property check point expression.

For sure i am wrong somewhere.

In my code of the application the format in Delphi is specified by '#,##0.00'

But i dont know how to do it in TC.

 

Community Hero

Re: Format for numeric value

Well, for one thing, the "Property" field should be the field that indicates which property of the object you're going to do a check against... you don't put the "aqString.Format" code in there....

So... you're doing a property checkpoint... meaning you want to check that the value of a property matches an expected value.  So...  in your checkpoint, the "Object" field should be everything all the way up to but NOT including the "wText"... that should be set up as an "Onscreen Object".   The "Property" field should be a string containng "wText".

 

It's the "Value" field where it sounds like you want to use the Code Expression for "aqString.Format".  Basically, this is where you're going to put in the value that you want to compare... 

Start with that... 


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Occasional Contributor

Re: Format for numeric value

Actually i dont have a specific value to be checked, i want to check the format for any value entered how it is displayed, i didnt make it still to find a solution, because i cannot find any particular example when only the format is checked, all the examples are for specific values. Can i do it in keyword with Code expression with aqString.Format and how to specify the format within the aqString.Format(??????)?

 

Here it is the original code for the Format in Delphi:

begin
FilterDFT := CompleteRound(FloatToStr(Dan));
FilterDFTPrimac := CompleteRound(FloatToStr(DanPrimac));
DFT.Text := FormatFloat('#,##0.00',StrToFloat(CompleteRound(FloatToStr(Dan))));
VKIznos.Text := FormatFloat('#,##0.00',StrToFloat(CompleteRound(FloatToStr(Dan + StrToFloat(FilterIznos) + StrToFloat(Provizija.Text)))));
end;

Highlighted
Community Hero

Re: Format for numeric value

Now it's clear... so, you're simply wanting to make sure that the contents of the property match a particular format.

So...  When setting up your property checkpoint, one of the options in the "Condition" parameter is "cmpMatches".  When you select that, then in the "Value" parameter, you enter the regular expression for the format you want as a "String", not a code expression.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Occasional Contributor

Re: Format for numeric value

But this way compares the both properties as strings. If I enter an expression a value as a string it gives me a hard coded value, and the field I want to check is constantly changing which makes the checkpoint useless. 

I have a field in my app that can have from 1 to 15 digit numbers and I want to check whether every and each of those numbers entered has the specific format of thousands separated by commas and decimals separated by a dot.

image.png

image.png

What do you suggest goes in the blank space? Is this right?

Thank you and sorry Smiley Happy

Community Hero

Re: Format for numeric value

In the blank space in the value field I believe should be the regular expression for the format that you're wanting to check... and yes, it is a "number" techincally, but the wText field in the object is a string property.

You MAY end up not being able to use the built in property check point but might need to write a script routine that you call from within your keyword test to do the validation/check of the contents.  Again, regular expressions are going to be your friend here.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.

Mysterious Gremlin Master
Extensions available
Occasional Contributor

Re: Format for numeric value

This was very enlightening. Thank you

New Here?
Join us and watch the welcome video:
Join the September Hub-bub to show off, learn and win