Skip to content

Commit 17d9a51

Browse files
committed
Added more tests on PackUnpackTimestamp
1 parent 6fb676d commit 17d9a51

File tree

6 files changed

+121
-90
lines changed

6 files changed

+121
-90
lines changed

repository/MessagePackTest.package/MpPackUnpackTestCase.class/instance/testPackUnpackTimestamp.st

Lines changed: 0 additions & 87 deletions
This file was deleted.
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
testing
2+
testPackUnpackTimestamp32
3+
"self debug: #testPackUnpackTimestamp32"
4+
| packed unpacked secondsAndNanos |
5+
packed := self unixEpochTimestamp messagePacked: [:settings | settings formatVersion: 2013].
6+
self assert: packed size = 6.
7+
unpacked := Object fromMessagePack: packed.
8+
secondsAndNanos := MpPortableUtil default unixSecondsWithNanosecondsFrom: unpacked.
9+
self assert: secondsAndNanos first = 0.
10+
self assert: secondsAndNanos last = 0.
11+
12+
packed := (self unixEpochTimestamp + 10 seconds) messagePacked: [:settings | settings formatVersion: 2013].
13+
self assert: packed size = 6.
14+
unpacked := Object fromMessagePack: packed.
15+
secondsAndNanos := MpPortableUtil default unixSecondsWithNanosecondsFrom: unpacked.
16+
self assert: secondsAndNanos first = 10.
17+
self assert: secondsAndNanos last = 0.
18+
19+
packed := self max32Timestamp - 1 seconds messagePacked: [:settings | settings formatVersion: 2013].
20+
self assert: packed size = 6.
21+
unpacked := Object fromMessagePack: packed.
22+
secondsAndNanos := MpPortableUtil default unixSecondsWithNanosecondsFrom: unpacked.
23+
self assert: secondsAndNanos first = -1.
24+
self assert: secondsAndNanos last = 0.
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
testing
2+
testPackUnpackTimestamp64
3+
"self debug: #testPackUnpackTimestamp64"
4+
| packed unpacked secondsAndNanos |
5+
packed := (self unixEpochTimestamp + 10 nanoSeconds) messagePacked: [:settings | settings formatVersion: 2013].
6+
self assert: packed size = 10.
7+
unpacked := Object fromMessagePack: packed.
8+
secondsAndNanos := MpPortableUtil default unixSecondsWithNanosecondsFrom: unpacked.
9+
self assert: secondsAndNanos first = 0.
10+
self assert: secondsAndNanos last = 10.
11+
12+
packed := self max32Timestamp messagePacked: [:settings | settings formatVersion: 2013].
13+
self assert: packed size = 10.
14+
unpacked := Object fromMessagePack: packed.
15+
secondsAndNanos := MpPortableUtil default unixSecondsWithNanosecondsFrom: unpacked.
16+
self assert: secondsAndNanos first = (1 << 32).
17+
self assert: secondsAndNanos last = 0.
18+
19+
packed := (self max32Timestamp - 10 nanoSeconds) messagePacked: [:settings | settings formatVersion: 2013].
20+
self assert: packed size = 10.
21+
unpacked := Object fromMessagePack: packed.
22+
secondsAndNanos := MpPortableUtil default unixSecondsWithNanosecondsFrom: unpacked.
23+
self assert: secondsAndNanos first = ((1 << 32) -1).
24+
self assert: secondsAndNanos last = 999999990.
25+
26+
packed := (self max32Timestamp + 10 nanoSeconds) messagePacked: [:settings | settings formatVersion: 2013].
27+
self assert: packed size = 10.
28+
unpacked := Object fromMessagePack: packed.
29+
secondsAndNanos := MpPortableUtil default unixSecondsWithNanosecondsFrom: unpacked.
30+
self assert: secondsAndNanos first = (1 << 32).
31+
self assert: secondsAndNanos last = 10.
32+
33+
packed := (self max32Timestamp + 90 seconds + 10 nanoSeconds) messagePacked: [:settings | settings formatVersion: 2013].
34+
self assert: packed size = 10.
35+
unpacked := Object fromMessagePack: packed.
36+
secondsAndNanos := MpPortableUtil default unixSecondsWithNanosecondsFrom: unpacked.
37+
self assert: secondsAndNanos first = ((1 << 32) + 90).
38+
self assert: secondsAndNanos last = 10.
39+
40+
packed := (self max64Timestamp - 1 seconds) messagePacked: [:settings | settings formatVersion: 2013].
41+
self assert: packed size = 10.
42+
unpacked := Object fromMessagePack: packed.
43+
secondsAndNanos := MpPortableUtil default unixSecondsWithNanosecondsFrom: unpacked.
44+
self assert: secondsAndNanos first = ((1 << 34) - 1).
45+
self assert: secondsAndNanos last = 999999999.
46+
47+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
testing
2+
testPackUnpackTimestamp96
3+
"self debug: #testPackUnpackTimestamp"
4+
| packed unpacked secondsAndNanos |
5+
packed := (self max64Timestamp) messagePacked: [:settings | settings formatVersion: 2013].
6+
self assert: packed size = 15.
7+
unpacked := Object fromMessagePack: packed.
8+
secondsAndNanos := MpPortableUtil default unixSecondsWithNanosecondsFrom: unpacked.
9+
self assert: secondsAndNanos first = (1 << 34).
10+
self assert: secondsAndNanos last = 999999999.
11+
12+
packed := (self unixEpochTimestamp - 1 seconds) messagePacked: [:settings | settings formatVersion: 2013].
13+
self assert: packed size = 15.
14+
unpacked := Object fromMessagePack: packed.
15+
secondsAndNanos := MpPortableUtil default unixSecondsWithNanosecondsFrom: unpacked.
16+
self assert: secondsAndNanos first = -1.
17+
self assert: secondsAndNanos last = 0.
18+
19+
packed := (self unixEpochTimestamp - 1 nanoSeconds) messagePacked: [:settings | settings formatVersion: 2013].
20+
self assert: packed size = 15.
21+
unpacked := Object fromMessagePack: packed.
22+
secondsAndNanos := MpPortableUtil default unixSecondsWithNanosecondsFrom: unpacked.
23+
self assert: secondsAndNanos first = -1.
24+
self assert: secondsAndNanos last = 999999999.
25+
26+
packed := (self unixEpochTimestamp - 1 seconds - 999999999 nanoSeconds) messagePacked: [:settings | settings formatVersion: 2013].
27+
self assert: packed size = 15.
28+
unpacked := Object fromMessagePack: packed.
29+
secondsAndNanos := MpPortableUtil default unixSecondsWithNanosecondsFrom: unpacked.
30+
self assert: secondsAndNanos first = -2.
31+
self assert: secondsAndNanos last = 1.
32+
33+
packed := (self max96Timestamp) messagePacked: [:settings | settings formatVersion: 2013].
34+
self assert: packed size = 15.
35+
unpacked := Object fromMessagePack: packed.
36+
secondsAndNanos := MpPortableUtil default unixSecondsWithNanosecondsFrom: unpacked.
37+
self assert: secondsAndNanos first = 9223372036854775807.
38+
self assert: secondsAndNanos last = 999999999.
39+
40+
packed := (self min96Timestamp) messagePacked: [:settings | settings formatVersion: 2013].
41+
self assert: packed size = 15.
42+
unpacked := Object fromMessagePack: packed.
43+
secondsAndNanos := MpPortableUtil default unixSecondsWithNanosecondsFrom: unpacked.
44+
self assert: secondsAndNanos first = -9223372036854775808.
45+
self assert: secondsAndNanos last = 0.

