RegressionTests__CRCTests.st
author Claus Gittinger <cg@exept.de>
Tue, 09 Jul 2019 18:53:03 +0200
changeset 2327 bf482d49aeaf
parent 2150 aef972c78e73
permissions -rw-r--r--
#QUALITY by exept class: RegressionTests::StringTests added: #test82c_expanding
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
     1
"{ Encoding: utf8 }"
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
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:''
2136
58df71c87356 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2134
diff changeset
    11
	category:'tests-Regression-Files and Encodings'
2098
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
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
    70
    "the crc16 variants"
2108
a13e1ed049af #BUGFIX by Stefan Reise
sr
parents: 2107
diff changeset
    71
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
    72
    self skipIf:true description:'fails, by order of cg - skip'.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
    73
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
    74
    "/ 1..9 testVector from 
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
    75
    "/    https://www.lammertbies.nl/comm/info/crc-calculation.html
2108
a13e1ed049af #BUGFIX by Stefan Reise
sr
parents: 2107
diff changeset
    76
2106
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    77
    CRC16Stream flushCrcTables.
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    78
    "/ CRCStream flushCrcTables.
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    79
    "/ CRC32Stream flushCrcTables.
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    80
    self assert:(CRC16Stream newKERMIT hashValueOf:'') = 0.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    81
    self assert:(CRC16Stream newKERMIT hashValueOf:'a') = 16r8F72.
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
    82
    self assert:(CRC16Stream newKERMIT hashValueOf:'abc') = 16rE958.
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    83
    self assert:(CRC16Stream newKERMIT hashValueOf:' ') = 16r0221.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    84
    self assert:(CRC16Stream newKERMIT hashValueOf:'123456789') = 16r8921.
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
    85
    self assert:(CRC16Stream newKERMIT hashValueOf:'Lammert Bies') = 16rF80D.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
    86
    self assert:(CRC16Stream newKERMIT hashValueOf:#[16r06 16r00 16r0c 16rf0 16r00 16r04 16r00 16r55 16r88 16r73 16rc9 16r00 16r00 16r05 16r21]
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
    87
                                                    ) = 16r2098.
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    88
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    89
    self assert:(CRC16Stream newDNP hashValueOf:'') = 16rFFFF.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    90
    self assert:(CRC16Stream newDNP hashValueOf:'a') = 16r50B3.
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
    91
    self assert:(CRC16Stream newDNP hashValueOf:'abc') = 16r57E9.
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    92
    self assert:(CRC16Stream newDNP hashValueOf:' ') = 16r50D6.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    93
    self assert:(CRC16Stream newDNP hashValueOf:'123456789') = 16r82EA.
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
    94
    self assert:(CRC16Stream newDNP hashValueOf:'Lammert Bies') = 16r4583.
