RegressionTests__QueueTest.st
author Claus Gittinger <cg@exept.de>
Wed, 07 Sep 2016 15:25:27 +0200
changeset 1534 65f4fdae8ad0
parent 1447 2351db93aa5b
child 1564 2a4963ef3a4a
child 1691 684012a746c0
permissions -rw-r--r--
#QUALITY by cg class: RegressionTests::QueueTest added: #coveredClassNames #testChangeCapacity
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
     1
"{ Package: 'stx:goodies/regression' }"
171
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     2
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     3
"{ NameSpace: RegressionTests }"
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
TestCase subclass:#QueueTest
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
	instanceVariableNames:''
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
	classVariableNames:''
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	poolDictionaries:''
1057
0d8367313171 category
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
     9
	category:'tests-Regression-Collections'
171
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
!
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    11
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
1534
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
    13
!QueueTest class methodsFor:'queries'!
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
    14
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
    15
coveredClassNames
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
    16
    ^ #( Queue )
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
    17
! !
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
    18
171
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    19
!QueueTest methodsFor:'Testing'!
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    20
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    21
testBasic1
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    22
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    23
    |q el|
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    24
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    25
    q := Queue new:5.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
    self assert:q isEmpty.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
    self assert:q size == 0.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
    q nextPut:1.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    29
    self assert:q notEmpty.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    30
    self assert:q size == 1.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    31
    q nextPut:2.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    32
    self assert:q notEmpty.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    33
    self assert:q size == 2.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    34
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    35
    self assert:q notEmpty.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    36
    self assert:q size == 1.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    37
    self assert:(el==1).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    38
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    39
    self assert:q isEmpty.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    40
    self assert:q size == 0.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    41
    self assert:(el==2).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    42
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    43
    "
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
    44
     self new testBasic1
171
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    45
    "
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    46
!
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    47
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    48
testBasic2
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    49
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    50
    |q el|
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    51
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    52
    q := Queue new:5.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    53
    self assert:q isEmpty.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    54
    self assert:q size == 0.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    55
    q nextPut:1.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    56
    q nextPut:2.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    57
    q nextPut:3.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    58
    q nextPut:4.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    59
    q nextPut:5.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    60
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    61
    self assert:(el==1).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    62
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    63
    self assert:(el==2).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    64
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    65
    self assert:(el==3).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    66
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    67
    self assert:(el==4).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    68
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    69
    self assert:(el==5).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    70
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    71
    "
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
    72
     self new testBasic2
171
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    73
    "
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    74
!
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    75
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    76
testBasic3
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    77
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    78
    |q el|
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    79
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    80
    q := Queue new:5.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    81
    self assert:q isEmpty.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    82
    self assert:q size == 0.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    83
    q nextPut:1.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    84
    q nextPut:2.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    85
    q nextPut:3.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    86
    q nextPut:4.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    87
    q nextPut:5.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    88
    self should:[q nextPut:6] raise:Error.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    89
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    90
    self assert:(el==1).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    91
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    92
    self assert:(el==2).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    93
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    94
    self assert:(el==3).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    95
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    96
    self assert:(el==4).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    97
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    98
    self assert:(el==5).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    99
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   100
    "
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
   101
     self new testBasic3
171
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   102
    "
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   103
!
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   104
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   105
testBasic4
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   106
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   107
    |q el|
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   108
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   109
    q := Queue new:5.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   110
    self assert:q isEmpty.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   111
    self assert:q size == 0.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   112
    q nextPut:1.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   113
    q nextPutFirst:2.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   114
    q nextPutFirst:3.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   115
    q nextPutFirst:4.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   116
    q nextPutFirst:5.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   117
    self should:[q nextPutFirst:6] raise:Error.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   118
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   119
    self assert:(el==5).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   120
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   121
    self assert:(el==4).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   122
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   123
    self assert:(el==3).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   124
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   125
    self assert:(el==2).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   126
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   127
    self assert:(el==1).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   128
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   129
    "
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
   130
     self new testBasic4
