Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 80 additions & 13 deletions src/GeoTools-Tests/AbsoluteCoordinatesTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -169,19 +169,6 @@ AbsoluteCoordinatesTest >> testAbsoluteCoordinatesLimitations [
self assert: coord altitudeInMeters equals: 100.
]

{ #category : #tests }
AbsoluteCoordinatesTest >> testAbsoluteCoordinatesPrintOn [
| coord |
coord := AbsoluteCoordinates new.
self assert: coord printString equals: 'an AbsoluteCoordinates lat --° lon --° alt --m'.

coord := AbsoluteCoordinates zero.
self assert: coord printString equals: 'an AbsoluteCoordinates lat 0° lon 0° alt 0m'.

coord := AbsoluteCoordinates frBrest.
self assert: coord printString equals: 'an AbsoluteCoordinates lat 48.3897° lon -4.48333° alt 52m'.
]

{ #category : #tests }
AbsoluteCoordinatesTest >> testAbsoluteCoordinatesRandom [
| coord |
Expand Down Expand Up @@ -348,6 +335,86 @@ AbsoluteCoordinatesTest >> testIsZero [
self assert: coord isZero.
]

{ #category : #tests }
AbsoluteCoordinatesTest >> testPrintAltitudeString [

self
assert: absCoord printAltitudeString
equals: 'Not valid altitude'.

self
assert: AbsoluteCoordinates frBrest printAltitudeString
equals: '52m'.

self
assert: AbsoluteCoordinates zero printAltitudeString
equals: '0m'.

self
assert: (AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 0) printAltitudeString
equals: 'Not valid altitude'.
]

{ #category : #tests }
AbsoluteCoordinatesTest >> testPrintLatitudeString [

self
assert: absCoord printLatitudeString
equals: 'Not valid latitude'.

self
assert: AbsoluteCoordinates frBrest printLatitudeString
equals: '48°23''22"N'.

self
assert: AbsoluteCoordinates zero printLatitudeString
equals: '00°00''00"N'.

self
assert: (AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 0) printLatitudeString
equals: '00°00''00"N'.
]

{ #category : #tests }
AbsoluteCoordinatesTest >> testPrintLongitudeString [

self
assert: absCoord printLongitudeString
equals: 'Not valid longitude'.

self
assert: AbsoluteCoordinates frBrest printLongitudeString
equals: '004°29''00"W'.

self
assert: AbsoluteCoordinates zero printLongitudeString
equals: '000°00''00"E'.

self
assert: (AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 0) printLongitudeString
equals: '000°00''00"E'.
]

{ #category : #tests }
AbsoluteCoordinatesTest >> testPrintOn [

self
assert: (String streamContents: [ :str | absCoord printOn: str ])
equals: 'No valid coordinates'.

self
assert: (String streamContents: [ :str | AbsoluteCoordinates frBrest printOn: str ])
equals: '48°23''22"N 004°29''00"W 52m'.

self
assert: (String streamContents: [ :str | AbsoluteCoordinates zero printOn: str ])
equals: '00°00''00"N 000°00''00"E 0m'.

self
assert: (String streamContents: [ :str | (AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 0) printOn: str ])
equals: '00°00''00"N 000°00''00"E'.
]

{ #category : #tests }
AbsoluteCoordinatesTest >> testRandom [

Expand Down
83 changes: 83 additions & 0 deletions src/GeoTools-Tests/AbstractAbsoluteCoordinatesPrinterTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
"
An AbstractAbsoluteCoordinatesPrinterTest is a test class for testing the behavior of AbstractAbsoluteCoordinatesPrinter
"
Class {
#name : #AbstractAbsoluteCoordinatesPrinterTest,
#superclass : #TestCase,
#instVars : [
'printer'
],
#category : #'GeoTools-Tests-Coordinates'
}

{ #category : #testing }
AbstractAbsoluteCoordinatesPrinterTest class >> isAbstract [

^ self == AbstractAbsoluteCoordinatesPrinterTest
]

{ #category : #private }
AbstractAbsoluteCoordinatesPrinterTest >> coordinatesList [

^ {
AbsoluteCoordinates frBrest.
AbsoluteCoordinates ausSydney.
AbsoluteCoordinates usaNewYork.
AbsoluteCoordinates zero.
(AbsoluteCoordinates latitudeInDegrees: 0 longitudeInDegrees: 0).
AbsoluteCoordinates new }
]

{ #category : #accessing }
AbstractAbsoluteCoordinatesPrinterTest >> printerClass [

self subclassResponsibility
]

{ #category : #running }
AbstractAbsoluteCoordinatesPrinterTest >> setUp [

super setUp.

printer := self printerClass new
]

{ #category : #tests }
AbstractAbsoluteCoordinatesPrinterTest >> testPrintAbsoluteCoordinatesOn [

self coordinatesList do: [ :c |
| stream |
stream := String new writeStream.
printer printAbsoluteCoordinates: c on: stream.
self assert: stream contents isString ]
]

{ #category : #tests }
AbstractAbsoluteCoordinatesPrinterTest >> testPrintAltitudeOn [

self coordinatesList do: [ :c |
| stream |
stream := String new writeStream.
printer printAltitude: c altitude on: stream.
self assert: stream contents isString ]
]

{ #category : #tests }
AbstractAbsoluteCoordinatesPrinterTest >> testPrintLatitudeOn [

self coordinatesList do: [ :c |
| stream |
stream := String new writeStream.
printer printLatitude: c latitude on: stream.
self assert: stream contents isString ]
]

{ #category : #tests }
AbstractAbsoluteCoordinatesPrinterTest >> testPrintLongitudeOn [

self coordinatesList do: [ :c |
| stream |
stream := String new writeStream.
printer printLongitude: c longitude on: stream.
self assert: stream contents isString ]
]
69 changes: 69 additions & 0 deletions src/GeoTools-Tests/DMSAbsoluteCoordinatesPrinterTest.class.st
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
Class {
#name : #DMSAbsoluteCoordinatesPrinterTest,
#superclass : #AbstractAbsoluteCoordinatesPrinterTest,
#category : #'GeoTools-Tests-Coordinates'
}

{ #category : #accessing }
DMSAbsoluteCoordinatesPrinterTest >> printerClass [

^ DMSAbsoluteCoordinatesPrinter
]

{ #category : #tests }
DMSAbsoluteCoordinatesPrinterTest >> testCharacterWest [
"Test changing west character, i.e. using french language"

| stream |
printer characterWest: $O.
self assert: printer characterWest equals: $O.

stream := String new writeStream.
printer printAbsoluteCoordinates: AbsoluteCoordinates frBrest on: stream.
self assert: stream contents equals: '48°23''22"N 004°29''00"O 52m'.
]

{ #category : #tests }
DMSAbsoluteCoordinatesPrinterTest >> testPrintAbsoluteCoordinatesOn2 [

| stream |
stream := String new writeStream.
printer printAbsoluteCoordinates: AbsoluteCoordinates frBrest on: stream.
self assert: stream contents equals: '48°23''22"N 004°29''00"W 52m'.

stream := String new writeStream.
printer printAbsoluteCoordinates: AbsoluteCoordinates zero on: stream.
self assert: stream contents equals: '00°00''00"N 000°00''00"E 0m'.

stream := String new writeStream.
printer printAbsoluteCoordinates: AbsoluteCoordinates new on: stream.
self assert: stream contents equals: ''



]

{ #category : #tests }
DMSAbsoluteCoordinatesPrinterTest >> testReset [

printer reset
]

{ #category : #tests }
DMSAbsoluteCoordinatesPrinterTest >> testWithSpaces [

| stream |
self deny: printer withSpaces.

printer withSpaces: true.
self assert: printer withSpaces.
stream := String new writeStream.
printer printAbsoluteCoordinates: AbsoluteCoordinates frBrest on: stream.
self assert: stream contents equals: '48° 23'' 22" N 004° 29'' 00" W 52m'.

printer withSpaces: false.
self deny: printer withSpaces.
stream := String new writeStream.
printer printAbsoluteCoordinates: AbsoluteCoordinates frBrest on: stream.
self assert: stream contents equals: '48°23''22"N 004°29''00"W 52m'.
]
Loading