Produced by Araxis Merge on 4/12/2018 10:18:30 AM Central Daylight Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | MSSRe Build 4.zip\Applications\OncoTrax-E40 | ONC_UnitTests.cpp | Tue Apr 10 19:43:39 2018 UTC |
| 2 | MSSRe Build 4.zip\Applications\OncoTrax-E40 | ONC_UnitTests.cpp | Thu Apr 12 08:55:14 2018 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 3 | 486 |
| Changed | 2 | 4 |
| Inserted | 0 | 0 |
| Removed | 0 | 0 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | /********* ********** ********** ********** ********** ********** ********** ********** / | |
| 2 | /* Packag e: ON C – Oncolo gy * / | |
| 3 | /* Date C reated: Ju l 26,2004 * / | |
| 4 | /* Site N ame: Hi nes OIFO * / | |
| 5 | /* Developers : Sergey Gav rilov PII ) */ | |
| 6 | /* Descri ption: Th is unit co ntains cod e that per forms unit tests of * / | |
| 7 | /* di fferent pa rts of the Oncology CGI applic ation. * / | |
| 8 | /********* ********** ********** ********** ********** ********** ********** ********** / | |
| 9 | ||
| 10 | #include " stdafx.h" | |
| 11 | #include " OncologyCG I.h" | |
| 12 | #include < memory> | |
| 13 | #include < conio.h> | |
| 14 | ||
| 15 | #include " ONC_Reques ts.h" | |
| 16 | ||
| 17 | #ifdef _DE BUG | |
| 18 | ||
| 19 | //***** PR OMPTS THE USER AND W AITS FOR E ITHER 'Y' OR 'N' ANS WER | |
| 20 | ||
| 21 | bool askYe sNo(const char* prom pt = "<def ault>") | |
| 22 | { | |
| 23 | ch ar ch; | |
| 24 | if ( strcmp(p rompt, "<d efault>") != 0 ) | |
| 25 | prin tf("\n%s", prompt); | |
| 26 | el se | |
| 27 | prin tf("\nAsnw er \'Y\' o r \'N\': " ); | |
| 28 | ||
| 29 | do | |
| 30 | { | |
| 31 | ch = toupper(_ getch()); | |
| 32 | } | |
| 33 | wh ile( (ch ! = 'Y') && (ch != 'N' ) ); | |
| 34 | pr intf("%c\n ", ch); | |
| 35 | ||
| 36 | re turn (ch = = 'Y'); | |
| 37 | } | |
| 38 | ||
| 39 | //***** PR INTS NAME OF THE TES T AND THE RESULT | |
| 40 | ||
| 41 | bool print Test(const char* hea der, const bool resu lt) | |
| 42 | { | |
| 43 | pr intf("\n%- 70s %s", header, re sult ? "Pa ssed" : "F ailed"); | |
| 44 | re turn resul t; | |
| 45 | } | |
| 46 | ||
| 47 | //***** TE STS THE EX CEPTION OB JECT | |
| 48 | ||
| 49 | bool testT ONCFault() | |
| 50 | { | |
| 51 | pu ts("\n\nTe sting cust om excepti on object. ..\n"); | |
| 52 | ||
| 53 | tr y | |
| 54 | { | |
| 55 | thro w TONCFaul t(EC_INVAL ID_EDITSCF G, "DEBUG" ); | |
| 56 | } | |
| 57 | ca tch(TONCFa ult Fault) | |
| 58 | { | |
| 59 | Faul t.output() ; | |
| 60 | } | |
| 61 | ||
| 62 | pu ts("\nDoes the XML f ragment ab ove look l ike this:\ n"); | |
| 63 | ||
| 64 | pu ts("<soap: Fault>"); | |
| 65 | pu ts("<fault code>Clien t</faultco de>"); | |
| 66 | pu ts("<fault string>Inv alid EDITS configura tion name: \'DEBUG\' .</faultst ring>"); | |
| 67 | pu ts("<detai l>"); | |
| 68 | pu ts("<RC>-1 7</RC>"); | |
| 69 | pu ts("</deta il>"); | |
| 70 | pu ts("</soap :Fault>"); | |
| 71 | ||
| 72 | if ( !askYesN o() ) | |
| 73 | retu rn false; | |
| 74 | ||
| 75 | re turn true; | |
| 76 | } | |
| 77 | ||
| 78 | //***** TE STS THE VE RSION REQU EST OBJECT | |
| 79 | ||
| 80 | bool testT ONCReqGetV ersion() | |
| 81 | { | |
| 82 | pu ts("\n\nTe sting vers ion reques t object.. .\n"); | |
| 83 | ||
| 84 | au to_ptr<TON CReqGetVer sion> req( new TONCRe qGetVersio n(GET_VERS ION)); | |
| 85 | re q->execute Request(); | |
| 86 | ||
| 87 | pu ts("\nDoes the XML f ragment ab ove look l ike this:\ n"); | |
| 88 | ||
| 89 | pu ts("<RESPO NSE xmlns= \"http:// URL \">"); | |
| 90 | pu ts("<CS-AP IVER>01030 0</CS-APIV ER>"); | |
| 91 | pu ts("<ED-ME TAVER></ED -METAVER>" ); | |
| 92 | pu ts("<VERSI ON>2.00</V ERSION>"); | |
| 93 | pu ts("</RESP ONSE>"); | |
| 94 | ||
| 95 | if ( !askYesN o() ) | |
| 96 | retu rn false; | |
| 97 | ||
| 98 | re turn true; | |
| 99 | } | |
| 100 | ||
| 101 | //***** TE STS THE BU FFER OBJEC T THAT IS USED BY TH E PARAMETE R PARSER | |
| 102 | ||
| 103 | bool testT ONCTextBuf fer() | |
| 104 | { | |
| 105 | au to_ptr<TON CTextBuffe r> buffer( new TONCTe xtBuffer); | |
| 106 | st ring ctrlb uf = ""; | |
| 107 | in t i; | |
| 108 | ||
| 109 | bu ffer->appe nd("123"); | |
| 110 | if ( buffer-> getAsInt() != 123 ) | |
| 111 | retu rn false; | |
| 112 | ||
| 113 | bu ffer->clea r(); | |
| 114 | ||
| 115 | // --- 8190 c haracters (buffer is almost fu ll) | |
| 116 | fo r(i=0; i<8 19; i++) | |
| 117 | { | |
| 118 | buff er->append ("12345678 90", 10); | |
| 119 | ctrl buf.append ("12345678 90"); | |
| 120 | } | |
| 121 | if ( buffer-> getAsText( ) != ctrlb uf ) | |
| 122 | retu rn false; | |
| 123 | ||
| 124 | // --- 32000 characters (initial buffer siz e) | |
| 125 | bu ffer->appe nd("12"); | |
| 126 | ct rlbuf.appe nd("12"); | |
| 127 | if ( buffer-> getAsText( ) != ctrlb uf ) | |
| 128 | retu rn false; | |
| 129 | ||
| 130 | // --- 8193 c haracters (buffer ha s been exp anded) | |
| 131 | bu ffer->appe nd("3"); | |
| 132 | ct rlbuf.appe nd("3"); | |
| 133 | if ( buffer-> getAsText( ) != ctrlb uf) | |
| 134 | retu rn false; | |
| 135 | ||
| 136 | // --- First character | |
| 137 | if ( buffer-> getAsChar( ) != ctrlb uf[0] ) | |
| 138 | retu rn false; | |
| 139 | ||
| 140 | re turn true; | |
| 141 | } | |
| 142 | ||
| 143 | //***** TE STS THE XM L PATH OBJ ECT THAT I S USED BY THE PARAME TER PARSER | |
| 144 | ||
| 145 | bool testT ONCXMLPath () | |
| 146 | { | |
| 147 | au to_ptr<TON CXMLPath> path(new T ONCXMLPath ); | |
| 148 | st ring ctrlb uf = ""; | |
| 149 | in t i; | |
| 150 | ||
| 151 | // --- 256 ch aracters ( initial bu ffer size) | |
| 152 | fo r(i=0; i<3 2; i++) | |
| 153 | { | |
| 154 | path ->pushTag( "^test-tag "); | |
| 155 | ctrl buf.append ("/test-ta g"); | |
| 156 | } | |
| 157 | if ( path->ge tPath() != ctrlbuf ) | |
| 158 | retu rn false; | |
| 159 | ||
| 160 | // --- Buffer has been expanded; empty tag name. | |
| 161 | pa th->pushTa g(""); | |
| 162 | ct rlbuf.appe nd("/<unkn own>"); | |
| 163 | if ( path->ge tPath() != ctrlbuf ) | |
| 164 | retu rn false; | |
| 165 | ||
| 166 | // --- Tag co des; push & pop | |
| 167 | pa th->clear( ); | |
| 168 | ||
| 169 | pa th->pushTa g("^Envelo pe"); | |
| 170 | pa th->pushTa g("^Body") ; | |
| 171 | pa th->pushTa g("^CS-GET -TABLES"); | |
| 172 | if ( path->ge tCode() != CS_GET_TA BLES ) | |
| 173 | retu rn false; | |
| 174 | ||
| 175 | pa th->popTag (); | |
| 176 | if ( path->ge tCode() != SOAP_BODY ) | |
| 177 | retu rn false; | |
| 178 | ||
| 179 | pa th->popTag (); | |
| 180 | if ( path->ge tCode() != SOAP_ENVE LOPE ) | |
| 181 | retu rn false; | |
| 182 | ||
| 183 | // --- Unknow n tag; las t tag name | |
| 184 | pa th->pushTa g("^CS-GET -TABLES"); | |
| 185 | if ( strcmp(p ath->getLa stTag(), " CS-GET-TAB LES") != 0 ) | |
| 186 | retu rn false; | |
| 187 | if ( path->ge tCode() != 0 ) | |
| 188 | retu rn false; | |
| 189 | ||
| 190 | re turn true; | |
| 191 | } | |
| 192 | ||
| 193 | //***** PE RFORMS UNI T TESTS | |
| 194 | ||
| 195 | int UnitTe sts() | |
| 196 | { | |
| 197 | in t rc = EXI T_FAILURE, errcnt = 0; | |
| 198 | ||
| 199 | tr y | |
| 200 | { | |
| 201 | //-- - TONCFaul t | |
| 202 | if( !printTest ("TONCFaul t", testTO NCFault()) ) | |
| 203 | errcnt ++; | |
| 204 | ||
| 205 | //-- - TONCReqG etVersion | |
| 206 | if( !printTest ("TONCReqG etVersion" , testTONC ReqGetVers ion()) ) | |
| 207 | errcnt ++; | |
| 208 | ||
| 209 | ||
| 210 | //-- - TONCText Buffer | |
| 211 | if( !printTest ("TONCText Buffer", t estTONCTex tBuffer()) ) | |
| 212 | errcnt ++; | |
| 213 | ||
| 214 | //-- - TONCXMLP ath | |
| 215 | if( !printTest ("TONCXMLP ath", test TONCXMLPat h()) ) | |
| 216 | errcnt ++; | |
| 217 | ||
| 218 | //-- - Success | |
| 219 | if( errcnt == 0 ) | |
| 220 | rc = E XIT_SUCCES S; | |
| 221 | } | |
| 222 | // --- Proces s exceptio ns explici tly genera ted by the Oncology code | |
| 223 | ca tch(TONCFa ult Fault) | |
| 224 | { | |
| 225 | Faul t.output() ; | |
| 226 | } | |
| 227 | ||
| 228 | pu ts("\n"); | |
| 229 | // --- Check for memory leaks | |
| 230 | if ( _CrtDump MemoryLeak s() ) | |
| 231 | { | |
| 232 | puts ("Memory l eak(s) det ected!"); | |
| 233 | rc = EXIT_FAIL URE; | |
| 234 | } | |
| 235 | // --- Print the conclu sion | |
| 236 | if ( rc == EX IT_SUCCESS ) | |
| 237 | puts ("Code pas sed all un it tests." ); | |
| 238 | el se | |
| 239 | puts ("Code did not pass unit test( s)."); | |
| 240 | ge tchar(); | |
| 241 | ||
| 242 | re turn rc; | |
| 243 | } | |
| 244 | ||
| 245 | #endif |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.