171
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   131
    "
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   132
!
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   133
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   134
testBasic5
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   135
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   136
    |q el|
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   137
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   138
    q := Queue new:5.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   139
    self assert:q isEmpty.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   140
    self assert:q size == 0.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   141
    q nextPutFirst:1.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   142
    q nextPutFirst:2.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   143
    q nextPutFirst:3.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   144
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   145
    self assert:(el==3).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   146
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   147
    self assert:(el==2).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   148
    el := q next.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   149
    self assert:(el==1).
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   150
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   151
    "
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
   152
     self new testBasic5
171
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   153
    "
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   154
!
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   155
1534
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   156
testChangeCapacity
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   157
    "tests all kinds of boundary conditions in the capacity-change code
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   158
     (i.e. especially wraps)"
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   159
     
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   160
     |q|
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   161
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   162
     #(false true) do:[:wrap |
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   163
        1 to:10 do:[:fill |
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   164
            1 to:fill do:[:read |
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   165
                 Transcript show:'wrap: '; show:wrap; show:' fill: '; show:fill; show:' read: '; showCR:read.
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   166
                
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   167
                 q := Queue new:10.
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   168
                 self assert:(q capacity == 10).
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   169
                 wrap ifTrue:[
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   170
                     1 to:5 do:[:i | q nextPut:#foo ].
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   171
                 ].
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   172
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   173
                 1 to:fill do:[:i | q nextPut:i.
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   174
                                    (i==1 and:[wrap]) ifTrue:[ 1 to:5 do:[:i | q next ] ].
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   175
                              ].
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   176
                "/ (wrap and:[fill==9 and:[read == 8]]) ifTrue:[self halt].
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   177
                 read timesRepeat:[ q next ].
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   178
                 q capacity:12.
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   179
                 self assert:(q capacity == 12).
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   180
                 self assert:(q size == (fill-read)).
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   181
                 self assert:((Array streamContents:[:s | q do:[:e |s nextPut:e]]) = (read+1 to:fill) asArray).
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   182
                 self assert:(q size == (fill-read)).
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   183
                 fill==read ifTrue:[
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   184
                     self assert:(q isEmpty).
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   185
                     self assert:(q notEmpty not).
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   186
                     self assert:(q size == 0).
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   187
                     self assert:(q nextOrNil == nil).
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   188
                     self assert:(q peekOrNil == nil).
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   189
                     self should:[q at:1] raise:SubscriptOutOfBoundsError.
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   190
                 ] ifFalse:[
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   191
                     self assert:(q notEmpty).
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   192
                     self assert:(q isEmpty not).
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   193
                     self assert:(q at:1) == (read+1).
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   194
                     self assert:(q peek) == (read+1).
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   195
                     self assert:(q peekOrNil) == (read+1).
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   196
                 ].        
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   197
            ].    
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   198
        ].    
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   199
     ]. 
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   200
!
65f4fdae8ad0 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   201
171
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   202
testRemoveAll
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   203
    0 to:10 do:[:i|
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1057
diff changeset
   204
	self removeAllSize:10 fill:i.
171
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   205
    ].
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   206
! !
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   207
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   208
!QueueTest methodsFor:'helpers'!
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   209
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   210
removeAllSize:size fill:fill
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   211
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   212
    |q|
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   213
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   214
    q := Queue new:size.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   215
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   216
    1 to:fill do:[:i|
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   217
	q nextPut:i.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   218
    ].
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   219
    q removeAll.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   220
    self assert:q isEmpty.
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   221
! !
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   222
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   223
!QueueTest class methodsFor:'documentation'!
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   224
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   225
version
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   226
    ^ '$Header$'
21c0c65568af initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   227
! !
1057
0d8367313171 category
Claus Gittinger <cg@exept.de>
parents: 181
diff changeset
   228