| 1 | /* -*- mode: C++ -*- */ |
|---|
| 2 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 3 | // FILE : test.tol |
|---|
| 4 | ////////////////////////////////////////////////////////////////////////////// |
|---|
| 5 | |
|---|
| 6 | Text email_ = "vdebuen@tol-project.org"; |
|---|
| 7 | Text link_ = ""; |
|---|
| 8 | Text summary_ = "checking a simple graph"; |
|---|
| 9 | |
|---|
| 10 | //Write here the initial test TOL code if needed |
|---|
| 11 | Real numErr0 = Copy(NError); |
|---|
| 12 | Real numWar0 = Copy(NWarning); |
|---|
| 13 | |
|---|
| 14 | Real rndSeed = 0; |
|---|
| 15 | Real removeRepeatedEdges = True; |
|---|
| 16 | |
|---|
| 17 | #Embed "../../_GraphTools.tol"; |
|---|
| 18 | #Embed "./define.random.graph.tol"; |
|---|
| 19 | |
|---|
| 20 | Set vertex.names_ = graph::get.vertex.names(?); |
|---|
| 21 | |
|---|
| 22 | Real ok.1 = Card(vertex.names)==Card(vertex.names_); |
|---|
| 23 | |
|---|
| 24 | Real vertex.idx = IntRand(1,vertex.num); |
|---|
| 25 | |
|---|
| 26 | Text vertex.name_ = graph::get.vertex.name(vertex.idx); |
|---|
| 27 | Real ok.2 = vertex.name_==vertex.names[vertex.idx]; |
|---|
| 28 | |
|---|
| 29 | Real edge.idx = IntRand(1,edge.num); |
|---|
| 30 | Set edge.info = graph::get.edge.features(edge.idx); |
|---|
| 31 | Real edge.idx.1 = graph::get.edge.index(edge.info[1], edge.info[2]); |
|---|
| 32 | Real edge.idx.2 = graph::get.edge.index(edge.info[2], edge.info[1]); |
|---|
| 33 | |
|---|
| 34 | WriteLn("edge.idx = "<<edge.idx); |
|---|
| 35 | WriteLn("edge.idx.1 = "<<edge.idx.1); |
|---|
| 36 | WriteLn("edge.idx.2 = "<<edge.idx.2); |
|---|
| 37 | |
|---|
| 38 | Real ok.3_ = edge.idx.1==edge.idx; |
|---|
| 39 | Real ok.4_ = edge.idx.2==edge.idx; |
|---|
| 40 | |
|---|
| 41 | Real ok.3 = ?; |
|---|
| 42 | Real ok.4 = ?; |
|---|
| 43 | |
|---|
| 44 | Real If(directed, |
|---|
| 45 | { |
|---|
| 46 | Real ok.3 := ok.3_ | ok.4_; |
|---|
| 47 | Real ok.4 := ok.3_ | ok.4_ |
|---|
| 48 | }, |
|---|
| 49 | { |
|---|
| 50 | Real ok.3 := ok.3_; |
|---|
| 51 | Real ok.4 := ok.3_ |
|---|
| 52 | }); |
|---|
| 53 | |
|---|
| 54 | Real high = MatDat(data,edge.idx,4); |
|---|
| 55 | Real high.1 = graph::get.edge.feature(edge.idx,4); |
|---|
| 56 | Real high.2 = graph::get.edge.feature(edge.idx,"Hight"); |
|---|
| 57 | Real ok.5 = Eq(high,high.1,high.2); |
|---|
| 58 | |
|---|
| 59 | Real t1 = Copy(Time); |
|---|
| 60 | |
|---|
| 61 | WriteLn("Creating time "<<(t1-t0)+" seconds"); |
|---|
| 62 | |
|---|
| 63 | Real Ois.Store([[graph]],"graph.oza"); |
|---|
| 64 | Real t2 = Copy(Time); |
|---|
| 65 | |
|---|
| 66 | WriteLn("Saving OIS time "<<(t2-t1)+" seconds"); |
|---|
| 67 | |
|---|
| 68 | Set load = { Include("graph.oza") }; |
|---|
| 69 | Real t3 = Copy(Time); |
|---|
| 70 | |
|---|
| 71 | WriteLn("Loading OIS time "<<(t3-t2)+" seconds"); |
|---|
| 72 | |
|---|
| 73 | Real numErr1 = Copy(NError); |
|---|
| 74 | Real numWar1 = Copy(NWarning); |
|---|
| 75 | |
|---|
| 76 | Set partialResults_ = [[numErr0, numErr1, |
|---|
| 77 | ok.1, ok.2, ok.3, ok.4, ok.5]]; |
|---|
| 78 | |
|---|
| 79 | //This is a messure of the success of the test |
|---|
| 80 | Real quality_ = And(numErr1 == numErr0, |
|---|
| 81 | numWar1 <= numWar0+1, |
|---|
| 82 | ok.1, ok.2, ok.3, ok.4, ok.5); |
|---|
| 83 | |
|---|
| 84 | //Return the results |
|---|
| 85 | Set resultStr_ = @strTestStatus(summary_, link_, quality_, |
|---|
| 86 | "Partial results = "<<partialResults_, |
|---|
| 87 | "NO DBServerType", "NO DBServerHost", "NO DBAlias", |
|---|
| 88 | email_); |
|---|
| 89 | WriteLn(""<<resultStr_); |
|---|
| 90 | resultStr_; |
|---|
| 91 | |
|---|
| 92 | /* */ |
|---|
| 93 | |
|---|