RegressionTests__TimeDurationTest.st
author Claus Gittinger <cg@exept.de>
Thu, 17 May 2018 23:31:05 +0200
changeset 1939 9a6e4956515f
parent 1926 139e97e95b07
child 1941 0ae2e86f50cf
permissions -rw-r--r--
#BUGFIX by cg class: RegressionTests::CacheDictionaryTest added: #testSizes
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
     1
"{ Encoding: utf8 }"
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
     2
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
     3
"{ Package: 'stx:goodies/regression' }"
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     4
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     5
"{ NameSpace: RegressionTests }"
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     6
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     7
TestCase subclass:#TimeDurationTest
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     8
	instanceVariableNames:''
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
     9
	classVariableNames:''
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    10
	poolDictionaries:''
1078
a4829ce2f3f1 category change
Claus Gittinger <cg@exept.de>
parents: 678
diff changeset
    11
	category:'tests-Regression-DateAndTime'
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    12
!
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    13
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    14
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    15
!TimeDurationTest methodsFor:'Testing'!
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    17
test_00_Basic
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    18
    |t|
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    19
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    20
    t := TimeDuration fromSeconds:1.
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    21
    self assert:(t asSeconds = 1).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    22
    self assert:(t asMilliseconds == 1000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    23
    self assert:(t asMicroseconds = 1000000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    24
    self assert:(t asNanoseconds = 1000000000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    25
    self assert:(t asPicoseconds = 1000000000000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    26
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    27
    t := TimeDuration fromSeconds:1.5.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    28
    self assert:(t asSeconds = 1).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    29
    self assert:(t asTruncatedSeconds == 1).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    30
    self assert:(t asExactSeconds = 1.5).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    31
    self assert:(t asMilliseconds == 1500).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    32
    self assert:(t asMicroseconds = 1500000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    33
    self assert:(t asNanoseconds = 1500000000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    34
    self assert:(t asPicoseconds = 1500000000000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    35
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    36
    t := TimeDuration fromMilliseconds:345.
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    37
    self assert:(t asSeconds = 0).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    38
    self assert:(t asExactSeconds = 0.345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    39
    self assert:(t asTruncatedSeconds = 0).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    40
    self assert:(t asMilliseconds == 345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    41
    self assert:(t asMicroseconds = 345000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    42
    self assert:(t asNanoseconds = 345000000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    43
    self assert:(t asPicoseconds = 345000000000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    44
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    45
    t := TimeDuration fromMicroseconds:345.
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    46
    self assert:(t asExactSeconds = 0.000345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    47
    self assert:(t asTruncatedSeconds = 0).
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    48
    self assert:(t asExactMilliseconds = 0.345).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    49
    self assert:(t asTruncatedMilliseconds == 0).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    50
    self assert:(t asMicroseconds = 345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    51
    self assert:(t asNanoseconds = 345000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    52
    self assert:(t asPicoseconds = 345000000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    53
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    54
    t := TimeDuration fromNanoseconds:345.
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    55
    self assert:(t asExactSeconds = 0.000000345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    56
    self assert:(t asTruncatedSeconds = 0).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    57
    self assert:(t asTruncatedMilliseconds == 0).
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    58
    self assert:(t asExactMilliseconds = 0.000345).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    59
    self assert:(t asTruncatedMicroseconds = 0).
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    60
    self assert:(t asExactMicroseconds = 0.345).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    61
    self assert:(t asNanoseconds = 345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    62
    self assert:(t asPicoseconds = 345000).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    63
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    64
    t := TimeDuration fromPicoseconds:345.
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    65
    self assert:(t asExactSeconds = 0.000000000345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    66
    self assert:(t asTruncatedSeconds = 0).
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    67
    self assert:(t asExactMilliseconds = 0.000000345).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    68
    self assert:(t asTruncatedMilliseconds == 0).
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    69
    self assert:(t asExactMicroseconds = 0.000345).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    70
    self assert:(t asTruncatedMicroseconds = 0).
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
    71
    self assert:(t asExactNanoseconds = 0.345).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    72
    self assert:(t asTruncatedNanoseconds = 0).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    73
    self assert:(t asPicoseconds = 345).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
    74
1923
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
    75
    t := TimeDuration fromMicroseconds:-10001.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
    76
    self assert:(t asExactMicroseconds = -10001).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
    77
1926
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    78
    (4 to:4000000000000000000 byFactor:1000) do:[:v |
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    79
        self assert:(t := TimeDuration new setPicoseconds:v) asPicoseconds = v.
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    80
        self assert:(t := TimeDuration fromPicoseconds:v) asPicoseconds = v.
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    81
        self assert:(t := v picoseconds) asPicoseconds = v.
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    82
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    83
        self assert:(t := TimeDuration new setNanoseconds:v) asNanoseconds = v.
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    84
        self assert:(t := TimeDuration fromNanoseconds:v) asNanoseconds = v.
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    85
        self assert:(t := v nanoseconds) asNanoseconds = v.
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    86
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    87
    ].
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    88
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    89
    self assert:(t := 4 picoseconds) printString = ('4ps').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    90
    self assert:(t := 40 picoseconds) printString = ('40ps').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    91
    self assert:(t := 400 picoseconds) printString = ('400ps').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    92
    self assert:(t := 4000 picoseconds) printString = ('4ns').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    93
    self assert:(4000 picoseconds = 4 nanoseconds).
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    94
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    95
    self assert:(t := 4 nanoseconds) printString = ('4ns').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    96
    self assert:(t := 40 nanoseconds) printString = ('40ns').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    97
    self assert:(t := 400 nanoseconds) printString = ('400ns').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    98
    self assert:(t := 4000 nanoseconds) printString = ('4us').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
    99
    self assert:(4000 nanoseconds = 4 microseconds).
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   100
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   101
    self assert:(t := 4 microseconds) printString = ('4us').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   102
    self assert:(t := 40 microseconds) printString = ('40us').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   103
    self assert:(t := 400 microseconds) printString = ('400us').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   104
    self assert:(t := 4000 microseconds) printString = ('4ms').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   105
    self assert:(4000 microseconds = 4 milliseconds).
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   106
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   107
    self assert:(t := 4 milliseconds) printString = ('4ms').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   108
    self assert:(t := 40 milliseconds) printString = ('40ms').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   109
    self assert:(t := 400 milliseconds) printString = ('400ms').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   110
    self assert:(t := 4000 milliseconds) printString = ('4s').
139e97e95b07 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1925
diff changeset
   111
    self assert:(4000 milliseconds = 4 seconds).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   112
    "
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   113
     self new test_00_Basic
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   114
    "
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   115
!
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   116
1922
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   117
test_01_Addition
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   118
    |t1 t2 sum|
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   119
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   120
    t1 := TimeDuration fromSeconds:1.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   121
    t2 := TimeDuration fromMilliseconds:1.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   122
    sum := t1 + t2.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   123
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   124
    self assert:(sum asMilliseconds == 1001).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   125
    self assert:(sum asMicroseconds = 1001000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   126
    self assert:(sum asNanoseconds = 1001000000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   127
    self assert:(sum asPicoseconds = 1001000000000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   128
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   129
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   130
    t1 := TimeDuration fromSeconds:1.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   131
    t2 := TimeDuration fromMicroseconds:1.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   132
    sum := t1 + t2.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   133
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   134
    self assert:(sum asMilliseconds == 1000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   135
    self assert:(sum asMicroseconds = 1000001).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   136
    self assert:(sum asNanoseconds = 1000001000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   137
    self assert:(sum asPicoseconds = 1000001000000).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   138
1921
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   139
    t1 := TimeDuration fromNanoseconds:100.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   140
    t2 := TimeDuration fromNanoseconds:15.5.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   141
    sum := t1 + t2.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   142
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   143
    self assert:(sum asNanoseconds = 115).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   144
    self assert:(sum asPicoseconds = 115500).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   145
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   146
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   147
    "
1922
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   148
     self new test_01_Addition
1921
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   149
    "
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   150
!
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   151
1922
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   152
test_02_Subtraction
1921
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   153
    |t1 t2 sum|
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   154
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   155
    t1 := TimeDuration fromSeconds:1.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   156
    t2 := TimeDuration fromMilliseconds:1.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   157
    sum := t1 - t2.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   158
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   159
    self assert:(sum asMilliseconds == 999).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   160
    self assert:(sum asMicroseconds = 999000).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   161
    self assert:(sum asNanoseconds = 999000000).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   162
    self assert:(sum asPicoseconds = 999000000000).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   163
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   164
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   165
    t1 := TimeDuration fromSeconds:1.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   166
    t2 := TimeDuration fromMicroseconds:1.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   167
    sum := t1 - t2.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   168
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   169
    self assert:(sum asMilliseconds == 999).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   170
    self assert:(sum asMicroseconds = 999999).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   171
    self assert:(sum asNanoseconds = 999999000).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   172
    self assert:(sum asPicoseconds = 999999000000).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   173
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   174
    t1 := TimeDuration fromNanoseconds:100.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   175
    t2 := TimeDuration fromNanoseconds:15.5.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   176
    sum := t1 - t2.
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   177
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   178
    self assert:(sum asNanoseconds = 84).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   179
    self assert:(sum asPicoseconds = 84500).
5d52a8565d1d #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1920
diff changeset
   180
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   181
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   182
    "
1922
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   183
     self new test_01_Subtraction
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   184
    "
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   185
!
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   186
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   187
test_03_Multiplication
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   188
    |t rslt|
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   189
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   190
    t := TimeDuration fromSeconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   191
    rslt := t * 5.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   192
    self assert:(rslt asMilliseconds == 5000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   193
    self assert:(rslt asPicoseconds = 5000000000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   194
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   195
    rslt := 5 * t.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   196
    self assert:(rslt asMilliseconds == 5000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   197
    self assert:(rslt asPicoseconds = 5000000000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   198
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   199
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   200
    t := TimeDuration fromSeconds:1.1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   201
    rslt := t * 2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   202
    self assert:(rslt asMilliseconds == 2200).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   203
    self assert:(rslt asPicoseconds = 2200000000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   204
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   205
    rslt := 2 * t.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   206
    self assert:(rslt asMilliseconds == 2200).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   207
    self assert:(rslt asPicoseconds = 2200000000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   208
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   209
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   210
    t := TimeDuration fromNanoseconds:100.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   211
    rslt := t * 4.5.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   212
    self assert:(rslt asNanoseconds = 450).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   213
    self assert:(rslt asPicoseconds = 450000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   214
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   215
    rslt := 4.5 * t.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   216
    self assert:(rslt asNanoseconds = 450).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   217
    self assert:(rslt asPicoseconds = 450000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   218
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   219
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   220
    t := TimeDuration fromMilliseconds:100.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   221
    t := t + 50 nanoseconds.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   222
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   223
    rslt := t * 5.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   224
    self assert:(rslt asNanoseconds = 500000250).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   225
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   226
    rslt := 5 * t.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   227
    self assert:(rslt asNanoseconds = 500000250).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   228
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   229
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   230
    "
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   231
     self new test_03_Multiplication
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   232
    "
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   233
!
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   234
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   235
test_04_Division
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   236
    |t rslt|
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   237
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   238
    t := TimeDuration fromSeconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   239
    rslt := t / 5.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   240
    self assert:(rslt asMilliseconds == 200).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   241
    self assert:(rslt asPicoseconds = 200000000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   242
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   243
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   244
    t := TimeDuration fromSeconds:2.2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   245
    rslt := t / 2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   246
    self assert:(rslt asMilliseconds == 1100).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   247
    self assert:(rslt asPicoseconds = 1100000000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   248
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   249
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   250
    t := TimeDuration fromNanoseconds:450.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   251
    rslt := t / 4.5.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   252
    self assert:(rslt asNanoseconds = 100).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   253
    self assert:(rslt asPicoseconds = 100000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   254
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   255
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   256
    t := TimeDuration fromMilliseconds:100.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   257
    t := t + 50 nanoseconds.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   258
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   259
    rslt := t / 5.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   260
    self assert:(rslt asNanoseconds = 20000010).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   261
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   262
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   263
    "
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   264
     self new test_04_Division
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   265
    "
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   266
!
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   267
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   268
test_05_Division    
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   269
    "dividing two timeDurations gives a numeric quotient"
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   270
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   271
    |t1 t2 rslt|
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   272
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   273
    t1 := TimeDuration fromSeconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   274
    t2 := TimeDuration fromSeconds:2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   275
    rslt := t1 / t2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   276
    self assert:(rslt isNumber).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   277
    self assert:(rslt = 0.5).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   278
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   279
    t1 := TimeDuration fromSeconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   280
    t2 := TimeDuration fromMilliseconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   281
    rslt := t1 / t2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   282
    self assert:(rslt isNumber).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   283
    self assert:(rslt = 1000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   284
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   285
    t1 := TimeDuration fromMilliseconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   286
    t2 := TimeDuration fromMicroseconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   287
    rslt := t1 / t2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   288
    self assert:(rslt isNumber).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   289
    self assert:(rslt = 1000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   290
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   291
    t1 := TimeDuration fromMicroseconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   292
    t2 := TimeDuration fromNanoseconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   293
    rslt := t1 / t2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   294
    self assert:(rslt isNumber).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   295
    self assert:(rslt = 1000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   296
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   297
    t1 := TimeDuration fromSeconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   298
    t2 := TimeDuration fromNanoseconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   299
    rslt := t1 / t2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   300
    self assert:(rslt isNumber).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   301
    self assert:(rslt = 1000000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   302
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   303
    t1 := TimeDuration fromSeconds:1.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   304
    t2 := TimeDuration fromNanoseconds:50.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   305
    rslt := t1 / t2.
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   306
    self assert:(rslt isNumber).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   307
    self assert:(rslt = 20000000).
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   308
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   309
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   310
    "
a6d99b7a3447 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1921
diff changeset
   311
     self new test_05_Division
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   312
    "
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   313
!
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   314
1923
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   315
test_06_miscArithmetic    
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   316
    |t rslt|
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   317
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   318
    t := TimeDuration fromSeconds:1.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   319
    rslt := t negated.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   320
    self assert:(rslt asSeconds = -1).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   321
    self assert:(rslt = (TimeDuration fromSeconds:-1)).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   322
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   323
    t := TimeDuration fromMicroseconds:1.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   324
    rslt := t negated.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   325
    self assert:(rslt asMicroseconds = -1).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   326
    self assert:(rslt = (TimeDuration fromMicroseconds:-1)).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   327
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   328
    t := TimeDuration fromMicroseconds:10001.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   329
    rslt := t negated.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   330
    self assert:(rslt asMicroseconds = -10001).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   331
    self assert:(rslt = (TimeDuration fromMicroseconds:-10001)).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   332
    rslt := rslt negated.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   333
    self assert:(rslt asMicroseconds = 10001).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   334
    self assert:(rslt = (TimeDuration fromMicroseconds:10001)).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   335
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   336
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   337
    t := TimeDuration fromMicroseconds:-10001.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   338
    rslt := t abs.
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   339
    self assert:(rslt asMicroseconds = 10001).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   340
    self assert:(rslt = (TimeDuration fromMicroseconds:10001)).
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   341
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   342
    "
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   343
     self new test_06_miscArithmetic
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   344
    "
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   345
!
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   346
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   347
test_09_Reading
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   348
    |t1 t2|
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   349
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   350
    t2 := TimeDuration fromString:'1.001s'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   351
    self assert:(t2 asMilliseconds == 1001).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   352
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   353
    t1 := TimeDuration fromString:'1001ms'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   354
    self assert:(t1 asMilliseconds = 1001).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   355
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   356
    t1 := TimeDuration fromString:'1001ns'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   357
    self assert:(t1 asNanoseconds = 1001).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   358
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   359
    t1 := TimeDuration fromString:'1001us'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   360
    self assert:(t1 asMicroseconds = 1001).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   361
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   362
    t1 := TimeDuration fromString:'1001ps'.
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   363
    self assert:(t1 asPicoseconds = 1001).
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   364
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   365
    t1 := TimeDuration fromString:'1s 30us'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   366
    self assert:(t1 asMicroseconds = 1000030).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   367
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   368
    t1 := TimeDuration fromString:'0.1s'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   369
    self assert:(t1 asMilliseconds = 100).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   370
    t1 := TimeDuration fromString:'0.1ms'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   371
    self assert:(t1 asMicroseconds = 100).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   372
    t1 := TimeDuration fromString:'0.1us'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   373
    self assert:(t1 asNanoseconds = 100).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   374
    t1 := TimeDuration fromString:'0.1ns'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   375
    self assert:(t1 asPicoseconds = 100).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   376
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   377
    t1 := TimeDuration fromString:'0,1ns'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   378
    self assert:(t1 asPicoseconds = 100).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   379
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   380
    t1 := TimeDuration fromString:'01:30:33'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   381
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   382
    self assert:(t1 asMilliseconds = (((1*3600)+(30*60)+33)*1000)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   383
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   384
    t1 := TimeDuration fromString:'01:30:33.5'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   385
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   386
    self assert:(t1 asMilliseconds = ((((1*3600)+(30*60)+33)*1000)+500)).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   387
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   388
    t1 := TimeDuration fromString:'01:30:33,5'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   389
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   390
    self assert:(t1 asMilliseconds = ((((1*3600)+(30*60)+33)*1000)+500)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   391
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   392
    t1 := TimeDuration fromString:'01:30:33,05'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   393
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   394
    self assert:(t1 asMilliseconds = ((((1*3600)+(30*60)+33)*1000)+50)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   395
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   396
    t1 := TimeDuration fromString:'01:30:33,005'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   397
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   398
    self assert:(t1 asMilliseconds = ((((1*3600)+(30*60)+33)*1000)+5)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   399
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   400
    t1 := TimeDuration fromString:'01:30:33,0005'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   401
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   402
    self assert:(t1 asMicroseconds = ((((1*3600)+(30*60)+33)*1000*1000)+500)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   403
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   404
    t1 := TimeDuration fromString:'01:30:33,00005'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   405
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   406
    self assert:(t1 asMicroseconds = ((((1*3600)+(30*60)+33)*1000*1000)+50)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   407
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   408
    t1 := TimeDuration fromString:'01:30:33,000005'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   409
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   410
    self assert:(t1 asMicroseconds = ((((1*3600)+(30*60)+33)*1000*1000)+5)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   411
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   412
    t1 := TimeDuration fromString:'01:30:33,0000005'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   413
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   414
    self assert:(t1 asNanoseconds = ((((1*3600)+(30*60)+33)*1000*1000*1000)+500)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   415
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   416
    t1 := TimeDuration fromString:'01:30:33,00000005'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   417
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   418
    self assert:(t1 asNanoseconds = ((((1*3600)+(30*60)+33)*1000*1000*1000)+50)).
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   419
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   420
    t1 := TimeDuration fromString:'01:30:33,000000005'.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   421
    self assert:(t1 asSeconds = ((1*3600)+(30*60)+33)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   422
    self assert:(t1 asNanoseconds = ((((1*3600)+(30*60)+33)*1000*1000*1000)+5)).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   423
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   424
    t1 := TimeDuration fromString:'0.000000005'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   425
    self assert:(t1 asNanoseconds = 5).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   426
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   427
    t1 := TimeDuration fromString:'0.000000005s'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   428
    self assert:(t1 asNanoseconds = 5).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   429
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   430
    t1 := TimeDuration fromString:'1d 5h'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   431
    self assert:(t1 asTruncatedHours = 29).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   432
1920
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   433
    t1 := TimeDuration fromString:'1d 5h 30m'.
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   434
    self assert:(t1 asTruncatedHours = 29).
bb1f0cf27979 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1919
diff changeset
   435
    self assert:(t1 asExactHours = 29.5).
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   436
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   437
    "
1923
00f3085c5b71 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1922
diff changeset
   438
     self new test_09_Reading
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   439
    "
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   440
!
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   441
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   442
test_10_PrintingReading
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   443
     #(
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   444
        "/ hours minutes seconds millis
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   445
        (0 0 0 0)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   446
        (0 0 0 1)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   447
        (0 0 0 9)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   448
        (0 0 0 10)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   449
        (0 0 0 11)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   450
        (0 0 0 99)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   451
        (0 0 0 100)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   452
        (0 0 0 101)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   453
        (0 0 0 999)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   454
        (0 0 0 1000)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   455
        (0 0 0 1001)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   456
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   457
        (0 33 0 123)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   458
        (2 0 0 123)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   459
        (2 33 0 123)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   460
        (100 33 0 123)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   461
        (10000 33 0 123)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   462
        (1000000 33 0 123)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   463
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   464
        (2 33 0 0)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   465
        (2 0 0 0)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   466
        (24 0 0 0)
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   467
        (0 0 0 123)
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   468
    ) do:[:hmsms |
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   469
        |h m s ms d1 d2 s1 s2|
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   470
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   471
        h := hmsms first.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   472
        m := hmsms second.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   473
        s := hmsms third.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   474
        ms := hmsms fourth.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   475
        "/ generate a duration
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   476
        d1 := TimeDuration hours:h minutes:m seconds:s milliseconds:ms.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   477
        "/ print it
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   478
        s1 := d1 printString.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   479
        "/ read it back
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   480
        d2 := TimeDuration readFrom:s1.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   481
        s2 := d2 printString.
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   482
        "/ same time?
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   483
        self assert:(d1 = d2).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   484
        self assert:(d1 timeEncoding = d2 timeEncoding).
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   485
        "/ same string?
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   486
        self assert:(s1 = s2).
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   487
     ].
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   488
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   489
1447
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   490
"/     (TimeDuration hours:0 minutes:0 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   491
"/     (TimeDuration hours:0 minutes:0 seconds:10 milliseconds:123) printStringFormat:'%h:%m:%s'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   492
"/     (TimeDuration hours:0 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   493
"/     (TimeDuration hours:2 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   494
"/     (TimeDuration hours:100 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   495
"/     (TimeDuration hours:10000 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
2351db93aa5b package changes
Claus Gittinger <cg@exept.de>
parents: 1078
diff changeset
   496
"/     (TimeDuration hours:1000000 minutes:33 seconds:0 milliseconds:123) printStringFormat:'%h:%m:%s'
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   497
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   498
    "
1918
208bd3c139d3 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1447
diff changeset
   499
     self new test_10_PrintingReading
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   500
    "
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   501
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   502
    "Created: / 18-07-2007 / 14:02:01 / cg"
1925
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   503
!
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   504
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   505
test_11_Comparing
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   506
    |t1 t2|
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   507
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   508
    t1 := TimeDuration fromSeconds:1.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   509
    t2 := t1 + 1 picoseconds.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   510
    self assert:(t2 > t1).
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   511
    self assert:(t2 >= t1).
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   512
    self assert:(t2 = t1) not.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   513
    self assert:(t2 <= t1) not.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   514
    self assert:(t2 < t1) not.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   515
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   516
    t1 := TimeDuration fromSeconds:1.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   517
    t2 := t1 - 1 picoseconds.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   518
    self assert:(t2 < t1).
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   519
    self assert:(t2 <= t1).
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   520
    self assert:(t2 = t1) not.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   521
    self assert:(t2 >= t1) not.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   522
    self assert:(t2 > t1) not.
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   523
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   524
    "
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   525
     self new test_11_Comparing
8aae0cf16be3 #QUALITY by cg
Claus Gittinger <cg@exept.de>
parents: 1923
diff changeset
   526
    "
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   527
! !
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   528
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   529
!TimeDurationTest class methodsFor:'documentation'!
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   530
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   531
version
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   532
    ^ '$Header$'
1919
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   533
!
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   534
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   535
version_CVS
2a68b01c7f02 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 1918
diff changeset
   536
    ^ '$Header$'
333
0416f0422ad1 initial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   537
! !
1078
a4829ce2f3f1 category change
Claus Gittinger <cg@exept.de>
parents: 678
diff changeset
   538