| 1 | /* -*- mode: C++ -*- */ |
|---|
| 2 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 3 | // FILE : test.tol |
|---|
| 4 | // PURPOSE: Package MatQuery test |
|---|
| 5 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 6 | |
|---|
| 7 | Text email_ = "vdebuen@tol-project.org"; |
|---|
| 8 | Text link_ = ""; |
|---|
| 9 | Text summary_ = "checking matrix row selection of unknown values"; |
|---|
| 10 | |
|---|
| 11 | //Write here the initial test TOL code if needed |
|---|
| 12 | Real numErr0 = Copy(NError); |
|---|
| 13 | Real numWar0 = Copy(NWarning); |
|---|
| 14 | |
|---|
| 15 | #Require MatQuery; |
|---|
| 16 | //#Embed "../../../_embed_all.tol"; |
|---|
| 17 | |
|---|
| 18 | Real t1 = Copy(Time); |
|---|
| 19 | Real rndSeed = 0; |
|---|
| 20 | Real m = 300; |
|---|
| 21 | |
|---|
| 22 | VMatrix unk.match = LE(Rand(m,1,0,1),Rand(m,1,1,1)*.20); |
|---|
| 23 | VMatrix M = IfVMat(unk.match, Rand(m,1,1,1)*?, Rand(m,1,-10,10)); |
|---|
| 24 | |
|---|
| 25 | VMatrix unk.match_ = MatQuery::MatchRowsWithValue(M,?); |
|---|
| 26 | Real ok.1 = VMatMax(Abs(unk.match-unk.match))==0; |
|---|
| 27 | |
|---|
| 28 | Set sel.known = MatQuery::SelectMatch(Not(unk.match_)); |
|---|
| 29 | |
|---|
| 30 | VMatrix extract.known = SubRow(M, sel.known); |
|---|
| 31 | |
|---|
| 32 | Real ok.2 = VMatSum(IsUnknown(extract.known))==0; |
|---|
| 33 | Real ok.3 = VRows(extract.known)==m-VMatSum(unk.match); |
|---|
| 34 | |
|---|
| 35 | |
|---|
| 36 | Real numErr1 = Copy(NError); |
|---|
| 37 | Real numWar1 = Copy(NWarning); |
|---|
| 38 | |
|---|
| 39 | Set partialResults_ = [[numErr0, numErr1, |
|---|
| 40 | ok.1, ok.2, ok.3]]; |
|---|
| 41 | |
|---|
| 42 | //This is a messure of the success of the test |
|---|
| 43 | Real quality_ = And(numErr1 == numErr0, |
|---|
| 44 | numWar1 <= numWar0, |
|---|
| 45 | ok.1, ok.2, ok.3); |
|---|
| 46 | |
|---|
| 47 | //Return the results |
|---|
| 48 | Set resultStr_ = @strTestStatus(summary_, link_, quality_, |
|---|
| 49 | "Partial results = "<<partialResults_, |
|---|
| 50 | "NO DBServerType", "NO DBServerHost", "NO DBAlias", |
|---|
| 51 | email_); |
|---|
| 52 | WriteLn(""<<resultStr_); |
|---|
| 53 | resultStr_; |
|---|
| 54 | |
|---|
| 55 | /* */ |
|---|
| 56 | |
|---|