RegressionTests__CRCTests.st
author Claus Gittinger <cg@exept.de>
Sun, 17 Mar 2019 01:12:49 +0100
changeset 2106 288fa2469be2
parent 2098 8cf7cbaf99fb
child 2107 c318ea211c64
permissions -rw-r--r--
#REFACTORING by cg class: RegressionTests::CRCTests added: #test02_crc32c #test03_crc16 removed: #test01_crc32c
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
    
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
    self assert:(CRC32Stream new hashValueOf:'') = 0.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
    self assert:(CRC32Stream new hashValueOf:'resume') = 16r60C1D0A0.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
    self assert:(CRC32Stream new hashValueOf:#[1 2 3 4 5 6 7]) = 16r70E46888.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    self assert:(CRC32Stream new hashValueOf:(ByteArray new:40 withAll:16rFF)) = 16r8CD04C73.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    self assert:(CRC32Stream new hashValueOf:'123456789') = 16rCBF43926.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    "Created: / 16-03-2019 / 23:22:34 / Claus Gittinger"
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    44
!
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
2106
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    46
test02_crc32c
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    47
    "the Castagnoli crc32"
2098
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
    
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
    self assert:(CRC32Stream newCrc32c hashValueOf:'') = 0.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    self assert:(CRC32Stream newCrc32c hashValueOf:'a') = 16rC1D04330.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
    self assert:(CRC32Stream newCrc32c hashValueOf:'123456789') = 16rE3069283.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    self assert:(CRC32Stream newCrc32c hashValueOf:(ByteArray new:32 withAll:0)) = 16r8A9136AA.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    self assert:(CRC32Stream newCrc32c hashValueOf:(ByteArray new:32 withAll:16rFF)) = 16r62a8ab43.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    self assert:(CRC32Stream newCrc32c hashValueOf:((0 to:31) asByteArray)) = 16r46dd794e.
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
2106
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    56
    "Created: / 16-03-2019 / 23:39:52 / Claus Gittinger"
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    57
!
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    58
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    59
test03_crc16
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    60
    "the default ccitt crc16"
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    61
    
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    62
    CRC16Stream flushCrcTables.
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    63
    "/ CRCStream flushCrcTables.
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    64
    "/ CRC32Stream flushCrcTables.
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    65
    self assert:(CRC16Stream new hashValueOf:#[16rFC 5 16r11]) = 16r2756.
288fa2469be2 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 2098
diff changeset
    66
    self assert:(CRC16Stream new hashValueOf:'123456789') = 16r8921.
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
    "Created: / 16-03-2019 / 23:40:26 / Claus Gittinger"
2098
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
! !
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
!CRCTests class methodsFor:'documentation'!
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    72
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
version_CVS
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
    ^ '$Header$'
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
! !
8cf7cbaf99fb initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76