Discussion:
The Trunk: MultilingualTests-pre.37.mcz
(too old to reply)
c***@source.squeak.org
0000-12-07 19:26:04 UTC
Permalink
Patrick Rein uploaded a new version of MultilingualTests to project The Trunk:
http://source.squeak.org/trunk/MultilingualTests-pre.37.mcz

==================== Summary ====================

Name: MultilingualTests-pre.37
Author: pre
Time: 6 December 2018, 8:26:00.740566 pm
UUID: 01733a34-a005-1d4d-a679-fd99c2fe27c3
Ancestors: MultilingualTests-pre.36

Similar to the commit in Multilingual, this commit categorizes un-categorized methods and moves tests from testing to tests.

=============== Diff against MultilingualTests-pre.36 ===============

Item was changed:
+ ----- Method: FontTest>>testDisplay (in category 'tests') -----
- ----- Method: FontTest>>testDisplay (in category 'testing') -----
testDisplay
"self debug: #testDisplay"
| text font bb destPoint width |
text := 'test' asText.
font := TextStyle default fontOfSize: 21.
text addAttribute: (TextFontReference toFont: font).
bb := (Form extent: 100 @ 30) getCanvas privatePort.
bb combinationRule: Form paint.

font installOn: bb foregroundColor: Color black backgroundColor: Color white.
destPoint := font displayString: text asString on: bb from: 1 to: 4 at: ***@0 kern: 1.

width := text inject: 0 into: [:max :char | max + (font widthOf: char)].
self assert: destPoint x = (width + 4).
"bb destForm asMorph openInHand."
!

Item was changed:
+ ----- Method: FontTest>>testFallback (in category 'tests') -----
- ----- Method: FontTest>>testFallback (in category 'testing') -----
testFallback
"self debug: #testFallback"
| text font bb destPoint |
text := (Character value: 257) asString asText.
font := TextStyle default fontOfSize: 21.
text addAttribute: (TextFontReference toFont: font).
bb := (Form extent: 100 @ 30) getCanvas privatePort.
bb combinationRule: Form paint.

font installOn: bb foregroundColor: Color black backgroundColor: Color white.
destPoint := font displayString: text asString on: bb from: 1 to: 1 at: ***@0 kern: 1.

"bb destForm asMorph openInHand."
self assert: destPoint x = ((font widthOf: $?) + 1).
!

Item was changed:
+ ----- Method: FontTest>>testMultistringFallbackFont (in category 'tests') -----
- ----- Method: FontTest>>testMultistringFallbackFont (in category 'testing') -----
testMultistringFallbackFont
"self debug: #testMultistringFallbackFont"
| text p style height width |
[(TextStyle default fontArray at: JapaneseEnvironment leadingChar)
ifNil: [^ self]]
ifError: [:err :rcvr | ^ self].
text := ((#(20983874 20983876 20983878 )
collect: [:e | e asCharacter])
as: String) asText.
p := NewParagraph new.
style := TextStyle new leading: 0; newFontArray: {Preferences standardFlapFont}.
p
compose: text
style: style
from: 1
in: (0 @ 0 corner: 100 @ 100).
"See CompositionScanner>>setActualFont: &
CompositionScanner>>composeFrom:inRectangle:firstLine:leftSide:rightSide:"
height := style defaultFont height + style leading.
width := p caretWidth + (text
inject: 0
into: [:tally :next | tally
+ (style defaultFont widthOf: next)]).
p adjustRightX.
self assert: p extent = (width @ height).
"Display getCanvas
paragraph: p
bounds: (10 @ 10 extent: 100 @ 100)
color: Color black"!