2149
40765bd0896a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2148
diff changeset
    95
    self assert:(CRC16Stream newDNP hashValueOf:#[16r06 16r00 16r0c 16rf0 16r00 16r04 16r00 16r55 16r88 16r73 16rc9 16r00 16r00 16r05 16r21]) = 16r7482.
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    96
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
    97
    self assert:(CRC16Stream newMODBUS hashValueOf:'') = 16rFFFF.
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
    98
    self assert:(CRC16Stream newMODBUS hashValueOf:'a') = 16rA87E.
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
    99
    self assert:(CRC16Stream newMODBUS hashValueOf:'abc') = 16r5749.
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
   100
    self assert:(CRC16Stream newMODBUS hashValueOf:' ') = 16r98BE.
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
   101
    self assert:(CRC16Stream newMODBUS hashValueOf:'123456789') = 16r4B37.
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   102
    self assert:(CRC16Stream newMODBUS hashValueOf:'Lammert Bies') = 16rB45C.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   103
    self assert:(CRC16Stream newMODBUS hashValueOf:#[16r06 16r00 16r0c 16rf0 16r00 16r04 16r00 16r55 16r88 16r73 16rc9 16r00 16r00 16r05 16r21]
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   104
                                                    ) = 16rF50C.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   105
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   106
    self assert:(CRC16Stream newXMODEM hashValueOf:'') = 0.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   107
    self assert:(CRC16Stream newXMODEM hashValueOf:'a') = 16r7C87.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   108
    self assert:(CRC16Stream newXMODEM hashValueOf:'abc') = 16r9dd6.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   109
    self assert:(CRC16Stream newXMODEM hashValueOf:' ') = 16r2462.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   110
    self assert:(CRC16Stream newXMODEM hashValueOf:'123456789') = 16r31C3.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   111
    self assert:(CRC16Stream newXMODEM hashValueOf:'Lammert Bies') = 16rCEC8.
2149
40765bd0896a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2148
diff changeset
   112
    self assert:(CRC16Stream newXMODEM hashValueOf:#[16r06 16r00 16r0c 16rf0 16r00 16r04 16r00 16r55 16r88 16r73 16rc9 16r00 16r00 16r05 16r21]) = 16r3B38.
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
   113
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
   114
    self assert:(CRC16Stream newCRC_16 hashValueOf:'') = 0.
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   115
    self assert:(CRC16Stream newCRC_16 hashValueOf:'a') = 16rE8C1.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   116
    self assert:(CRC16Stream newCRC_16 hashValueOf:'abc') = 16r9738.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   117
    self assert:(CRC16Stream newCRC_16 hashValueOf:' ') = 16rD801.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   118
    self assert:(CRC16Stream newCRC_16 hashValueOf:'123456789') = 16rBB3D.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   119
    self assert:(CRC16Stream newCRC_16 hashValueOf:'Lammert Bies') = 16rB638.
2149
40765bd0896a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2148
diff changeset
   120
    self assert:(CRC16Stream newCRC_16 hashValueOf:#[16r06 16r00 16r0c 16rf0 16r00 16r04 16r00 16r55 16r88 16r73 16rc9 16r00 16r00 16r05 16r21]) = 16r4A4C.
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
   121
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   122
    "/ CCITT with 0xFFFF as start
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   123
    self assert:(CRC16Stream newCCITT hashValueOf:'') = 16rFFFF.
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
   124
    self assert:(CRC16Stream newCCITT hashValueOf:'a') = 16r9D77.
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   125
    self assert:(CRC16Stream newCCITT hashValueOf:'abc') = 16r514A.
2107
c318ea211c64 #TUNING by cg
Claus Gittinger <cg@exept.de>
parents: 2106
diff changeset
   126
    self assert:(CRC16Stream newCCITT hashValueOf:' ') = 16rC592.
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   127
    self assert:(CRC16Stream newCCITT hashValueOf:'123456789') = 16r29B1.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   128
    self assert:(CRC16Stream newCCITT hashValueOf:'Lammert Bies') = 16r4A31.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   129
    self assert:(CRC16Stream newCCITT hashValueOf:#[16r06 16r00 16r0c 16rf0 16r00 16r04 16r00 16r55 16r88 16r73 16rc9 16r00 16r00 16r05 16r21]
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   130
                                                   ) = 16r75FB.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   131
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   132
    "/ CCITT with 0x1D0F as start
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   133
    self assert:(CRC16Stream newCCITT_1D0F hashValueOf:'') = 16r1D0F.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   134
    self assert:(CRC16Stream newCCITT_1D0F hashValueOf:'a') = 16rB01B.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   135
    self assert:(CRC16Stream newCCITT_1D0F hashValueOf:'abc') = 16r8CDA.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   136
    self assert:(CRC16Stream newCCITT_1D0F hashValueOf:' ') = 16rE8FE.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   137
    self assert:(CRC16Stream newCCITT_1D0F hashValueOf:'123456789') = 16rE5CC.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   138
    self assert:(CRC16Stream newCCITT_1D0F hashValueOf:'Lammert Bies') = 16r67A2.
2149
40765bd0896a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2148
diff changeset
   139
    self assert:(CRC16Stream newCCITT_1D0F hashValueOf:#[16r06 16r00 16r0c 16rf0 16r00 16r04 16r00 16r55 16r88 16r73 16rc9 16r00 16r00 16r05 16r21]) = 16rFCD4.
2106
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
   140
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
   141
    "Created: / 16-03-2019 / 23:40:26 / Claus Gittinger"
2108
a13e1ed049af #BUGFIX by Stefan Reise
sr
parents: 2107
diff changeset
   142
    "Modified: / 19-03-2019 / 11:23:27 / Stefan Reise"
2149
40765bd0896a #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2148
diff changeset
   143
    "Modified (format): / 24-03-2019 / 21:03:06 / Claus Gittinger"
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   144
!
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   145
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   146
test04_crc8
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   147
    "the crc8 variants"
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   149
    self skipIf:true description:'fails, by order of cg - skip'.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   150
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   151
    CRC8Stream flushCrcTables.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   152
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   153
    "/ test vectors from AUTOSAR_SWS_CRCLibrary.pdf
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   154
    self assert:(CRC8Stream newSAE_J1850 hashValueOf:'') = 0.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   155
    self assert:(CRC8Stream newSAE_J1850 hashValueOf:#[0 0 0 0] ) = 16r59.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   156
    self assert:(CRC8Stream newSAE_J1850 hashValueOf:#[16rF2 16r01 16r83]) = 16r37.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   157
    self assert:(CRC8Stream newSAE_J1850 hashValueOf:#[16r0F 16rAA 16r99 16r55]) = 16r79.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   158
    self assert:(CRC8Stream newSAE_J1850 hashValueOf:#[16r00 16rFF 16r55 16r11]) = 16rB8.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   159
    self assert:(CRC8Stream newSAE_J1850 hashValueOf:#[16r33 16r22 16r55 16rAA 16rBB 16rCC 16rDD 16rEE 16rFF]) = 16rCB.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   160
    self assert:(CRC8Stream newSAE_J1850 hashValueOf:#[16r92 16r6B 16r55]) = 16r8C.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   161
    self assert:(CRC8Stream newSAE_J1850 hashValueOf:#[16rFF 16rFF 16rFF 16rFF]) = 16r74.
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   162
2150
aef972c78e73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2149
diff changeset
   163
    "/ test vectors from AUTOSAR_SWS_CRCLibrary.pdf
aef972c78e73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2149
diff changeset
   164
    "/ self assert:(CRC8Stream new_2F hashValueOf:'') = 0.
aef972c78e73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2149
diff changeset
   165
    self assert:(CRC8Stream new_2F hashValueOf:#[0 0 0 0] ) = 16r12.
aef972c78e73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2149
diff changeset
   166
    self assert:(CRC8Stream new_2F hashValueOf:#[16rF2 16r01 16r83]) = 16rC2.
aef972c78e73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2149
diff changeset
   167
    self assert:(CRC8Stream new_2F hashValueOf:#[16r0F 16rAA 16r99 16r55]) = 16rC6.
aef972c78e73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2149
diff changeset
   168
    self assert:(CRC8Stream new_2F hashValueOf:#[16r00 16rFF 16r55 16r11]) = 16r77.
aef972c78e73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2149
diff changeset
   169
    self assert:(CRC8Stream new_2F hashValueOf:#[16r33 16r22 16r55 16rAA 16rBB 16rCC 16rDD 16rEE 16rFF]) = 16r11.
aef972c78e73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2149
diff changeset
   170
    self assert:(CRC8Stream new_2F hashValueOf:#[16r92 16r6B 16r55]) = 16r33.
aef972c78e73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2149
diff changeset
   171
    self assert:(CRC8Stream new_2F hashValueOf:#[16rFF 16rFF 16rFF 16rFF]) = 16r6C.
aef972c78e73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2149
diff changeset
   172
2148
7b5e4c70aa5b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 2136
diff changeset
   173
    "Created: / 24-03-2019 / 12:03:54 / Claus Gittinger"
2150
aef972c78e73 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2149
diff changeset
   174
    "Modified: / 25-03-2019 / 14:25:02 / Claus Gittinger"
2132
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   175
!
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   176
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   177
test99_speed
2134
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   178
    |oneTest speedTest|
2132
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   179
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   180
    self skipIf:true description:'speedtest; not part of automated test suite'.
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   181
2134
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   182
    oneTest := [:name :hashStream :n :s |
2132
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   183
        |l t nMb|
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   184
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   185
        l := s size.
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   186
        t := Time millisecondsToRun:[
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   187
                n timesRepeat:[
2134
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   188
                        hashStream nextPutAll:s
2132
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   189
                ].
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   190
             ].
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   191
        t := (t / 1000) asFloat.
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   192
        nMb := n*l/1024/1024.
2134
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   193
        Transcript showCR:'%1: %2 (chunk size %3)' with:name with:(hashStream hashValue hexPrintString) with:l.
2132
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   194
        Transcript showCR:'  %1 seconds for %2 Mb' with:t with:(nMb asFixedPoint:2).
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   195
        Transcript showCR:'  %1 Mb/s' with:((nMb / t) asFixedPoint:2).
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   196
    ].
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   197
2134
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   198
    speedTest := [:name :hashStreamMaker |
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   199
        Transcript showCR:'-----------------------'.
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   200
        oneTest 
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   201
            value:name value:(hashStreamMaker value) value:2000000
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   202
            value:'1234567890'.
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   203
        oneTest
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   204
            value:name value:(hashStreamMaker value) value:2000000
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   205
            value:'12345678901234567890123456789012345678901234567890'.
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   206
        oneTest
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   207
            value:name value:(hashStreamMaker value) value:200000
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   208
            value:('12345678901234567890123456789012345678901234567890' ,* 20).
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   209
        oneTest
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   210
            value:name value:(hashStreamMaker value) value:20000
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   211
            value:('12345678901234567890123456789012345678901234567890' ,* 1000).
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   212
    ].
2132
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   213
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   214
    speedTest 
2134
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   215
        value:'crc32' value:[CRC32Stream new].
2132
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   216
    speedTest 
2134
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   217
        value:'crc32 castagnoli' value:[CRC32Stream newCastagnoli].
2132
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   218
0ecd8352f5a1 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 2108
diff changeset
   219
    "Created: / 23-03-2019 / 09:53:58 / Claus Gittinger"
2134
5343904b23a1 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
   220
    "Modified: / 23-03-2019 / 14:41:14 / Claus Gittinger"
2098
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
! !
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
!CRCTests class methodsFor:'documentation'!
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
version_CVS
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    ^ '$Header$'
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
! !
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   228