repository/MessagePackTest.package/MpPackUnpackTestCase.class/methodProperties.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
"max32Timestamp" : "MasashiUmezawa 8/13/2017 12:49",
1212
"testPackUnpackComplexArray" : "mu 6/23/2011 12:43",
1313
"testPackUnpackNil" : "MasashiUmezawa 5/18/2015 10:45",
14+
"testPackUnpackTimestamp64" : "MasashiUmezawa 8/15/2017 23:01",
1415
"testPackUnpackBinBytes" : "mu 8/25/2013 23:22",
1516
"max64Timestamp" : "MasashiUmezawa 8/13/2017 12:53",
1617
"testPackUnpackArray" : "mu 6/23/2011 12:43",
@@ -24,12 +25,12 @@
2425
"testPackUnpackComplexMap" : "mu 6/23/2011 12:43",
2526
"testPackUnpackStrBytes" : "mu 8/25/2013 23:49",
2627
"min96Timestamp" : "MasashiUmezawa 8/13/2017 14:31",
27-
"testPackUnpackTimestamp" : "MasashiUmezawa 8/14/2017 23:23",
2828
"max96Timestamp" : "MasashiUmezawa 8/13/2017 14:11",
2929
"rawFixExtValueArray" : "mu 12/8/2013 15:25",
3030
"testPackUnpackFloatingPoint" : "mu 5/1/2011 21:43",
3131
"testPackUnpackMap" : "mu 6/23/2011 12:44",
3232
"complexArraysArray" : "mu 5/1/2011 23:45",
33+
"testPackUnpackTimestamp96" : "MasashiUmezawa 8/15/2017 23:06",
3334
"createByteStringSized:" : "MasashiUmezawa 11/12/2016 23:44",
3435
"createRawBytesSized:" : "MasashiUmezawa 2/2/2013 21:14",
3536
"simpleMapsArray" : "mu 5/1/2011 23:50",
@@ -43,7 +44,8 @@
4344
"complexMapsArray" : "mu 5/1/2011 23:56",
4445
"createComplexArraySized:" : "mu 6/23/2011 12:11",
4546
"testPackUnpackFalse" : "MasashiUmezawa 5/18/2015 10:49",
46-
"simpleArraysArray" : "mu 5/1/2011 23:45"
47+
"simpleArraysArray" : "mu 5/1/2011 23:45",
48+
"testPackUnpackTimestamp32" : "MasashiUmezawa 8/15/2017 22:53"
4749
},
4850
"class" : { }
4951
}