Item was changed:
+ ----- Method: FontTest>>testMultistringFont (in category 'tests') -----
- ----- Method: FontTest>>testMultistringFont (in category 'testing') -----
testMultistringFont
"self debug: #testMultistringFont"
| text p style height width |
[(TextStyle default fontArray at: JapaneseEnvironment leadingChar)
ifNil: [^ self]]
ifError: [:err :rcvr | ^ self].
text := ((#(20983874 20983876 20983878 )
collect: [:e | e asCharacter])
as: String) asText.
p := NewParagraph new.
style := TextStyle default.
p
compose: text
style: style
from: 1
in: (0 @ 0 corner: 100 @ 100).
"See CompositionScanner>>setActualFont: &
CompositionScanner>>composeFrom:inRectangle:firstLine:leftSide:rightSide:"
height := style defaultFont height + style leading.
width := p caretWidth + (text
inject: 0
into: [:tally :next | tally
+ (style defaultFont widthOf: next)]).
p adjustRightX.
self assert: p extent = (width @ height).
"Display getCanvas
paragraph: p
bounds: (10 @ 10 extent: 100 @ 100)
color: Color black"!

Item was changed:
+ ----- Method: FontTest>>testParagraph (in category 'tests') -----
- ----- Method: FontTest>>testParagraph (in category 'testing') -----
testParagraph
"self debug: #testParagraph"
| text p style height width |
text := 'test' asText.
p := NewParagraph new.
style := TextStyle default.
p
compose: text
style: style
from: 1
in: (0 @ 0 corner: 100 @ 100).
"See CompositionScanner>>setActualFont: &
CompositionScanner>>composeFrom:inRectangle:firstLine:leftSide:rightSide:"
height := style defaultFont height + style leading.
width := (text
inject: 0
into: [:tally :next | tally
+ (style defaultFont widthOf: next)]) + p caretWidth. "because it is added by the paragraph formatting"
p adjustRightX.
self assert: p extent = (width @ height)!

Item was changed:
+ ----- Method: FontTest>>testParagraphFallback (in category 'tests') -----
- ----- Method: FontTest>>testParagraphFallback (in category 'testing') -----
testParagraphFallback
"self debug: #testParagraphFallback"
| text p style height width e expect |
e := (Character value: 257) asString.
text := ('test' , e , e , e , e , 'test') asText.
expect := 'test????test'.
p := NewParagraph new.
style := TextStyle default.
p
compose: text
style: style
from: 1
in: (0 @ 0 corner: 100 @ 100).
"See CompositionScanner>>setActualFont: &
CompositionScanner>>composeFrom:inRectangle:firstLine:leftSide:rightSide:"
height := style defaultFont height + style leading.
width := (expect
inject: 0
into: [:tally :next | tally
+ (style defaultFont widthOf: next)]) + p caretWidth.
p adjustRightX.
self assert: p extent = (width @ height).
"Display getCanvas
paragraph: p
bounds: (10 @ 10 extent: 100 @ 100)
color: Color black"!

Item was changed:
+ ----- Method: FontTest>>testResetAfterEmphasized (in category 'tests') -----
- ----- Method: FontTest>>testResetAfterEmphasized (in category 'testing') -----
testResetAfterEmphasized
"self debug: #testResetAfterEmphasized"
| normal derivative |
normal := TextStyle defaultFont.
derivative := normal emphasized: 3.
self assert: (normal derivativeFonts at: 3) == derivative.
normal reset.
self assert: (normal derivativeFonts select:[:any| any isSynthetic]) isEmpty
!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>expectedFailures (in category 'failures') -----
- ----- Method: MultiByteFileStreamTest>>expectedFailures (in category 'testing') -----
expectedFailures
^ #(testLineEndConversionExpectedFailures)!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testAsciiBackChunk (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testAsciiBackChunk (in category 'testing') -----
testAsciiBackChunk

