Add GtWireFloatPrintStringEncoder · feenkcom/gtoolkit-wireencoding@d52e27d · GitHub
Skip to content

Commit d52e27d

Browse files
committed
Add GtWireFloatPrintStringEncoder
1 parent 16c8ac2 commit d52e27d

4 files changed

Lines changed: 61 additions & 12 deletions

File tree

src/GToolkit-WireEncoding-GemStone/GtWireEncoderDecoder.extension.st

Lines changed: 8 additions & 5 deletions

src/GToolkit-WireEncoding/GtWireClassEncoder.class.st

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
GtWireClassEncoder passes class references by name, assuming that the local and remote class definitions are equivalent.
33
"
44
Class {
5-
#name : 'GtWireClassEncoder',
6-
#superclass : 'GtWireObjectEncoder',
7-
#category : 'GToolkit-WireEncoding'
5+
#name : #GtWireClassEncoder,
6+
#superclass : #GtWireObjectEncoder,
7+
#category : #'GToolkit-WireEncoding'
88
}
99

10-
{ #category : 'accessing' }
10+
{ #category : #accessing }
1111
GtWireClassEncoder class >> typeIdentifier [
1212

1313
^ 28
1414
]
1515

16-
{ #category : 'encoding - decoding' }
16+
{ #category : #'encoding - decoding' }
1717
GtWireClassEncoder >> decodeWith: aGtWireEncoderContext [
1818
| className isMeta instanceClass |
1919

@@ -27,7 +27,7 @@ GtWireClassEncoder >> decodeWith: aGtWireEncoderContext [
2727
ifFalse: [ instanceClass ].
2828
]
2929

30-
{ #category : 'encoding - decoding' }
30+
{ #category : #'encoding - decoding' }
3131
GtWireClassEncoder >> encode: aClass with: aGtWireEncoderContext [
3232

3333
aGtWireEncoderContext

src/GToolkit-WireEncoding/GtWireEncodingExamples.class.st

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ GtWireEncodingExamples >> encoderHasValidConfigurationByDefault [
246246

247247
{ #category : #examples }
248248
GtWireEncodingExamples >> float [
249+
"Check float encoding using the default encoder"
249250
<gtExample>
250251
<return: #GtWireEncodingExamples>
251252
| encoder byteArray next |
@@ -257,7 +258,27 @@ GtWireEncodingExamples >> float [
257258
encoder reset.
258259
encoder nextPut: f.
259260
byteArray := encoder contents.
260-
self assert: byteArray size equals: 9.
261+
next := (GtWireDecoder on: byteArray readStream) next.
262+
self assert: next equals: f ]
263+
]
264+
265+
{ #category : #examples }
266+
GtWireEncodingExamples >> floatString [
267+
"Check float encoding forcing GtWireFloatPrintStringEncoder"
268+
<gtExample>
269+
<return: #GtWireEncodingExamples>
270+
| encoder fpsEncoder byteArray next |
271+
272+
encoder := GtWireEncoder onByteArray.
273+
fpsEncoder := GtWireFloatPrintStringEncoder new.
274+
{Float fmin.
275+
Float fmax.
276+
1.25.
277+
Float pi. }
278+
doWithIndex: [ :f :i |
279+
encoder reset.
280+
fpsEncoder encode: f with: encoder.
281+
byteArray := encoder contents.
261282
next := (GtWireDecoder on: byteArray readStream) next.
262283
self assert: next equals: f ]
263284
]
Lines changed: 25 additions & 0 deletions

0 commit comments

Comments
 (0)