| 1 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 2 | // FILE : test.tol |
|---|
| 3 | // PURPOSE: test of database handling with TOL |
|---|
| 4 | // requieres an active database connection |
|---|
| 5 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 6 | |
|---|
| 7 | Text email_ = "vdebuen@tol-project.org"; |
|---|
| 8 | Text link_ = ""; |
|---|
| 9 | Text summary_ = "Handling with NULL values in numeric fields"; |
|---|
| 10 | |
|---|
| 11 | //Write here the initial test TOL code if needed |
|---|
| 12 | |
|---|
| 13 | Real numErrIni = Copy(NError); //Initial number of errors |
|---|
| 14 | |
|---|
| 15 | Write("Checking if therea are active databases ... "); |
|---|
| 16 | Set dbConns = DBGetOpened(""); |
|---|
| 17 | Real ok0 = Card(dbConns)>0; |
|---|
| 18 | WriteLn(If(ok0,"OK","FAIL")); |
|---|
| 19 | |
|---|
| 20 | Set set.1 = DBTable(" |
|---|
| 21 | select 1.0+null, Concat('Hola',NULL) from dual |
|---|
| 22 | "); |
|---|
| 23 | Real numErrorEnd = Copy(NError); //Final number of errors |
|---|
| 24 | |
|---|
| 25 | //Expected number of errors |
|---|
| 26 | Real numErrorExpected = If(ok0, numErrIni, numErrIni+22); |
|---|
| 27 | |
|---|
| 28 | //Extented information about test behaviour |
|---|
| 29 | Set partialResults_ = |
|---|
| 30 | [[ |
|---|
| 31 | Real ok.1 = IsUnknown(set.1[1][1]), |
|---|
| 32 | Real ok.2 = Text(set.1[1][2])=="", |
|---|
| 33 | numErrIni, numErrorEnd, numErrorExpected, |
|---|
| 34 | Real okErr = numErrorEnd == numErrorExpected, |
|---|
| 35 | Real okQry = And(okErr, ok.1, ok.2) |
|---|
| 36 | ]]; |
|---|
| 37 | |
|---|
| 38 | Real quality_ = If(ok0, okQry, If(okQry, ?, false)); |
|---|
| 39 | |
|---|
| 40 | Real Dbt.Exists = ObjectExist("Set","Dbt.Connect"); |
|---|
| 41 | //Return the results |
|---|
| 42 | Set resultStr_ = @strTestStatus(summary_, link_, quality_, |
|---|
| 43 | "Partial results = "<<partialResults_, |
|---|
| 44 | If(Dbt.Exists,Dbt.Connect->engine_, ""), |
|---|
| 45 | If(Dbt.Exists,Dbt.Connect->host_, ""), |
|---|
| 46 | If(Dbt.Exists,Dbt.Connect->alias_, ""), |
|---|
| 47 | email_); |
|---|
| 48 | WriteLn(""<<resultStr_); |
|---|
| 49 | resultStr_ |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | /* */ |
|---|