repository/MessagePackTest.package/monticello.meta/version

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
(name 'MessagePackTest-MasashiUmezawa.16' message 'Revising testPackUnpackTimestamp' id '2c807530-1913-0d00-bf28-a848069d6816' date '14 August 2017' time '11:26:45.356078 pm' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-MasashiUmezawa.15' message 'Added testPackUnpackTimestamp' id '2ec240a3-fd12-0d00-961e-18360ade5bf7' date '13 August 2017' time '2:34:32.197822 pm' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-MasashiUmezawa.14' message 'Updated test fixtures of string creation' id 'b17145fb-55d1-3d49-90ff-4698af2a186b' date '13 November 2016' time '12:06:57.527191 am' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-MasashiUmezawa.13' message 'Added #testPackUnpackSymbolBytes' id '19b6a570-5d88-884e-bf66-5f1ca9d3dafb' date '4 June 2016' time '2:24:24.077615 pm' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-MasashiUmezawa.12' message '- Changed tests for older format' id '7917bb4f-8326-4932-bb01-bf96b1b8542f' date '21 June 2015' time '8:36:04.342843 pm' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-MasashiUmezawa.11' message 'Renamed MpConstants typecode methods for compatibility with GemStone.https://github.com/msgpack/msgpack-smalltalk/issues/4' id '0743d0ea-4883-40eb-8632-c39dad337679' date '18 May 2015' time '10:55:09.715775 am' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-mu.10' message '-Added testPackUnpackExt, testPackUnpackFixExt test cases' id 'd9431577-e13c-724a-b3ff-642435692c12' date '8 December 2013' time '3:47:56.186 pm' author 'mu' ancestors ((name 'MessagePackTest-MasashiUmezawa.9' message '-Fixed MpStringUnpackTestCase>>testUnpackString8 to run on Pharo' id '4fedb785-bf5b-bb42-9245-6a0b2973d013' date '15 October 2013' time '1:07:32.7 am' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-mu.8' message '- Added PackUnpack tests for new Binary type- Added tests for String (formerly Raw) type' id '5f057f80-8c27-084b-89b1-5c3cc7ae9f9c' date '26 August 2013' time '12:34:48.825 am' author 'mu' ancestors ((name 'MessagePackTest-mu.7' message 'Added decoder tests for str8, bin8, bin16, bin32.See the proposal: https://gist.github.com/frsyuki/5432559' id 'da119030-ed83-6241-847c-2795a61d804a' date '12 August 2013' time '1:41:12.542 am' author 'mu' ancestors ((name 'MessagePackTest-MasashiUmezawa.6' message 'Avoid sending #asByteArray for portability' id 'c9be1c45-49c4-8947-93d5-16ccbf7e7df3' date '2 February 2013' time '10:02:03.626 pm' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-MasashiUmezawa.5' message 'Confirmed all tests are green' id '9667ec89-9c26-1c46-8a89-fad027e006bc' date '2 February 2013' time '9:57:02.029 pm' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-MasashiUmezawa.4' message 'Adding test cases for new encode/decode options' id '61bbf0a0-053d-c24c-bd29-8332d8e99a57' date '2 February 2013' time '9:36:55.589 pm' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-mu.3' message 'Changes for portablity' id '06a6b0a5-0061-104a-bec2-a82f96c6a87c' date '23 June 2011' time '5:09:30.249 pm' author 'mu' ancestors ((name 'MessagePackTest-mu.2' message 'empty log message' id '77d3b945-c29d-c34f-84e7-81b255f6a638' date '2 May 2011' time '12:02:08.182 am' author 'mu' ancestors ((name 'MessagePackTest-mu.1' message 'empty log message' id '0ba4d187-aa2e-c94d-8aed-2dd83925c6b8' date '1 May 2011' time '11:43:57.135 pm' author 'mu' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())
1+
(name 'MessagePackTest-MasashiUmezawa.17' message 'Added more tests on PackUnpackTimestamp ' id '88b8fe0a-2d13-0d00-ad27-398701d173ae' date '15 August 2017' time '11:07:56.160682 pm' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-MasashiUmezawa.16' message 'Revising testPackUnpackTimestamp' id '2c807530-1913-0d00-bf28-a848069d6816' date '14 August 2017' time '11:26:45.356078 pm' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-MasashiUmezawa.15' message 'Added testPackUnpackTimestamp' id '2ec240a3-fd12-0d00-961e-18360ade5bf7' date '13 August 2017' time '2:34:32.197822 pm' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-MasashiUmezawa.14' message 'Updated test fixtures of string creation' id 'b17145fb-55d1-3d49-90ff-4698af2a186b' date '13 November 2016' time '12:06:57.527191 am' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-MasashiUmezawa.13' message 'Added #testPackUnpackSymbolBytes' id '19b6a570-5d88-884e-bf66-5f1ca9d3dafb' date '4 June 2016' time '2:24:24.077615 pm' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-MasashiUmezawa.12' message '- Changed tests for older format' id '7917bb4f-8326-4932-bb01-bf96b1b8542f' date '21 June 2015' time '8:36:04.342843 pm' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-MasashiUmezawa.11' message 'Renamed MpConstants typecode methods for compatibility with GemStone.https://github.com/msgpack/msgpack-smalltalk/issues/4' id '0743d0ea-4883-40eb-8632-c39dad337679' date '18 May 2015' time '10:55:09.715775 am' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-mu.10' message '-Added testPackUnpackExt, testPackUnpackFixExt test cases' id 'd9431577-e13c-724a-b3ff-642435692c12' date '8 December 2013' time '3:47:56.186 pm' author 'mu' ancestors ((name 'MessagePackTest-MasashiUmezawa.9' message '-Fixed MpStringUnpackTestCase>>testUnpackString8 to run on Pharo' id '4fedb785-bf5b-bb42-9245-6a0b2973d013' date '15 October 2013' time '1:07:32.7 am' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-mu.8' message '- Added PackUnpack tests for new Binary type- Added tests for String (formerly Raw) type' id '5f057f80-8c27-084b-89b1-5c3cc7ae9f9c' date '26 August 2013' time '12:34:48.825 am' author 'mu' ancestors ((name 'MessagePackTest-mu.7' message 'Added decoder tests for str8, bin8, bin16, bin32.See the proposal: https://gist.github.com/frsyuki/5432559' id 'da119030-ed83-6241-847c-2795a61d804a' date '12 August 2013' time '1:41:12.542 am' author 'mu' ancestors ((name 'MessagePackTest-MasashiUmezawa.6' message 'Avoid sending #asByteArray for portability' id 'c9be1c45-49c4-8947-93d5-16ccbf7e7df3' date '2 February 2013' time '10:02:03.626 pm' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-MasashiUmezawa.5' message 'Confirmed all tests are green' id '9667ec89-9c26-1c46-8a89-fad027e006bc' date '2 February 2013' time '9:57:02.029 pm' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-MasashiUmezawa.4' message 'Adding test cases for new encode/decode options' id '61bbf0a0-053d-c24c-bd29-8332d8e99a57' date '2 February 2013' time '9:36:55.589 pm' author 'MasashiUmezawa' ancestors ((name 'MessagePackTest-mu.3' message 'Changes for portablity' id '06a6b0a5-0061-104a-bec2-a82f96c6a87c' date '23 June 2011' time '5:09:30.249 pm' author 'mu' ancestors ((name 'MessagePackTest-mu.2' message 'empty log message' id '77d3b945-c29d-c34f-84e7-81b255f6a638' date '2 May 2011' time '12:02:08.182 am' author 'mu' ancestors ((name 'MessagePackTest-mu.1' message 'empty log message' id '0ba4d187-aa2e-c94d-8aed-2dd83925c6b8' date '1 May 2011' time '11:43:57.135 pm' author 'mu' ancestors () stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())) stepChildren ())

0 commit comments

Comments
 (0)