fileName := 'foobackchunk.txt'.
MultiByteFileStream forceNewFileNamed: fileName do: [ :file |
file
lineEndConvention: #cr;
converter: UTF8TextConverter new;
cr; nextChunkPut: 'test1' printString;
cr; nextChunkPut: 'test2' printString.
self
assert: file backChunk = (String cr , 'test2' printString);
assert: file backChunk = (String cr , 'test1' printString) ]!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testBinaryUpTo (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testBinaryUpTo (in category 'testing') -----
testBinaryUpTo
"This is a non regression test for bug http://bugs.squeak.org/view.php?id=6933"

fileName := 'foobug6933'.
MultiByteFileStream forceNewFileNamed: fileName do: [ :file |
file
binary;
nextPutAll: #[ 1 2 3 4 ] ].
MultiByteFileStream oldFileNamed: fileName do: [ :file |
file binary.
self assert: (file upTo: 3) = #[ 1 2 ] ]!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testByteTextConverter (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testByteTextConverter (in category 'testing') -----
testByteTextConverter

| byteCharacters converterClasses |
byteCharacters := Character allByteCharacters.
converterClasses := ByteTextConverter allSubclasses
copyWithoutAll: {ISO8859TextConverter . WinCPTextConverter . MacOSCPTextConverter}.
converterClasses do: [ :converterClass |
| converter stream encoded decoded encoded2 |
converter := converterClass new.
stream := byteCharacters readStream.
"Find bytes that can be decoded by this converter."
encoded := byteCharacters select: [ :e | (converter nextFromStream: stream) notNil ].
"Decode those bytes."
stream := encoded readStream.
decoded := encoded collect: [ :e | converter nextFromStream: stream ].
self assert: stream atEnd.
"Re-encode the decoded bytes using #nextPutAll:toStream:, and check if they match the original bytes."
encoded2 := String streamContents: [ :writeStream |
converter nextPutAll: decoded toStream: writeStream ].
encoded with: encoded2 do: [ :original :reencoded |
self
assert: original charCode = reencoded charCode
description: [ '{1} could not decode or re-encode {2} using #nextPutAll:toStream:. Instead, it yielded {3}.'
format: {
converterClass name.
original charCode.
reencoded charCode } ] ].
"Re-encode the decoded bytes using #nextPut:toStream:, and check if they match the original bytes."
encoded2 := String streamContents: [ :writeStream |
decoded do: [:e | converter nextPut: e toStream: writeStream ] ].
encoded with: encoded2 do: [ :original :reencoded |
self
assert: original charCode = reencoded charCode
description: [ '{1} could not decode or re-encode {2} using #nextPut:toStream:. Instead, it yielded {3}.'
format: {
converterClass name.
original charCode.
reencoded charCode } ] ] ]!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testLineEndConversion (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testLineEndConversion (in category 'testing') -----
testLineEndConversion

| failures |
fileName := 'foolinendconversion.txt'.
failures := OrderedCollection new.
self textConvertersWithLineEndConversionSupport do: [ :textConverterClass |
textConverterClass encodingNames ifNotEmpty: [
#(cr lf crlf) do: [ :lineEndConvention |
self
testLineEndConvention: lineEndConvention
withConverter: textConverterClass
ifFail: [ :expectedResult :result |
failures add: {
textConverterClass.
lineEndConvention.
expectedResult.
result } ] ] ] ].
self assert: failures isEmpty.
"The code below is here to help you see why those cases fail"
failures do: [ :failure |
self
testLineEndConvention: failure second
withConverter: failure first
ifFail: [ :expectedResult :result | self halt ] ].!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testLineEndConversionExpectedFailures (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testLineEndConversionExpectedFailures (in category 'testing') -----
testLineEndConversionExpectedFailures
"Copy of #testLineEndConversion checking for missing line conversion implementations.
This test and corresponding helpers (see senders) can be removed as soon as all TextConverters support line end conversion. --fn"
| failures |
fileName := 'foolinendconversion_failures.txt'.
failures := OrderedCollection new.
self textConvertersWithoutLineEndConversionSupport do: [ :textConverterClass |
textConverterClass encodingNames ifNotEmpty: [
#(cr lf crlf) do: [ :lineEndConvention |
self
testLineEndConvention: lineEndConvention
withConverter: textConverterClass
ifFail: [ :expectedResult :result |
failures add: {
textConverterClass.
lineEndConvention.
expectedResult.
result } ] ] ] ].
self assert: failures isEmpty.
"The code below is here to help you see why those cases fail"
failures do: [ :failure |
self
testLineEndConvention: failure second
withConverter: failure first
ifFail: [ :expectedResult :result | self halt ] ].!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testLineEnding (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testLineEnding (in category 'testing') -----
testLineEnding

fileName := 'foolinend.txt'.
MultiByteFileStream forceNewFileNamed: fileName do: [ :file |
file
wantsLineEndConversion: false;
nextPutAll: 'line 1'; cr;
nextPutAll: 'line 2'; crlf;
nextPutAll: 'line 3'; lf;
nextPutAll: 'line 4' ].
{
{#cr. 'line 1' , String cr , 'line 2' , String cr , 'line 3' , String cr , 'line 4'}.
{#lf. 'line 1' , String cr , 'line 2' , String cr , 'line 3' , String cr , 'line 4'}.
{#crlf. 'line 1' , String cr , 'line 2' , String cr , 'line 3' , String cr , 'line 4'}.
{nil. 'line 1' , String cr , 'line 2' , String crlf , 'line 3' , String lf , 'line 4'}
} do: [:lineEndingResult |
MultiByteFileStream oldFileNamed: fileName do: [ :file |
file lineEndConvention: lineEndingResult first.
self assert: file upToEnd = lineEndingResult last ] ]!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testLineEndingChunk (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testLineEndingChunk (in category 'testing') -----
testLineEndingChunk
| failures |
fileName := 'foolinend.txt'.
failures := OrderedCollection new.
MultiByteFileStream forceNewFileNamed: fileName do: [ :file |
file
wantsLineEndConversion: false;
nextPutAll: 'line 1'; cr;
nextPutAll: 'line 2'; crlf;
nextPutAll: 'line 3'; lf;
nextPutAll: 'line 4'; nextPut: $!! ].
{
{#cr. 'line 1' , String cr , 'line 2' , String cr , 'line 3' , String cr , 'line 4'}.
{#lf. 'line 1' , String cr , 'line 2' , String cr , 'line 3' , String cr , 'line 4'}.
{#crlf. 'line 1' , String cr , 'line 2' , String cr , 'line 3' , String cr , 'line 4'}.
{nil. 'line 1' , String cr , 'line 2' , String crlf , 'line 3' , String lf , 'line 4'}
} do: [:lineEndingResult |
MultiByteFileStream oldFileNamed: fileName do: [ :file | | actual |
file lineEndConvention: lineEndingResult first.
lineEndingResult last = (actual := file nextChunk) ifFalse: [
failures add: (lineEndingResult copyWith: actual).
].
] ].
self assert: failures isEmpty!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testLineEndingWithWideStrings (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testLineEndingWithWideStrings (in category 'testing') -----
testLineEndingWithWideStrings

| cr lf crlf |
fileName := 'foolinend.txt'.
cr := String cr asWideString.
lf := String lf asWideString.
crlf := String crlf asWideString.
MultiByteFileStream forceNewFileNamed: fileName do: [ :file |
file
wantsLineEndConversion: false;
nextPutAll: 'line 1'; nextPutAll: cr;
nextPutAll: 'line 2'; nextPutAll: crlf;
nextPutAll: 'line 3'; nextPutAll: lf;
nextPutAll: 'line 4' ].
{
{#cr. 'line 1' , String cr , 'line 2' , String cr , 'line 3' , String cr , 'line 4'}.
{#lf. 'line 1' , String cr , 'line 2' , String cr , 'line 3' , String cr , 'line 4'}.
{#crlf. 'line 1' , String cr , 'line 2' , String cr , 'line 3' , String cr , 'line 4'}.
{nil. 'line 1' , String cr , 'line 2' , String crlf , 'line 3' , String lf , 'line 4'}
} do: [ :lineEndingResult |
MultiByteFileStream oldFileNamed: fileName do: [ :file |
file lineEndConvention: lineEndingResult first.
self assert: file upToEnd = lineEndingResult last ] ]!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testMultiByteTextConverter (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testMultiByteTextConverter (in category 'testing') -----
testMultiByteTextConverter
| strings converterClasses |
strings := {
String newFrom: ((0 to: 255) collect: [:e | Unicode value: e]).
String newFrom: ((0 to: 1023) collect: [:e | Unicode value: e]).
}.

converterClasses := {
UTF8TextConverter . UTF16TextConverter .
"CompoundTextConverter ."
"EUCJPTextConverter . CNGBTextConverter . ShiftJISTextConverter . EUCKRTextConverter"}.
converterClasses do: [:converterClass |
strings do: [:string |
| converter stream |
converter := converterClass new.
stream := String new writeStream.
converter nextPutAll: string toStream: stream.
stream := stream contents readStream.
string do: [:e | | decoded |
decoded := converter nextFromStream: stream.
self assert: e charCode = decoded charCode].
self assert: stream atEnd.

stream := String new writeStream.
string do: [:e | converter nextPut: e toStream: stream].
stream := stream contents readStream.
string do: [:e | | decoded |
decoded := converter nextFromStream: stream.
self assert: e charCode = decoded charCode].
self assert: stream atEnd]]!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testNextLine (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testNextLine (in category 'testing') -----
testNextLine

fileName := 'foonextline.txt'.
MultiByteFileStream forceNewFileNamed: fileName do: [ :file |
file
wantsLineEndConversion: false;
nextPutAll: 'line 1'; cr;
nextPutAll: 'line 2'; crlf;
nextPutAll: 'line 3'; lf;
nextPutAll: 'line 4' ].
#(cr lf crlf nil) do: [:lineEnding |
MultiByteFileStream oldFileNamed: fileName do: [ :file |
file lineEndConvention: lineEnding.
self
assert: file nextLine = 'line 1';
assert: file nextLine = 'line 2';
assert: file nextLine = 'line 3';
assert: file nextLine = 'line 4';
assert: file nextLine = nil ] ]!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testNextPutAllStartingAt (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testNextPutAllStartingAt (in category 'testing') -----
testNextPutAllStartingAt

| result |
fileName := 'foonextputallstartingat.txt'.
MultiByteFileStream forceNewFileNamed: fileName do: [ :file |
{ 'abcde' asWideString. 'abcde' } do: [ :string |
file
next: 1 putAll: string startingAt: 5;
next: 3 putAll: string startingAt: 2;
next: 1 putAll: string startingAt: 1 ] ].
result := StandardFileStream readOnlyFileNamed: fileName do: [ :file |
file binary; contents ].
self assert: #[101 98 99 100 97 101 98 99 100 97] equals: result
!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testNextPutAllUtfsStartingAt (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testNextPutAllUtfsStartingAt (in category 'testing') -----
testNextPutAllUtfsStartingAt

| result |
fileName := 'foonextputallstartingat.txt'.
{'utf-16' . #[0 64 216 0 220 0 216 0 220 1 216 0 220 2] .
'utf-32'. #[0 0 0 64 0 1 0 0 0 1 0 1 0 1 0 2]}
pairsDo: [:encodingName :encodingResult |
MultiByteFileStream forceNewFileNamed: fileName do: [ :file | | string |
file converter: (TextConverter newForEncoding: encodingName).
string := self unicodeString.
file
next: 2 putAll: string startingAt: 1;
next: 1 putAll: string startingAt: 3;
next: 1 putAll: string startingAt: 4 ].
result := StandardFileStream readOnlyFileNamed: fileName do: [ :file |
file binary; contents ].

"See for example: https://unicode-table.com/de/10000/ --pre"
self assert: encodingResult equals: result]


!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testNonAsciiBackChunk (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testNonAsciiBackChunk (in category 'testing') -----
testNonAsciiBackChunk
"Note: this is an expected failure: MultiByteFileStream is not equipped to read back non ASCII String... (no comment)
As a consequence, never use non ASCII in method category nor in your initials. That would make a few tools blind..."

fileName := 'foobackchunk.txt'.
MultiByteFileStream forceNewFileNamed: fileName do: [ :file |
file
lineEndConvention: #cr;
converter: UTF8TextConverter new;
cr; nextChunkPut: 'testé' printString;
cr; nextChunkPut: 'test' printString.
self assert: file backChunk = (String cr , 'test' printString).
self assert: file backChunk = (String cr , 'testé' printString) ]!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testUpToAllAscii (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testUpToAllAscii (in category 'testing') -----
testUpToAllAscii
"This test case is inspired by Mantis #4665."
"Compare to testUpToAllUtf."

| resultA resultB |
fileName :='testUpToAll.in'.
FileDirectory default forceNewFileNamed: fileName do: [ :out |
out nextPutAll: 'A<'. "Encodes to byte sequence 413C" ].

resultA := FileDirectory default readOnlyFileNamed: fileName do: [ :in |
in upToAll: '<' ].

resultB := FileDirectory default readOnlyFileNamed: fileName do: [ :in |
in upTo: $< ].

self assert: resultA = resultB
!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testUpToAllNonZeroLength (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testUpToAllNonZeroLength (in category 'testing') -----
testUpToAllNonZeroLength
"Ensures that upToAll: correctly skips over the nonzero-length separator."

fileName :='testUpToAll.in'.
FileDirectory default forceNewFileNamed: fileName do: [ :out |
out nextPutAll: 231 asCharacter asString, 'a<b<<c' ].

FileDirectory default readOnlyFileNamed: fileName do: [ :in |
self assert: in next = 231 asCharacter.
self assert: (in upToAll: '<<') = 'a<b'.
self assert: in next = $c ]!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testUpToAllUtf (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testUpToAllUtf (in category 'testing') -----
testUpToAllUtf
"This test case is adapted from Mantis #4665."
"MultiByteFileStream was relying on PositionableStream>>#match: to discover the position immediately following the delimiter collection. It would then use #next: to retrieve a number of *characters* computed as the difference in stream positions. However, stream positions are measured in *bytes*, not characters, so this would lead to misalignment when the skipped text included UTF-8 encoded characters."

| resultA resultB |
fileName :='testUpToAll.in'.
FileDirectory default forceNewFileNamed: fileName do: [ :out |
out nextPutAll: 231 asCharacter asString, '<'. "Encodes to byte sequence C3A73C" ].

resultA := FileDirectory default readOnlyFileNamed: fileName do: [ :in |
in upToAll: '<' ].

resultB := FileDirectory default readOnlyFileNamed: fileName do: [ :in |
in upTo: $< ].

self assert: resultA = resultB
!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testUpToAllZeroLength (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testUpToAllZeroLength (in category 'testing') -----
testUpToAllZeroLength
"Ensures that upToAll: behaves correctly with a zero-length separator."

fileName :='testUpToAll.in'.
FileDirectory default forceNewFileNamed: fileName do: [ :out |
out nextPutAll: 231 asCharacter asString, 'a<b<<c' ].

FileDirectory default readOnlyFileNamed: fileName do: [ :in |
self assert: in next = 231 asCharacter.
self assert: (in upToAll: '') = ''.
self assert: in next = $a ]!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testUpToPositionNonZero (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testUpToPositionNonZero (in category 'testing') -----
testUpToPositionNonZero
"Ensures that upToPosition: behaves correctly with a non-zero-length read."

fileName := 'testUpToPosition.in'.
FileDirectory default forceNewFileNamed: fileName do: [ :out |
out nextPutAll: 231 asCharacter asString, 'a<b' ].

FileDirectory default readOnlyFileNamed: fileName do: [ :in |
self assert: in next = 231 asCharacter.
self assert: (in upToPosition: in position + 2) = 'a<'.
self assert: in next = $b ]!

Item was changed:
+ ----- Method: MultiByteFileStreamTest>>testUpToPositionZero (in category 'tests') -----
- ----- Method: MultiByteFileStreamTest>>testUpToPositionZero (in category 'testing') -----
testUpToPositionZero
"Ensures that upToPosition: behaves correctly with a zero-length read."

fileName := 'testUpToPosition.in'.
FileDirectory default forceNewFileNamed: fileName do: [ :out |
out nextPutAll: 231 asCharacter asString, 'a<b' ].

FileDirectory default readOnlyFileNamed: fileName do: [ :in |
self assert: in next = 231 asCharacter.
self assert: (in upToPosition: in position) = ''.
self assert: in next = $a ]!

Item was removed:
- ----- Method: UTF16TextConverterTest>>testByteOrders (in category 'testing') -----
- testByteOrders
- |converter originalText bytes decodedText |
- originalText := 'test'.
- converter := UTF16TextConverter new.
-
- "Default (ie useLittleEndian instvar nil)"
- bytes := (originalText convertToWithConverter: converter).
- decodedText := bytes convertFromWithConverter: converter.
-
- self assert: originalText equals: decodedText.
-
- "Little-endian"
- converter useLittleEndian: true.
-
- bytes := (originalText convertToWithConverter: converter).
- decodedText := bytes convertFromWithConverter: converter.
-
- self assert: originalText equals: decodedText.
-
- "Big-endian"
- converter useLittleEndian: false.
-
- bytes := (originalText convertToWithConverter: converter).
- decodedText := bytes convertFromWithConverter: converter.
-
- self assert: originalText equals: decodedText.
-
- !

Item was changed:
+ ----- Method: UTF8EdgeCaseTest>>expectBytesToFailDecoding: (in category 'tests') -----
- ----- Method: UTF8EdgeCaseTest>>expectBytesToFailDecoding: (in category 'asserting') -----
expectBytesToFailDecoding: aByteArray
self should: [aByteArray utf8Decoded] raise: InvalidUTF8!

Item was changed:
+ ----- Method: UTF8EdgeCaseTest>>expectHex:toDecodeToCodepoint: (in category 'tests') -----
- ----- Method: UTF8EdgeCaseTest>>expectHex:toDecodeToCodepoint: (in category 'asserting') -----
expectHex: aString toDecodeToCodepoint: anInteger
self expectHex: aString toDecodeToCodepoints: { anInteger }
!

Item was changed:
+ ----- Method: UTF8EdgeCaseTest>>expectHex:toDecodeToCodepoints: (in category 'tests') -----
- ----- Method: UTF8EdgeCaseTest>>expectHex:toDecodeToCodepoints: (in category 'asserting') -----
expectHex: aString toDecodeToCodepoints: anArray
| s |
s := (ByteArray readHexFrom: aString) utf8Decoded.
self assert: anArray size equals: s size.
self assert: anArray asArray equals: (s asArray collect: [:c | c asInteger]).!

Item was changed:
+ ----- Method: UTF8EdgeCaseTest>>expectHexToFailDecoding: (in category 'tests') -----
- ----- Method: UTF8EdgeCaseTest>>expectHexToFailDecoding: (in category 'asserting') -----
expectHexToFailDecoding: aString
self should: [(ByteArray readHexFrom: aString) utf8Decoded] raise: InvalidUTF8.
!

Item was changed:
+ ----- Method: UTFTextConverterWithByteOrderTest class>>isAbstract (in category 'testing') -----
- ----- Method: UTFTextConverterWithByteOrderTest class>>isAbstract (in category 'as yet unclassified') -----
isAbstract

^ self = UTFTextConverterWithByteOrderTest!

Loading...