import 'mocha' ; import * as assert from 'assert' ; import ErrorCorrectionLevel from './../../../../core/qrcode/decoder/ErrorCorrectionLevel' ; import FormatInformation from './../../../../core/qrcode/decoder/FormatInformation' ; author Sean Owen
  describe ( "FormatInformationTestCase" , ( ) => { const MASKED_TEST_FORMAT_INFO = 0x2BED ; const UNMASKED_TEST_FORMAT_INFO = MASKED_TEST_FORMAT_INFO ^ 0x5412 ; it ( "testBitsDiffering" , ( ) => { assert . strictEqual ( FormatInformation . numBitsDiffering ( 1 , 1 ) , 0 ) ; assert . strictEqual ( FormatInformation . numBitsDiffering ( 0 , 2 ) , 1 ) ; assert . strictEqual ( FormatInformation . numBitsDiffering ( 1 , 2 ) , 2 ) ; assert . strictEqual ( FormatInformation . numBitsDiffering ( - 1 , 0 ) , 32 ) ; } ) ; it ( "testDecode" , ( ) => { const expected = FormatInformation . decodeFormatInformation ( MASKED_TEST_FORMAT_INFO , MASKED_TEST_FORMAT_INFO ) ; assert . strictEqual ( null !== expected , true ) ; assert . strictEqual ( expected . getDataMask ( ) , 0x07 ) ; assert . strictEqual ( ErrorCorrectionLevel . Q . equals ( expected . getErrorCorrectionLevel ( ) ) , true ) ; assert . strictEqual ( FormatInformation . decodeFormatInformation ( UNMASKED_TEST_FORMAT_INFO , MASKED_TEST_FORMAT_INFO ) . equals ( expected ) , true ) ; } ) ; it ( "testDecodeWithBitDifference" , ( ) => { const expected = FormatInformation . decodeFormatInformation ( MASKED_TEST_FORMAT_INFO , MASKED_TEST_FORMAT_INFO ) ; assert . strictEqual ( FormatInformation . decodeFormatInformation ( MASKED_TEST_FORMAT_INFO ^ 0x01 , MASKED_TEST_FORMAT_INFO ^ 0x01 ) . equals ( expected ) , true ) ; assert . strictEqual ( FormatInformation . decodeFormatInformation ( MASKED_TEST_FORMAT_INFO ^ 0x03 , MASKED_TEST_FORMAT_INFO ^ 0x03 ) . equals ( expected ) , true ) ; assert . strictEqual ( FormatInformation . decodeFormatInformation ( MASKED_TEST_FORMAT_INFO ^ 0x07 , MASKED_TEST_FORMAT_INFO ^ 0x07 ) . equals ( expected ) , true ) ; assert . strictEqual ( null === FormatInformation . decodeFormatInformation ( MASKED_TEST_FORMAT_INFO ^ 0x0F , MASKED_TEST_FORMAT_INFO ^ 0x0F ) , true ) ; } ) ; it ( "testDecodeWithMisread" , ( ) => { const expected = FormatInformation . decodeFormatInformation ( MASKED_TEST_FORMAT_INFO , MASKED_TEST_FORMAT_INFO ) ; assert . strictEqual ( FormatInformation . decodeFormatInformation ( MASKED_TEST_FORMAT_INFO ^ 0x03 , MASKED_TEST_FORMAT_INFO ^ 0x0F ) . equals ( expected ) , true ) ; } ) ; } ) ;