distributedlife

passionate about everything

Parameterisation and Strings in HP Service Test Published by Ryan Boucher @ 11:55 pm

For anyone that used Vanilla C before string manipulation is like wearing a razor wire g-string; excruciating at the best of times. Service Test comes with a bunch of methods that make it just a little bit easier. Namely these are lr_eval_string and lr_save_string. There are others but the two most use functions are these two. I use them all day long.

lr_save_string takes a normal char* pointer and stores it in a Service Test parameter.


lr_save_string (MyCharStarString, “MyParameter”) ;

You may wonder what the point of all of this is well let me show you how to get the value back.


MyCharStarString = lr_eval_string (“{MyParameter}”) ;

It may look pointless but eval string can take multiple parameters and strings; it’s a regular sprintf without the %s, %d, etc and without needing to allocate memory.


MyConstCharStarString = lr_eval_string (“SELECT {column} FROM {table}”) ;

Column and table get converted into their appropriate values before being returned to the user. With Vanilla C you would have to allocate a buffer of the correct size and then sprintf the values in. The act of managing memory is no longer there. You still can’t do complex string operations like tokenisation easily but concatenation and basic string manipulation are sorted.

My Mug Ryan Boucher is a Software Inquisitor and is passionate about it. You can find a whole raft of articles and anecdotes about software testing and other topics he gets excited about.
Tags , , , , , , , ,