Archive

Posts Tagged ‘Testing’

Statement Code Coverage Testing – Part 2

November 26, 2011 1 comment

Back in November 2009 I posted the “UniBasic Code Coverage” project as an open-source project. Back then it was stripped version based on one I set up for my then employer. The version for my employer used an in-house pre-processor that greatly simplified the work I needed to do for it work with our source files.

I have now released the v0.2 (update: v0.8) development version which has fixed several bugs, added the ability to specific a customer pre-process for those don’t use string UniBasic and provided improved the documentation on installing, using and contributing.

As you will already be aware, the source code for this is hosting on the UniBasic Code Coverage Project at SourceForge in a Subversion repository. If you have Subversion installed, you can checkout the code with the following command:


svn co https://ucov.svn.sourceforge.net/svnroot/ucov ucov

If you are running UniData or UniVerse on Windows, I highly recommend you install Tortoise SVN as it greatly simplifies working with Subversion.

On the SourceForge site you will not only find the Subversion repository for all the code, but also ‘Tracker’ which will allow you to submit Feature and Bug tickets. If you need help with anything, you can submit a Support Request as well.

If you wish to contribute to the code or documentation, you can introduce yourself on the Developer Forum. The best way to submit code or doc is by generating a Diff of the changes, as well as what the behaviour was before the change and what it was after the change.

When you have used UBC, be sure to fill out a Review. All constructive input is welcome and appreciated!

Advertisements

Crouching Null, Hidden Bug

May 2, 2010 1 comment

Null, (actually just an empty string “” in U2) is a valid value. Normally, it would be treated exactly the same as other normal values, such as 1 or “1”, but it isn’t always.

I’ve seen a few bugs that have been created by not understand the differences in how nulls are treated. When debugging the code can look completely valid as well, meaning it takes even longer to identify and rectify the issue.

Okay, lets see how you go. I’ll give you a few series of records, each created with the same data. Your job, is to work out which records in the series will exactly match their ‘CONTROL.REC’. Good luck and try to do it without needing to compile the code!

Series 1:

 CONTROL.REC = "" : @AM : "A"

 DIM REC(3)

 REC(0) = ""
 REC(0)<2> = "A"

 REC(1) = ""
 REC(1)<-1> = "A"

 REC(2) = ""
 INS "A" BEFORE REC(2)<2>

 REC(3) = "A"
 INS "" BEFORE REC(3)<1>


Series 2:

 CONTROL.REC = "A" : @AM : ""

 DIM REC(3)

 REC(0) = "A"
 REC(0)<2> = ""

 REC(1) = "A"
 REC(1)<-1> = ""

 REC(2) = "A"
 INS "" BEFORE REC(2)<2>

 REC(3) = ""
 INS "A" BEFORE REC(3)<1>


Series 3:

 CONTROL.REC = "" : @AM : "A" : @AM : ""

 DIM REC(3)

 REC(0) = ""
 REC(0)<2> = "A"
 REC(0)<3> = ""

 REC(1) = ""
 REC(1)<-1> = "A"
 REC(1)<-1> = ""

 REC(2) = ""
 INS "A" BEFORE REC(2)<1>
 INS "" BEFORE REC(2)<1>

 REC(3) = ""
 INS "A" BEFORE REC(3)<2>
 INS "" BEFORE REC(3)<3>


Series 4:

 CONTROL.REC = "A" : @AM : "" : @AM : "A"

 DIM REC(3)

 REC(0) = "A"
 REC(0)<2> = ""
 REC(0)<3> = "A"

 REC(1) = "A"
 REC(1)<-1> = ""
 REC(1)<-1> = "A"

 REC(2) = "A"
 INS "" BEFORE REC(2)<1>
 INS "A" BEFORE REC(2)<1>

 REC(3) = "A"
 INS "" BEFORE REC(3)<2>
 INS "A" BEFORE REC(3)<3>


Series 5:

 CONTROL.REC = "A" : @AM : "" : @AM : ""

 DIM REC(4)

 REC(0) = "A"
 REC(0)<2> = ""
 REC(0)<3> = ""

 REC(1) = "A"
 REC(1)<-1> = ""
 REC(1)<-1> = ""

 REC(2) = "A"
 INS "" BEFORE REC(2)<2>
 INS "" BEFORE REC(2)<2>

 REC(3) = "A"
 INS "" BEFORE REC(3)<2>
 INS "" BEFORE REC(3)<3>
 
 REC(4) = ""
 INS "" BEFORE REC(4)<1>
 INS "A" BEFORE REC(4)<1>


Series 6:

 CONTROL.REC = "A" : @AM : "B" : @AM : "C"

 DIM REC(4)

 REC(0) = "A"
 REC(0)<2> = "B"
 REC(0)<3> = "C"

 REC(1) = "A"
 REC(1)<-1> = "B"
 REC(1)<-1> = "C"

 REC(2) = "A"
 INS "C" BEFORE REC(2)<2>
 INS "B" BEFORE REC(2)<2>

 REC(3) = "A"
 INS "B" BEFORE REC(3)<2>
 INS "C" BEFORE REC(3)<3>
 
 REC(4) = "C"
 INS "B" BEFORE REC(4)<1>
 INS "A" BEFORE REC(4)<1>


Did you get them all? I’ve put the answers as a comment so you can check them if you want. I’d be surprised if you got them all right…

So, what should you take away from this? <-1> and INS can give you (or others!) a world of headaches if you don’t understand their peculiarities with null values.

Final Note: In UniVerse INS behaviour for some cases is dependant on the flavour your account is running in and the $OPTIONS EXTRA.DELIM setting.

%d bloggers like this: