Best Python code snippet using autotest_python
DataFormatTest.py
Source:DataFormatTest.py
...31 def runTest(self):32 """Testing DataFormat"""33 df1 = DataFormat('PNG', 'Portable Network Graphics', 'image/png', [ 'png', 'xng' ], True)34 35 self.assert_(df1.getName() == 'PNG')36 self.assert_(df1.name == 'PNG')37 self.assert_(df1.getDescription() == 'Portable Network Graphics')38 self.assert_(df1.description == 'Portable Network Graphics')39 self.assert_(df1.getMimeType() == 'image/png')40 self.assert_(df1.mimeType == 'image/png')41 self.assert_(df1.isMultiRecordFormat() == True)42 self.assert_(df1.multiRecordFormat == True)43 44 self.assert_(df1.getNumFileExtensions() == 2)45 self.assert_(df1.numFileExtensions == 2)46 47 self.assert_(len(df1.fileExtensions) == 2)48 49 self.assert_(df1.getFileExtension(0) == 'png')50 self.assert_(df1.getFileExtension(1) == 'xng')51 self.assert_(df1.fileExtensions[0] == 'png')52 self.assert_(df1.fileExtensions[1] == 'xng')53 54 self.assertRaises(IndexError, df1.getFileExtension, 2)55 self.assertRaises(IndexError, df1.getFileExtension, 3)56 self.assertRaises(IndexError, df1.fileExtensions.__getitem__, 2)57 self.assertRaises(IndexError, df1.fileExtensions.__getitem__, 3)58 59 self.assert_(df1.matchesName('png'))60 self.assert_(df1.matchesName('PNG'))61 self.assert_(df1.matchesName('pNg'))62 self.assert_(not df1.matchesName('pngc'))63 self.assert_(not df1.matchesName(' png'))64 self.assert_(not df1.matchesName('png '))65 self.assert_(not df1.matchesName(''))66 self.assert_(df1.matchesMimeType('image/png'))67 self.assert_(df1.matchesMimeType('IMAGE/PNG'))68 self.assert_(df1.matchesMimeType('ImAGe/pnG'))69 self.assert_(not df1.matchesMimeType('inage/png'))70 self.assert_(not df1.matchesMimeType(' image/png'))71 self.assert_(not df1.matchesMimeType('image/png '))72 self.assert_(not df1.matchesMimeType('imge/png'))73 self.assert_(not df1.matchesMimeType(''))74 self.assert_(df1.matchesFileExtension('png'))75 self.assert_(df1.matchesFileExtension('PNG'))76 self.assert_(df1.matchesFileExtension('pNg'))77 self.assert_(not df1.matchesFileExtension(' png'))78 self.assert_(not df1.matchesFileExtension('png '))79 self.assert_(not df1.matchesFileExtension('pn g'))80 self.assert_(not df1.matchesFileExtension('pnxg'))81 self.assert_(not df1.matchesFileExtension('pag'))82 self.assert_(not df1.matchesFileExtension('pg'))83 self.assert_(not df1.matchesFileExtension(''))84 self.assert_('png' in df1.fileExtensions)85 self.assert_('PNG' in df1.fileExtensions)86 self.assert_('pNg' in df1.fileExtensions)87 self.assert_(not ' png' in df1.fileExtensions)88 self.assert_(not 'png ' in df1.fileExtensions)89 self.assert_(not 'pn g' in df1.fileExtensions)90 self.assert_(not 'pnxg' in df1.fileExtensions)91 self.assert_(not 'pag' in df1.fileExtensions)92 self.assert_(not 'pg' in df1.fileExtensions)93 self.assert_(not '' in df1.fileExtensions)94 95 self.assert_(df1.matchesFileExtension('xng'))96 self.assert_(df1.matchesFileExtension('XNG'))97 self.assert_(df1.matchesFileExtension('xnG'))98 self.assert_(not df1.matchesFileExtension(' xng'))99 self.assert_(not df1.matchesFileExtension('xng '))100 self.assert_(not df1.matchesFileExtension('xn g'))101 self.assert_(not df1.matchesFileExtension('xnxg'))102 self.assert_(not df1.matchesFileExtension('xag'))103 self.assert_(not df1.matchesFileExtension('xn'))104 self.assert_('xng' in df1.fileExtensions)105 self.assert_('XNG' in df1.fileExtensions)106 self.assert_('xnG' in df1.fileExtensions)107 self.assert_(not ' xng' in df1.fileExtensions)108 self.assert_(not 'xng ' in df1.fileExtensions)109 self.assert_(not 'xn g' in df1.fileExtensions)110 self.assert_(not 'xnxg' in df1.fileExtensions)111 self.assert_(not 'xag' in df1.fileExtensions)112 self.assert_(not 'xn' in df1.fileExtensions)113 #-----114 115 df2 = DataFormat('PNG', 'Portable Network Graphics', 'image/png', True)116 117 self.assert_(df2.getName() == 'PNG')118 self.assert_(df2.name == 'PNG')119 self.assert_(df2.getDescription() == 'Portable Network Graphics')120 self.assert_(df2.description == 'Portable Network Graphics')121 self.assert_(df2.getMimeType() == 'image/png')122 self.assert_(df2.mimeType == 'image/png')123 self.assert_(df2.isMultiRecordFormat() == True)124 self.assert_(df2.multiRecordFormat == True)125 126 self.assert_(df2.getNumFileExtensions() == 0)127 self.assert_(df2.numFileExtensions == 0)128 129 self.assert_(len(df2.fileExtensions) == 0)130 131 self.assertRaises(IndexError, df2.getFileExtension, 0)132 self.assertRaises(IndexError, df2.getFileExtension, 1)133 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 0)134 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 0)135 136 self.assert_(df2.matchesName('png'))137 self.assert_(df2.matchesName('PNG'))138 self.assert_(df2.matchesName('pNg'))139 self.assert_(not df2.matchesName('pngc'))140 self.assert_(not df2.matchesName(' png'))141 self.assert_(not df2.matchesName('png '))142 self.assert_(not df2.matchesName(''))143 144 self.assert_(df2.matchesMimeType('image/png'))145 self.assert_(df2.matchesMimeType('IMAGE/PNG'))146 self.assert_(df2.matchesMimeType('ImAGe/pnG'))147 self.assert_(not df2.matchesMimeType('inage/png'))148 self.assert_(not df2.matchesMimeType(' image/png'))149 self.assert_(not df2.matchesMimeType('image/png '))150 self.assert_(not df2.matchesMimeType('imge/png'))151 self.assert_(not df2.matchesMimeType(''))152 self.assert_(not df2.matchesFileExtension('png'))153 self.assert_(not df2.matchesFileExtension('PNG'))154 self.assert_(not df2.matchesFileExtension('pNg'))155 self.assert_(not df2.matchesFileExtension(' png'))156 self.assert_(not df2.matchesFileExtension('png '))157 self.assert_(not df2.matchesFileExtension('pn g'))158 self.assert_(not df2.matchesFileExtension('pnxg'))159 self.assert_(not df2.matchesFileExtension('pag'))160 self.assert_(not df2.matchesFileExtension('pg'))161 self.assert_(not df2.matchesFileExtension(''))162 163 #-----164 165 df2 = DataFormat()166 167 self.assert_(df2.getName() == '')168 self.assert_(df2.name == '')169 self.assert_(df2.getDescription() == '')170 self.assert_(df2.description == '')171 self.assert_(df2.getMimeType() == '')172 self.assert_(df2.mimeType == '')173 self.assert_(df2.isMultiRecordFormat() == False)174 self.assert_(df2.multiRecordFormat == False)175 176 self.assert_(df2.getNumFileExtensions() == 0)177 self.assert_(df2.numFileExtensions == 0)178 179 self.assertRaises(IndexError, df2.getFileExtension, 0)180 self.assertRaises(IndexError, df2.getFileExtension, 1)181 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 0)182 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 1)183 184 self.assert_(len(df2.fileExtensions) == 0)185 186 #-----187 188 df2.setName('Name1')189 190 self.assert_(df2.getName() == 'Name1')191 self.assert_(df2.name == 'Name1')192 self.assert_(df2.getDescription() == '')193 self.assert_(df2.description == '')194 self.assert_(df2.getMimeType() == '')195 self.assert_(df2.mimeType == '')196 self.assert_(df2.isMultiRecordFormat() == False)197 self.assert_(df2.multiRecordFormat == False)198 199 self.assert_(df2.getNumFileExtensions() == 0)200 self.assert_(df2.numFileExtensions == 0)201 202 self.assertRaises(IndexError, df2.getFileExtension, 0)203 self.assertRaises(IndexError, df2.getFileExtension, 1)204 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 0)205 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 1)206 207 self.assert_(len(df2.fileExtensions) == 0)208 #-----209 210 df2.name = 'Name'211 212 self.assert_(df2.getName() == 'Name')213 self.assert_(df2.name == 'Name')214 self.assert_(df2.getDescription() == '')215 self.assert_(df2.description == '')216 self.assert_(df2.getMimeType() == '')217 self.assert_(df2.mimeType == '')218 self.assert_(df2.isMultiRecordFormat() == False)219 self.assert_(df2.multiRecordFormat == False)220 221 self.assert_(df2.getNumFileExtensions() == 0)222 self.assert_(df2.numFileExtensions == 0)223 224 self.assertRaises(IndexError, df2.getFileExtension, 0)225 self.assertRaises(IndexError, df2.getFileExtension, 1)226 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 0)227 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 1)228 229 self.assert_(len(df2.fileExtensions) == 0)230 231 #-----232 df2.description = 'Description1'233 234 self.assert_(df2.getName() == 'Name')235 self.assert_(df2.name == 'Name')236 self.assert_(df2.getDescription() == 'Description1')237 self.assert_(df2.description == 'Description1')238 self.assert_(df2.getMimeType() == '')239 self.assert_(df2.mimeType == '')240 self.assert_(df2.isMultiRecordFormat() == False)241 self.assert_(df2.multiRecordFormat == False)242 243 self.assert_(df2.getNumFileExtensions() == 0)244 self.assert_(df2.numFileExtensions == 0)245 246 self.assertRaises(IndexError, df2.getFileExtension, 0)247 self.assertRaises(IndexError, df2.getFileExtension, 1)248 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 0)249 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 1)250 251 self.assert_(len(df2.fileExtensions) == 0)252 #-----253 254 df2.setDescription('Description')255 self.assert_(df2.getName() == 'Name')256 self.assert_(df2.name == 'Name')257 self.assert_(df2.getDescription() == 'Description')258 self.assert_(df2.description == 'Description')259 self.assert_(df2.getMimeType() == '')260 self.assert_(df2.mimeType == '')261 self.assert_(df2.isMultiRecordFormat() == False)262 self.assert_(df2.multiRecordFormat == False)263 264 self.assert_(df2.getNumFileExtensions() == 0)265 self.assert_(df2.numFileExtensions == 0)266 267 self.assertRaises(IndexError, df2.getFileExtension, 0)268 self.assertRaises(IndexError, df2.getFileExtension, 1)269 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 0)270 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 1)271 272 self.assert_(len(df2.fileExtensions) == 0)273 274 #-----275 276 df2.setMimeType('mime/type1')277 self.assert_(df2.getName() == 'Name')278 self.assert_(df2.name == 'Name')279 self.assert_(df2.getDescription() == 'Description')280 self.assert_(df2.description == 'Description')281 self.assert_(df2.getMimeType() == 'mime/type1')282 self.assert_(df2.mimeType == 'mime/type1')283 self.assert_(df2.isMultiRecordFormat() == False)284 self.assert_(df2.multiRecordFormat == False)285 286 self.assert_(df2.getNumFileExtensions() == 0)287 self.assert_(df2.numFileExtensions == 0)288 289 self.assertRaises(IndexError, df2.getFileExtension, 0)290 self.assertRaises(IndexError, df2.getFileExtension, 1)291 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 0)292 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 1)293 294 self.assert_(len(df2.fileExtensions) == 0)295 #-----296 297 df2.mimeType = 'mime/type'298 self.assert_(df2.getName() == 'Name')299 self.assert_(df2.name == 'Name')300 self.assert_(df2.getDescription() == 'Description')301 self.assert_(df2.description == 'Description')302 self.assert_(df2.getMimeType() == 'mime/type')303 self.assert_(df2.mimeType == 'mime/type')304 self.assert_(df2.isMultiRecordFormat() == False)305 self.assert_(df2.multiRecordFormat == False)306 307 self.assert_(df2.getNumFileExtensions() == 0)308 self.assert_(df2.numFileExtensions == 0)309 310 self.assertRaises(IndexError, df2.getFileExtension, 0)311 self.assertRaises(IndexError, df2.getFileExtension, 1)312 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 0)313 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 1)314 315 self.assert_(len(df2.fileExtensions) == 0)316 317 #-----318 319 df2.setMultiRecordFormat(True)320 self.assert_(df2.getName() == 'Name')321 self.assert_(df2.name == 'Name')322 self.assert_(df2.getDescription() == 'Description')323 self.assert_(df2.description == 'Description')324 self.assert_(df2.getMimeType() == 'mime/type')325 self.assert_(df2.mimeType == 'mime/type')326 self.assert_(df2.isMultiRecordFormat() == True)327 self.assert_(df2.multiRecordFormat == True)328 329 self.assert_(df2.getNumFileExtensions() == 0)330 self.assert_(df2.numFileExtensions == 0)331 332 self.assertRaises(IndexError, df2.getFileExtension, 0)333 self.assertRaises(IndexError, df2.getFileExtension, 1)334 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 0)335 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 1)336 337 self.assert_(len(df2.fileExtensions) == 0)338 self.assert_(not df2.fileExtensions)339 #-----340 341 df2.multiRecordFormat = False342 self.assert_(df2.getName() == 'Name')343 self.assert_(df2.name == 'Name')344 self.assert_(df2.getDescription() == 'Description')345 self.assert_(df2.description == 'Description')346 self.assert_(df2.getMimeType() == 'mime/type')347 self.assert_(df2.mimeType == 'mime/type')348 self.assert_(df2.isMultiRecordFormat() == False)349 self.assert_(df2.multiRecordFormat == False)350 351 self.assert_(df2.getNumFileExtensions() == 0)352 self.assert_(df2.numFileExtensions == 0)353 354 self.assertRaises(IndexError, df2.getFileExtension, 0)355 self.assertRaises(IndexError, df2.getFileExtension, 1)356 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 0)357 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 1)358 359 self.assert_(len(df2.fileExtensions) == 0)360 self.assert_(not df2.fileExtensions)361 #-----362 df2.setMultiRecordFormat(True)363 df2.addFileExtension('ext1')364 365 self.assert_(df2.getName() == 'Name')366 self.assert_(df2.name == 'Name')367 self.assert_(df2.getDescription() == 'Description')368 self.assert_(df2.description == 'Description')369 self.assert_(df2.getMimeType() == 'mime/type')370 self.assert_(df2.mimeType == 'mime/type')371 self.assert_(df2.isMultiRecordFormat() == True)372 self.assert_(df2.multiRecordFormat == True)373 374 self.assert_(df2.getNumFileExtensions() == 1)375 self.assert_(df2.numFileExtensions == 1)376 377 self.assert_(df2.getFileExtension(0) == 'ext1')378 self.assert_(df2.fileExtensions[0] == 'ext1')379 380 self.assertRaises(IndexError, df2.getFileExtension, 1)381 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 1)382 383 self.assert_(len(df2.fileExtensions) == 1)384 self.assert_(df2.fileExtensions)385 386 self.assert_(df2.matchesFileExtension('ext1'))387 self.assert_(not df2.matchesFileExtension('ext2'))388 self.assert_(not df2.matchesFileExtension(''))389 self.assert_('ext1' in df2.fileExtensions)390 self.assert_(not 'ext2' in df2.fileExtensions)391 self.assert_(not '' in df2.fileExtensions)392 393 #-----394 395 df2.addFileExtension('ext2')396 397 self.assert_(df2.getName() == 'Name')398 self.assert_(df2.name == 'Name')399 self.assert_(df2.getDescription() == 'Description')400 self.assert_(df2.description == 'Description')401 self.assert_(df2.getMimeType() == 'mime/type')402 self.assert_(df2.mimeType == 'mime/type')403 self.assert_(df2.isMultiRecordFormat() == True)404 self.assert_(df2.multiRecordFormat == True)405 406 self.assert_(df2.getNumFileExtensions() == 2)407 self.assert_(df2.numFileExtensions == 2)408 409 self.assert_(df2.getFileExtension(0) == 'ext1')410 self.assert_(df2.fileExtensions[0] == 'ext1')411 self.assert_(df2.getFileExtension(1) == 'ext2')412 self.assert_(df2.fileExtensions[1] == 'ext2')413 414 self.assertRaises(IndexError, df2.getFileExtension, 2)415 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 2)416 417 self.assert_(len(df2.fileExtensions) == 2)418 self.assert_(df2.fileExtensions)419 420 self.assert_(df2.matchesFileExtension('ext1'))421 self.assert_(df2.matchesFileExtension('ext2'))422 self.assert_(not df2.matchesFileExtension(''))423 self.assert_('ext1' in df2.fileExtensions)424 self.assert_('ext2' in df2.fileExtensions)425 self.assert_(not '' in df2.fileExtensions)426 427 #-----428 429 df2.addFileExtension('')430 431 self.assert_(df2.getName() == 'Name')432 self.assert_(df2.name == 'Name')433 self.assert_(df2.getDescription() == 'Description')434 self.assert_(df2.description == 'Description')435 self.assert_(df2.getMimeType() == 'mime/type')436 self.assert_(df2.mimeType == 'mime/type')437 self.assert_(df2.isMultiRecordFormat() == True)438 self.assert_(df2.multiRecordFormat == True)439 440 self.assert_(df2.getNumFileExtensions() == 3)441 self.assert_(df2.numFileExtensions == 3)442 443 self.assert_(df2.getFileExtension(0) == 'ext1')444 self.assert_(df2.fileExtensions[0] == 'ext1')445 self.assert_(df2.getFileExtension(1) == 'ext2')446 self.assert_(df2.fileExtensions[1] == 'ext2')447 self.assert_(df2.getFileExtension(2) == '')448 self.assert_(df2.fileExtensions[2] == '')449 450 self.assertRaises(IndexError, df2.getFileExtension, 3)451 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 3)452 453 self.assert_(len(df2.fileExtensions) == 3)454 self.assert_(df2.fileExtensions)455 456 self.assert_(df2.matchesFileExtension('ext1'))457 self.assert_(df2.matchesFileExtension('ext2'))458 self.assert_(df2.matchesFileExtension(''))459 self.assert_('ext1' in df2.fileExtensions)460 self.assert_('ext2' in df2.fileExtensions)461 self.assert_('' in df2.fileExtensions)462 463 #-----464 465 df2.setFileExtension(2, 'ext3')466 467 self.assertRaises(IndexError, df2.setFileExtension, 3, 'ext4')468 self.assert_(df2.getName() == 'Name')469 self.assert_(df2.name == 'Name')470 self.assert_(df2.getDescription() == 'Description')471 self.assert_(df2.description == 'Description')472 self.assert_(df2.getMimeType() == 'mime/type')473 self.assert_(df2.mimeType == 'mime/type')474 self.assert_(df2.isMultiRecordFormat() == True)475 self.assert_(df2.multiRecordFormat == True)476 477 self.assert_(df2.getNumFileExtensions() == 3)478 self.assert_(df2.numFileExtensions == 3)479 480 self.assert_(df2.getFileExtension(0) == 'ext1')481 self.assert_(df2.fileExtensions[0] == 'ext1')482 self.assert_(df2.getFileExtension(1) == 'ext2')483 self.assert_(df2.fileExtensions[1] == 'ext2')484 self.assert_(df2.getFileExtension(2) == 'ext3')485 self.assert_(df2.fileExtensions[2] == 'ext3')486 487 self.assertRaises(IndexError, df2.getFileExtension, 3)488 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 3)489 490 self.assert_(len(df2.fileExtensions) == 3)491 self.assert_(df2.fileExtensions)492 493 self.assert_(df2.matchesFileExtension('ext1'))494 self.assert_(df2.matchesFileExtension('ext2'))495 self.assert_(df2.matchesFileExtension('ext3'))496 self.assert_(not df2.matchesFileExtension(''))497 self.assert_(not df2.matchesFileExtension(' '))498 self.assert_('ext1' in df2.fileExtensions)499 self.assert_('ext2' in df2.fileExtensions)500 self.assert_('ext3' in df2.fileExtensions)501 self.assert_(not '' in df2.fileExtensions)502 self.assert_(not ' ' in df2.fileExtensions)503 504 #-----505 506 df2.fileExtensions[2] = 'ext'507 self.assertRaises(IndexError, df2.fileExtensions.__setitem__, 3, 'ext4')508 509 self.assert_(df2.getName() == 'Name')510 self.assert_(df2.name == 'Name')511 self.assert_(df2.getDescription() == 'Description')512 self.assert_(df2.description == 'Description')513 self.assert_(df2.getMimeType() == 'mime/type')514 self.assert_(df2.mimeType == 'mime/type')515 self.assert_(df2.isMultiRecordFormat() == True)516 self.assert_(df2.multiRecordFormat == True)517 518 self.assert_(df2.getNumFileExtensions() == 3)519 self.assert_(df2.numFileExtensions == 3)520 521 self.assert_(df2.getFileExtension(0) == 'ext1')522 self.assert_(df2.fileExtensions[0] == 'ext1')523 self.assert_(df2.getFileExtension(1) == 'ext2')524 self.assert_(df2.fileExtensions[1] == 'ext2')525 self.assert_(df2.getFileExtension(2) == 'ext')526 self.assert_(df2.fileExtensions[2] == 'ext')527 528 self.assertRaises(IndexError, df2.getFileExtension, 3)529 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 3)530 531 self.assert_(len(df2.fileExtensions) == 3)532 self.assert_(df2.fileExtensions)533 534 self.assert_(df2.matchesFileExtension('ext1'))535 self.assert_(df2.matchesFileExtension('ext2'))536 self.assert_(df2.matchesFileExtension('ext'))537 self.assert_(not df2.matchesFileExtension(''))538 self.assert_(not df2.matchesFileExtension(' '))539 self.assert_('ext1' in df2.fileExtensions)540 self.assert_('ext2' in df2.fileExtensions)541 self.assert_('ext' in df2.fileExtensions)542 self.assert_(not '' in df2.fileExtensions)543 self.assert_(not ' ' in df2.fileExtensions)544 545 #-----546 df2.fileExtensions[2] = 'ext3'547 548 self.assertRaises(IndexError, df2.fileExtensions.__setitem__, 3, 'ext4')549 550 self.assert_(df2.getName() == 'Name')551 self.assert_(df2.name == 'Name')552 self.assert_(df2.getDescription() == 'Description')553 self.assert_(df2.description == 'Description')554 self.assert_(df2.getMimeType() == 'mime/type')555 self.assert_(df2.mimeType == 'mime/type')556 self.assert_(df2.isMultiRecordFormat() == True)557 self.assert_(df2.multiRecordFormat == True)558 559 self.assert_(df2.getNumFileExtensions() == 3)560 self.assert_(df2.numFileExtensions == 3)561 562 self.assert_(df2.getFileExtension(0) == 'ext1')563 self.assert_(df2.fileExtensions[0] == 'ext1')564 self.assert_(df2.getFileExtension(1) == 'ext2')565 self.assert_(df2.fileExtensions[1] == 'ext2')566 self.assert_(df2.getFileExtension(2) == 'ext3')567 self.assert_(df2.fileExtensions[2] == 'ext3')568 569 self.assertRaises(IndexError, df2.getFileExtension, 3)570 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 3)571 572 self.assert_(len(df2.fileExtensions) == 3)573 self.assert_(df2.fileExtensions)574 575 self.assert_(df2.matchesFileExtension('ext1'))576 self.assert_(df2.matchesFileExtension('ext2'))577 self.assert_(df2.matchesFileExtension('ext3'))578 self.assert_(not df2.matchesFileExtension('ext'))579 self.assert_(not df2.matchesFileExtension(''))580 self.assert_(not df2.matchesFileExtension(' '))581 self.assert_('ext1' in df2.fileExtensions)582 self.assert_('ext2' in df2.fileExtensions)583 self.assert_('ext3' in df2.fileExtensions)584 self.assert_(not 'ext' in df2.fileExtensions)585 self.assert_(not '' in df2.fileExtensions)586 self.assert_(not ' ' in df2.fileExtensions)587 588 #-----589 590 df2.removeFileExtension(1)591 592 self.assertRaises(IndexError, df2.removeFileExtension, 2)593 self.assert_(df2.getName() == 'Name')594 self.assert_(df2.name == 'Name')595 self.assert_(df2.getDescription() == 'Description')596 self.assert_(df2.description == 'Description')597 self.assert_(df2.getMimeType() == 'mime/type')598 self.assert_(df2.mimeType == 'mime/type')599 self.assert_(df2.isMultiRecordFormat() == True)600 self.assert_(df2.multiRecordFormat == True)601 602 self.assert_(df2.getNumFileExtensions() == 2)603 self.assert_(df2.numFileExtensions == 2)604 605 self.assert_(df2.getFileExtension(0) == 'ext1')606 self.assert_(df2.fileExtensions[0] == 'ext1')607 self.assert_(df2.getFileExtension(1) == 'ext3')608 self.assert_(df2.fileExtensions[1] == 'ext3')609 610 self.assertRaises(IndexError, df2.getFileExtension, 2)611 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 2)612 613 self.assert_(len(df2.fileExtensions) == 2)614 self.assert_(df2.fileExtensions)615 616 self.assert_(df2.matchesFileExtension('ext1'))617 self.assert_(not df2.matchesFileExtension('ext2'))618 self.assert_(df2.matchesFileExtension('ext3'))619 self.assert_(not df2.matchesFileExtension('ext'))620 self.assert_(not df2.matchesFileExtension(''))621 self.assert_(not df2.matchesFileExtension(' '))622 self.assert_('ext1' in df2.fileExtensions)623 self.assert_(not 'ext2' in df2.fileExtensions)624 self.assert_('ext3' in df2.fileExtensions)625 self.assert_(not 'ext' in df2.fileExtensions)626 self.assert_(not '' in df2.fileExtensions)627 self.assert_(not ' ' in df2.fileExtensions)628 629 #-----630 631 del df2.fileExtensions[0]632 self.assertRaises(IndexError, df2.fileExtensions.__delitem__, 1)633 634 self.assert_(df2.getName() == 'Name')635 self.assert_(df2.name == 'Name')636 self.assert_(df2.getDescription() == 'Description')637 self.assert_(df2.description == 'Description')638 self.assert_(df2.getMimeType() == 'mime/type')639 self.assert_(df2.mimeType == 'mime/type')640 self.assert_(df2.isMultiRecordFormat() == True)641 self.assert_(df2.multiRecordFormat == True)642 643 self.assert_(df2.getNumFileExtensions() == 1)644 self.assert_(df2.numFileExtensions == 1)645 646 self.assert_(df2.getFileExtension(0) == 'ext3')647 self.assert_(df2.fileExtensions[0] == 'ext3')648 649 self.assertRaises(IndexError, df2.getFileExtension, 1)650 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 1)651 652 self.assert_(len(df2.fileExtensions) == 1)653 self.assert_(df2.fileExtensions)654 655 self.assert_(not df2.matchesFileExtension('ext1'))656 self.assert_(not df2.matchesFileExtension('ext2'))657 self.assert_(df2.matchesFileExtension('ext3'))658 self.assert_(not df2.matchesFileExtension('ext'))659 self.assert_(not df2.matchesFileExtension(''))660 self.assert_(not df2.matchesFileExtension(' '))661 self.assert_(not 'ext1' in df2.fileExtensions)662 self.assert_(not 'ext2' in df2.fileExtensions)663 self.assert_('ext3' in df2.fileExtensions)664 self.assert_(not 'ext' in df2.fileExtensions)665 self.assert_(not '' in df2.fileExtensions)666 self.assert_(not ' ' in df2.fileExtensions)667 668 #-----669 670 df2.clearFileExtensions()671 672 self.assert_(df2.getName() == 'Name')673 self.assert_(df2.name == 'Name')674 self.assert_(df2.getDescription() == 'Description')675 self.assert_(df2.description == 'Description')676 self.assert_(df2.getMimeType() == 'mime/type')677 self.assert_(df2.mimeType == 'mime/type')678 self.assert_(df2.isMultiRecordFormat() == True)679 self.assert_(df2.multiRecordFormat == True)680 681 self.assert_(df2.getNumFileExtensions() == 0)682 self.assert_(df2.numFileExtensions == 0)683 684 self.assertRaises(IndexError, df2.getFileExtension, 0)685 self.assertRaises(IndexError, df2.getFileExtension, 1)686 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 0)687 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 1)688 689 self.assert_(len(df2.fileExtensions) == 0)690 self.assert_(not df2.fileExtensions)691 692 #-----693 694 df2.setName('')695 696 self.assert_(df2.getName() == '')697 self.assert_(df2.getDescription() == 'Description')698 self.assert_(df2.getMimeType() == 'mime/type')699 self.assert_(df2.isMultiRecordFormat() == True)700 701 self.assert_(df2.getNumFileExtensions() == 0)702 self.assert_(df2.numFileExtensions == 0)703 704 self.assert_(len(df2.fileExtensions) == 0)705 self.assert_(not df2.fileExtensions)706 self.assertRaises(IndexError, df2.getFileExtension, 0)707 self.assertRaises(IndexError, df2.getFileExtension, 1)708 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 0)709 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 1)710 711 self.assert_(not df2.matchesFileExtension('ext1'))712 self.assert_(not df2.matchesFileExtension('ext2'))713 self.assert_(not df2.matchesFileExtension('ext3'))714 self.assert_(not df2.matchesFileExtension(''))715 self.assert_(not df2.matchesFileExtension(' '))716 717 #-----718 719 df2.setDescription('')720 721 self.assert_(df2.getName() == '')722 self.assert_(df2.getDescription() == '')723 self.assert_(df2.getMimeType() == 'mime/type')724 self.assert_(df2.isMultiRecordFormat() == True)725 self.assert_(df2.getNumFileExtensions() == 0)726 self.assert_(df2.numFileExtensions == 0)727 self.assertRaises(IndexError, df2.getFileExtension, 0)728 self.assertRaises(IndexError, df2.getFileExtension, 1)729 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 0)730 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 1)731 732 self.assert_(len(df2.fileExtensions) == 0)733 self.assert_(not df2.fileExtensions)734 self.assert_(not df2.matchesFileExtension('ext1'))735 self.assert_(not df2.matchesFileExtension('ext2'))736 self.assert_(not df2.matchesFileExtension('ext3'))737 self.assert_(not df2.matchesFileExtension(''))738 self.assert_(not df2.matchesFileExtension(' '))739 740 #-----741 742 df2.setMimeType('')743 744 self.assert_(df2.getName() == '')745 self.assert_(df2.getDescription() == '')746 self.assert_(df2.getMimeType() == '')747 self.assert_(df2.isMultiRecordFormat() == True)748 self.assert_(df2.getNumFileExtensions() == 0)749 self.assert_(df2.numFileExtensions == 0)750 self.assertRaises(IndexError, df2.getFileExtension, 0)751 self.assertRaises(IndexError, df2.getFileExtension, 1)752 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 0)753 self.assertRaises(IndexError, df2.fileExtensions.__getitem__, 1)754 self.assert_(len(df2.fileExtensions) == 0)755 self.assert_(not df2.fileExtensions)756 self.assert_(not df2.matchesFileExtension('ext1'))757 self.assert_(not df2.matchesFileExtension('ext2'))758 self.assert_(not df2.matchesFileExtension('ext3'))759 self.assert_(not df2.matchesFileExtension(''))760 self.assert_(not df2.matchesFileExtension(' '))761 762 #-----763 764 self.assert_(not (df1 == df2))765 self.assert_(df1 != df2)766 767 df2.setName(df1.getName())768 769 self.assert_(not (df1 == df2))770 self.assert_(df1 != df2)771 772 df2.mimeType = df1.mimeType773 774 self.assert_(df1 == df2)775 self.assert_(not (df1 != df2))776 777 #-----778 df3 = DataFormat()779 self.assert_(not (df1 == df3))780 self.assert_(df1 != df3)781 df3.assign(df1)782 self.assert_(df1 == df3)783 self.assert_(not (df1 != df3))784 self.assert_(df1.getName() == df3.name)785 self.assert_(df1.getDescription() == df3.description)786 self.assert_(df1.getMimeType() == df3.mimeType)787 self.assert_(df1.isMultiRecordFormat() == df3.multiRecordFormat)788 self.assert_(df1.getNumFileExtensions() == df3.numFileExtensions)789 #-----790 df4 = DataFormat(df1)791 792 self.assert_(df1 == df4)793 self.assert_(not (df1 != df4))794 self.assert_(df4.getName() == df1.name)795 self.assert_(df4.getDescription() == df1.description)796 self.assert_(df4.getMimeType() == df1.mimeType)797 self.assert_(df4.isMultiRecordFormat() == df1.multiRecordFormat)...
stack_comp_test.js
Source:stack_comp_test.js
...14};15function eq(f, param) {16 Mt_global.collect_eq(test_id, suites, f, param[0], param[1]);17}18function assert_(loc, v) {19 eq(loc, [20 v,21 true22 ]);23}24function to_list(s) {25 var l = {26 contents: /* [] */027 };28 List.iter((function (x) {29 l.contents = {30 hd: x,31 tl: l.contents32 };33 }), s.c);34 return l.contents;35}36var S = {37 Empty: Stack.Empty,38 create: Stack.create,39 push: Stack.push,40 pop: Stack.pop,41 top: Stack.top,42 clear: Stack.clear,43 copy: Stack.copy,44 is_empty: Stack.is_empty,45 length: Stack.length,46 iter: Stack.iter,47 fold: Stack.fold,48 to_list: to_list49};50function does_raise(f, s) {51 try {52 Curry._1(f, s);53 return false;54 }55 catch (raw_exn){56 var exn = Caml_js_exceptions.internalToOCamlException(raw_exn);57 if (exn.RE_EXN_ID === Stack.Empty) {58 return true;59 }60 throw exn;61 }62}63var s = {64 c: /* [] */0,65 len: 066};67assert_("File \"stack_comp_test.ml\", line 33, characters 32-39", to_list(s) === /* [] */0 && s.len === 0);68Stack.push(1, s);69assert_("File \"stack_comp_test.ml\", line 34, characters 32-39", Caml_obj.equal(to_list(s), {70 hd: 1,71 tl: /* [] */072 }) && s.len === 1);73Stack.push(2, s);74assert_("File \"stack_comp_test.ml\", line 35, characters 32-39", Caml_obj.equal(to_list(s), {75 hd: 1,76 tl: {77 hd: 2,78 tl: /* [] */079 }80 }) && s.len === 2);81Stack.push(3, s);82assert_("File \"stack_comp_test.ml\", line 36, characters 32-39", Caml_obj.equal(to_list(s), {83 hd: 1,84 tl: {85 hd: 2,86 tl: {87 hd: 3,88 tl: /* [] */089 }90 }91 }) && s.len === 3);92Stack.push(4, s);93assert_("File \"stack_comp_test.ml\", line 37, characters 32-39", Caml_obj.equal(to_list(s), {94 hd: 1,95 tl: {96 hd: 2,97 tl: {98 hd: 3,99 tl: {100 hd: 4,101 tl: /* [] */0102 }103 }104 }105 }) && s.len === 4);106assert_("File \"stack_comp_test.ml\", line 38, characters 10-17", Stack.pop(s) === 4);107assert_("File \"stack_comp_test.ml\", line 38, characters 41-48", Caml_obj.equal(to_list(s), {108 hd: 1,109 tl: {110 hd: 2,111 tl: {112 hd: 3,113 tl: /* [] */0114 }115 }116 }) && s.len === 3);117assert_("File \"stack_comp_test.ml\", line 39, characters 10-17", Stack.pop(s) === 3);118assert_("File \"stack_comp_test.ml\", line 39, characters 41-48", Caml_obj.equal(to_list(s), {119 hd: 1,120 tl: {121 hd: 2,122 tl: /* [] */0123 }124 }) && s.len === 2);125assert_("File \"stack_comp_test.ml\", line 40, characters 10-17", Stack.pop(s) === 2);126assert_("File \"stack_comp_test.ml\", line 40, characters 41-48", Caml_obj.equal(to_list(s), {127 hd: 1,128 tl: /* [] */0129 }) && s.len === 1);130assert_("File \"stack_comp_test.ml\", line 41, characters 10-17", Stack.pop(s) === 1);131assert_("File \"stack_comp_test.ml\", line 41, characters 41-48", to_list(s) === /* [] */0 && s.len === 0);132assert_("File \"stack_comp_test.ml\", line 42, characters 10-17", does_raise(Stack.pop, s));133var s$1 = {134 c: /* [] */0,135 len: 0136};137Stack.push(1, s$1);138assert_("File \"stack_comp_test.ml\", line 47, characters 22-29", Stack.pop(s$1) === 1);139assert_("File \"stack_comp_test.ml\", line 47, characters 53-60", does_raise(Stack.pop, s$1));140Stack.push(2, s$1);141assert_("File \"stack_comp_test.ml\", line 48, characters 22-29", Stack.pop(s$1) === 2);142assert_("File \"stack_comp_test.ml\", line 48, characters 53-60", does_raise(Stack.pop, s$1));143assert_("File \"stack_comp_test.ml\", line 49, characters 10-17", s$1.len === 0);144var s$2 = {145 c: /* [] */0,146 len: 0147};148Stack.push(1, s$2);149assert_("File \"stack_comp_test.ml\", line 54, characters 22-29", Stack.top(s$2) === 1);150Stack.push(2, s$2);151assert_("File \"stack_comp_test.ml\", line 55, characters 22-29", Stack.top(s$2) === 2);152Stack.push(3, s$2);153assert_("File \"stack_comp_test.ml\", line 56, characters 22-29", Stack.top(s$2) === 3);154assert_("File \"stack_comp_test.ml\", line 57, characters 10-17", Stack.top(s$2) === 3);155assert_("File \"stack_comp_test.ml\", line 57, characters 41-48", Stack.pop(s$2) === 3);156assert_("File \"stack_comp_test.ml\", line 58, characters 10-17", Stack.top(s$2) === 2);157assert_("File \"stack_comp_test.ml\", line 58, characters 41-48", Stack.pop(s$2) === 2);158assert_("File \"stack_comp_test.ml\", line 59, characters 10-17", Stack.top(s$2) === 1);159assert_("File \"stack_comp_test.ml\", line 59, characters 41-48", Stack.pop(s$2) === 1);160assert_("File \"stack_comp_test.ml\", line 60, characters 10-17", does_raise(Stack.top, s$2));161assert_("File \"stack_comp_test.ml\", line 61, characters 10-17", does_raise(Stack.top, s$2));162var s$3 = {163 c: /* [] */0,164 len: 0165};166for(var i = 1; i <= 10; ++i){167 Stack.push(i, s$3);168}169Stack.clear(s$3);170assert_("File \"stack_comp_test.ml\", line 68, characters 10-17", s$3.len === 0);171assert_("File \"stack_comp_test.ml\", line 69, characters 10-17", does_raise(Stack.pop, s$3));172assert_("File \"stack_comp_test.ml\", line 70, characters 10-17", Caml_obj.equal(s$3, {173 c: /* [] */0,174 len: 0175 }));176Stack.push(42, s$3);177assert_("File \"stack_comp_test.ml\", line 72, characters 10-17", Stack.pop(s$3) === 42);178var s1 = {179 c: /* [] */0,180 len: 0181};182for(var i$1 = 1; i$1 <= 10; ++i$1){183 Stack.push(i$1, s1);184}185var s2 = Stack.copy(s1);186assert_("File \"stack_comp_test.ml\", line 79, characters 10-17", Caml_obj.equal(to_list(s1), {187 hd: 1,188 tl: {189 hd: 2,190 tl: {191 hd: 3,192 tl: {193 hd: 4,194 tl: {195 hd: 5,196 tl: {197 hd: 6,198 tl: {199 hd: 7,200 tl: {201 hd: 8,202 tl: {203 hd: 9,204 tl: {205 hd: 10,206 tl: /* [] */0207 }208 }209 }210 }211 }212 }213 }214 }215 }216 }));217assert_("File \"stack_comp_test.ml\", line 80, characters 10-17", Caml_obj.equal(to_list(s2), {218 hd: 1,219 tl: {220 hd: 2,221 tl: {222 hd: 3,223 tl: {224 hd: 4,225 tl: {226 hd: 5,227 tl: {228 hd: 6,229 tl: {230 hd: 7,231 tl: {232 hd: 8,233 tl: {234 hd: 9,235 tl: {236 hd: 10,237 tl: /* [] */0238 }239 }240 }241 }242 }243 }244 }245 }246 }247 }));248assert_("File \"stack_comp_test.ml\", line 81, characters 10-17", s1.len === 10);249assert_("File \"stack_comp_test.ml\", line 82, characters 10-17", s2.len === 10);250for(var i$2 = 10; i$2 >= 1; --i$2){251 assert_("File \"stack_comp_test.ml\", line 84, characters 12-19", Stack.pop(s1) === i$2);252}253for(var i$3 = 10; i$3 >= 1; --i$3){254 assert_("File \"stack_comp_test.ml\", line 87, characters 12-19", Stack.pop(s2) === i$3);255}256var s$4 = {257 c: /* [] */0,258 len: 0259};260assert_("File \"stack_comp_test.ml\", line 93, characters 10-17", s$4.c === /* [] */0);261for(var i$4 = 1; i$4 <= 10; ++i$4){262 Stack.push(i$4, s$4);263 assert_("File \"stack_comp_test.ml\", line 96, characters 12-19", s$4.len === i$4);264 assert_("File \"stack_comp_test.ml\", line 97, characters 12-19", s$4.c !== /* [] */0);265}266for(var i$5 = 10; i$5 >= 1; --i$5){267 assert_("File \"stack_comp_test.ml\", line 100, characters 12-19", s$4.len === i$5);268 assert_("File \"stack_comp_test.ml\", line 101, characters 12-19", s$4.c !== /* [] */0);269 Stack.pop(s$4);270}271assert_("File \"stack_comp_test.ml\", line 104, characters 10-17", s$4.len === 0);272assert_("File \"stack_comp_test.ml\", line 105, characters 10-17", s$4.c === /* [] */0);273var s$5 = {274 c: /* [] */0,275 len: 0276};277for(var i$6 = 10; i$6 >= 1; --i$6){278 Stack.push(i$6, s$5);279}280var i$7 = {281 contents: 1282};283List.iter((function (j) {284 assert_("File \"stack_comp_test.ml\", line 112, characters 27-34", i$7.contents === j);285 i$7.contents = i$7.contents + 1 | 0;286 }), s$5.c);287var s1$1 = {288 c: /* [] */0,289 len: 0290};291assert_("File \"stack_comp_test.ml\", line 117, characters 10-17", s1$1.len === 0);292assert_("File \"stack_comp_test.ml\", line 117, characters 45-52", to_list(s1$1) === /* [] */0);293var s2$1 = Stack.copy(s1$1);294assert_("File \"stack_comp_test.ml\", line 119, characters 10-17", s1$1.len === 0);295assert_("File \"stack_comp_test.ml\", line 119, characters 45-52", to_list(s1$1) === /* [] */0);296assert_("File \"stack_comp_test.ml\", line 120, characters 10-17", s2$1.len === 0);297assert_("File \"stack_comp_test.ml\", line 120, characters 45-52", to_list(s2$1) === /* [] */0);298var s1$2 = {299 c: /* [] */0,300 len: 0301};302for(var i$8 = 1; i$8 <= 4; ++i$8){303 Stack.push(i$8, s1$2);304}305assert_("File \"stack_comp_test.ml\", line 126, characters 10-17", s1$2.len === 4);306assert_("File \"stack_comp_test.ml\", line 126, characters 45-52", Caml_obj.equal(to_list(s1$2), {307 hd: 1,308 tl: {309 hd: 2,310 tl: {311 hd: 3,312 tl: {313 hd: 4,314 tl: /* [] */0315 }316 }317 }318 }));319var s2$2 = Stack.copy(s1$2);320assert_("File \"stack_comp_test.ml\", line 128, characters 10-17", s1$2.len === 4);321assert_("File \"stack_comp_test.ml\", line 128, characters 45-52", Caml_obj.equal(to_list(s1$2), {322 hd: 1,323 tl: {324 hd: 2,325 tl: {326 hd: 3,327 tl: {328 hd: 4,329 tl: /* [] */0330 }331 }332 }333 }));334assert_("File \"stack_comp_test.ml\", line 129, characters 10-17", s2$2.len === 4);335assert_("File \"stack_comp_test.ml\", line 129, characters 45-52", Caml_obj.equal(to_list(s2$2), {336 hd: 1,337 tl: {338 hd: 2,339 tl: {340 hd: 3,341 tl: {342 hd: 4,343 tl: /* [] */0344 }345 }346 }347 }));348Mt.from_pair_suites("Stack_comp_test", suites.contents);349exports.suites = suites;...
047-types.js
Source:047-types.js
1const assert_ = require('lib/utils/assert_types')2require('should')3describe('assert_', () => {4 describe('type', () => {5 describe('string', () => {6 it('should throw on false string', () => {7 (() => assert_.type('string', 123)).should.throw();8 (() => assert_.type('string', [ 'iam an array' ])).should.throw();9 (() => assert_.type('string', { iam: 'an object' })).should.throw()10 })11 it('should not throw on true string', () => {12 (() => assert_.type('string', 'im am a string')).should.not.throw()13 })14 })15 describe('number', () => {16 it('should throw on false number', () => {17 (() => assert_.type('number', [ 'iam an array' ])).should.throw();18 (() => assert_.type('number', 'im am a string')).should.throw();19 (() => assert_.type('number', { iam: 'an object' })).should.throw()20 })21 it('should not throw on true number', () => {22 (() => assert_.type('number', 123)).should.not.throw()23 })24 })25 describe('array', () => {26 it('should throw on false array', () => {27 (() => assert_.type('array', 'im am a string')).should.throw();28 (() => assert_.type('array', 123)).should.throw();29 (() => assert_.type('array', { iam: 'an object' })).should.throw()30 })31 it('should not throw on true array', () => {32 (() => assert_.type('array', [ 'iam an array' ])).should.not.throw()33 })34 })35 describe('object', () => {36 it('should throw on false object', () => {37 (() => assert_.type('object', 'im am a string')).should.throw();38 (() => assert_.type('object', 123)).should.throw();39 (() => assert_.type('object', [ 'iam an array' ])).should.throw()40 })41 it('should not throw on true object', () => {42 (() => assert_.type('object', { iam: 'an object' })).should.not.throw()43 })44 })45 describe('promise', () => {46 it('should throw on false promise object', () => {47 (() => assert_.type('promise', 'im am a string')).should.throw();48 (() => assert_.type('promise', 123)).should.throw();49 (() => assert_.type('promise', [ 'iam an array' ])).should.throw();50 (() => assert_.type('promise', { plain: 'object' })).should.throw()51 })52 it('should not throw on promise', () => {53 (() => { assert_.type('promise', Promise.resolve()) }).should.not.throw()54 })55 })56 describe('null', () => {57 it('should throw on false null', () => {58 (() => assert_.type('null', 'im am a string')).should.throw()59 })60 it('should not throw on true null', () => {61 (() => assert_.type('null', null)).should.not.throw()62 })63 })64 describe('undefined', () => {65 it('should throw on false undefined', () => {66 (() => assert_.type('undefined', 'im am a string')).should.throw()67 })68 it('should not throw on true undefined', () => {69 (() => assert_.type('undefined', undefined)).should.not.throw()70 })71 })72 describe('general', () => {73 it('should return the passed object', () => {74 const array = [ 'im an array' ]75 assert_.type('array', array).should.equal(array)76 const obj = { im: 'an array' }77 assert_.type('object', obj).should.equal(obj)78 })79 it('should accept piped types', () => {80 (() => assert_.type('number|null', 1252154)).should.not.throw();81 (() => assert_.type('number|null', null)).should.not.throw();82 (() => assert_.type('number|null', 'what?')).should.throw();83 (() => assert_.type('string|null', 'what?')).should.not.throw()84 })85 it('should throw when none of the piped types is true', () => {86 (() => assert_.type('number|null', 'what?')).should.throw();87 (() => assert_.type('array|string', 123)).should.throw()88 })89 })90 })91 describe('types', () => {92 it('should handle multi arguments type', () => {93 const args = [ 1, '2' ]94 const types = [ 'number', 'string' ];95 (() => assert_.types(types, args)).should.not.throw()96 })97 it('should throw when an argument is of the wrong type', () => {98 const args = [ 1, 2 ]99 const types = [ 'number', 'string' ];100 (() => assert_.types(types, args)).should.throw()101 })102 it('should throw when not enough arguments are passed', () => {103 const args = [ 1 ]104 const types = [ 'number', 'string' ];105 (() => assert_.types(types, args)).should.throw()106 })107 it('should throw when too many arguments are passed', () => {108 const args = [ 1, '2', 3 ]109 const types = [ 'number', 'string' ];110 (() => assert_.types(types, args)).should.throw()111 })112 it('accepts a common type for all the args as a string', () => {113 const types = 'numbers...';114 (() => assert_.types(types, [])).should.not.throw();115 (() => assert_.types(types, [ 1 ])).should.not.throw();116 (() => assert_.types(types, [ 1, 2 ])).should.not.throw();117 (() => assert_.types(types, [ 1, 2, 'foo' ])).should.throw()118 })119 it("should not accept other strings as types that the 's...' interface", () => {120 const types = 'numbers';121 (() => assert_.types(types, [ 1, 2, 3 ])).should.throw()122 })123 it("should accept piped 's...' types", () => {124 const types = 'strings...|numbers...';125 (() => assert_.types(types, [ 1, '2', 3 ])).should.not.throw()126 })127 it("should not accept piped 's...' types if 'arguments' is passed", () => {128 const types = 'strings...';129 // eslint-disable-next-line prefer-arrow/prefer-arrow-functions130 (function () {131 assert_.types(types, arguments)132 }).should.throw("types should be an array when used with 'arguments'")133 })134 })...
gtest_color_test.py
Source:gtest_color_test.py
...55class GTestColorTest(gtest_test_utils.TestCase):56 def testNoEnvVarNoFlag(self):57 """Tests the case when there's neither GTEST_COLOR nor --gtest_color."""58 if not IS_WINDOWS:59 self.assert_(not UsesColor('dumb', None, None))60 self.assert_(not UsesColor('emacs', None, None))61 self.assert_(not UsesColor('xterm-mono', None, None))62 self.assert_(not UsesColor('unknown', None, None))63 self.assert_(not UsesColor(None, None, None))64 self.assert_(UsesColor('linux', None, None))65 self.assert_(UsesColor('cygwin', None, None))66 self.assert_(UsesColor('xterm', None, None))67 self.assert_(UsesColor('xterm-color', None, None))68 self.assert_(UsesColor('xterm-256color', None, None))69 def testFlagOnly(self):70 """Tests the case when there's --gtest_color but not GTEST_COLOR."""71 self.assert_(not UsesColor('dumb', None, 'no'))72 self.assert_(not UsesColor('xterm-color', None, 'no'))73 if not IS_WINDOWS:74 self.assert_(not UsesColor('emacs', None, 'auto'))75 self.assert_(UsesColor('xterm', None, 'auto'))76 self.assert_(UsesColor('dumb', None, 'yes'))77 self.assert_(UsesColor('xterm', None, 'yes'))78 def testEnvVarOnly(self):79 """Tests the case when there's GTEST_COLOR but not --gtest_color."""80 self.assert_(not UsesColor('dumb', 'no', None))81 self.assert_(not UsesColor('xterm-color', 'no', None))82 if not IS_WINDOWS:83 self.assert_(not UsesColor('dumb', 'auto', None))84 self.assert_(UsesColor('xterm-color', 'auto', None))85 self.assert_(UsesColor('dumb', 'yes', None))86 self.assert_(UsesColor('xterm-color', 'yes', None))87 def testEnvVarAndFlag(self):88 """Tests the case when there are both GTEST_COLOR and --gtest_color."""89 self.assert_(not UsesColor('xterm-color', 'no', 'no'))90 self.assert_(UsesColor('dumb', 'no', 'yes'))91 self.assert_(UsesColor('xterm-color', 'no', 'auto'))92 def testAliasesOfYesAndNo(self):93 """Tests using aliases in specifying --gtest_color."""94 self.assert_(UsesColor('dumb', None, 'true'))95 self.assert_(UsesColor('dumb', None, 'YES'))96 self.assert_(UsesColor('dumb', None, 'T'))97 self.assert_(UsesColor('dumb', None, '1'))98 self.assert_(not UsesColor('xterm', None, 'f'))99 self.assert_(not UsesColor('xterm', None, 'false'))100 self.assert_(not UsesColor('xterm', None, '0'))101 self.assert_(not UsesColor('xterm', None, 'unknown'))102if __name__ == '__main__':...
Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!