RegressionTests__CRCTests.st
author sr
Tue, 19 Mar 2019 11:23:37 +0100
changeset 2108 a13e1ed049af
parent 2107 c318ea211c64
child 2132 0ecd8352f5a1
permissions -rw-r--r--
#BUGFIX by Stefan Reise class: RegressionTests::CRCTests class definition added: #test01_crc32 #test02_crc32c #test03_crc16 class: RegressionTests::CRCTests class added: #documentation #version_CVS
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2106
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
     1
"{ Encoding: utf8 }"
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
     2
2098
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ Package: 'stx:goodies/regression' }"
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
"{ NameSpace: RegressionTests }"
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
TestCase subclass:#CRCTests
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	instanceVariableNames:''
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
	classVariableNames:''
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
	poolDictionaries:''
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
	category:'tests-Regression-Streams'
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
!CRCTests class methodsFor:'documentation'!
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
documentation
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    17
"
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    18
    documentation to be added.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
    [author:]
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
        Claus Gittinger
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
    [instance variables:]
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
    [class variables:]
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
    [see also:]
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
"
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
! !
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
!CRCTests methodsFor:'tests'!
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
test01_crc32
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
    "the default ccitt crc32"
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
    
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    37
    CRC32Stream flushCrcTables.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    38
2098
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
    self assert:(CRC32Stream new hashValueOf:'') = 0.
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    40
    self assert:(CRC32Stream new hashValueOf:'a') = 16rE8B7BE43.
2098
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    self assert:(CRC32Stream new hashValueOf:'resume') = 16r60C1D0A0.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
    self assert:(CRC32Stream new hashValueOf:#[1 2 3 4 5 6 7]) = 16r70E46888.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    self assert:(CRC32Stream new hashValueOf:(ByteArray new:40 withAll:16rFF)) = 16r8CD04C73.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
    self assert:(CRC32Stream new hashValueOf:'123456789') = 16rCBF43926.
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    45
    self assert:(CRC32Stream new hashValueOf:'Lammert Bies') = 16r43C04CA6.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    46
    self assert:(CRC32Stream new hashValueOf:' ') = 16rE96CCF45.
2098
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    "Created: / 16-03-2019 / 23:22:34 / Claus Gittinger"
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    49
    "Modified (comment): / 17-03-2019 / 14:08:26 / Claus Gittinger"
2098
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
!
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
2106
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    52
test02_crc32c
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    53
    "the Castagnoli crc32"
2098
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    55
    CRC32Stream flushCrcTables.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    56
2098
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    self assert:(CRC32Stream newCrc32c hashValueOf:'') = 0.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    self assert:(CRC32Stream newCrc32c hashValueOf:'a') = 16rC1D04330.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    self assert:(CRC32Stream newCrc32c hashValueOf:'123456789') = 16rE3069283.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    self assert:(CRC32Stream newCrc32c hashValueOf:(ByteArray new:32 withAll:0)) = 16r8A9136AA.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    self assert:(CRC32Stream newCrc32c hashValueOf:(ByteArray new:32 withAll:16rFF)) = 16r62a8ab43.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    self assert:(CRC32Stream newCrc32c hashValueOf:((0 to:31) asByteArray)) = 16r46dd794e.
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    63
    self assert:(CRC32Stream newCrc32c hashValueOf:(ByteArray new:1000000)) = 16r71AF9A4E.
2098
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
2106
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    65
    "Created: / 16-03-2019 / 23:39:52 / Claus Gittinger"
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    66
    "Modified: / 17-03-2019 / 16:56:14 / Claus Gittinger"
2106
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    67
!
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    68
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    69
test03_crc16
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    70
    "the default ccitt crc16"
2108
a13e1ed049af #BUGFIX by Stefan Reise
sr
parents: 2107
diff changeset
    71
a13e1ed049af #BUGFIX by Stefan Reise
sr
parents: 2107
diff changeset
    72
    self skipIf:true description:'fails, in order of cg skip'.
a13e1ed049af #BUGFIX by Stefan Reise
sr
parents: 2107
diff changeset
    73
2106
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    74
    CRC16Stream flushCrcTables.
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    75
    "/ CRCStream flushCrcTables.
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    76
    "/ CRC32Stream flushCrcTables.
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    77
    self assert:(CRC16Stream newKERMIT hashValueOf:'') = 0.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    78
    self assert:(CRC16Stream newKERMIT hashValueOf:'a') = 16r8F72.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    79
    self assert:(CRC16Stream newKERMIT hashValueOf:' ') = 16r0221.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    80
    self assert:(CRC16Stream newKERMIT hashValueOf:'123456789') = 16r8921.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    81
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    82
    self assert:(CRC16Stream newDNP hashValueOf:'') = 16rFFFF.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    83
    self assert:(CRC16Stream newDNP hashValueOf:'a') = 16r50B3.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    84
    self assert:(CRC16Stream newDNP hashValueOf:' ') = 16r50D6.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    85
    self assert:(CRC16Stream newDNP hashValueOf:'123456789') = 16r82EA.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    86
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    87
    self assert:(CRC16Stream newMODBUS hashValueOf:'') = 0.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    88
    self assert:(CRC16Stream newMODBUS hashValueOf:'a') = 16rA87E.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    89
    self assert:(CRC16Stream newMODBUS hashValueOf:' ') = 16r98BE.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    90
    self assert:(CRC16Stream newMODBUS hashValueOf:'123456789') = 16r4B37.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    91
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    92
    self assert:(CRC16Stream newCRC_16 hashValueOf:'') = 0.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    93
    self assert:(CRC16Stream newCRC_16 hashValueOf:'a') = 16r50B3.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    94
    self assert:(CRC16Stream newCRC_16 hashValueOf:' ') = 16r50D6.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    95
    self assert:(CRC16Stream newCRC_16 hashValueOf:'123456789') = 16rBB3d.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    96
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    97
    self assert:(CRC16Stream newCCITT hashValueOf:'') = 0.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    98
    self assert:(CRC16Stream newCCITT hashValueOf:'a') = 16r9D77.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    99
    self assert:(CRC16Stream newCCITT hashValueOf:' ') = 16rC592.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
   100
    self assert:(CRC16Stream newCCITT hashValueOf:'123456789') = 16r8921.
2106
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
   101
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
   102
    "Created: / 16-03-2019 / 23:40:26 / Claus Gittinger"
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
   103
    "Modified: / 17-03-2019 / 15:10:28 / Claus Gittinger"
2108
a13e1ed049af #BUGFIX by Stefan Reise
sr
parents: 2107
diff changeset
   104
    "Modified: / 19-03-2019 / 11:23:27 / Stefan Reise"
2098
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
! !
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
!CRCTests class methodsFor:'documentation'!
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
version_CVS
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    ^ '$Header$'
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
! !
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112