Andreas Raab uploaded a new version of VersionNumberTests to project The Trunk:
http://source.squeak.org/trunk/VersionNumberTests-it.2.mcz ==================== Summary ==================== Name: VersionNumberTests-it.2 Author: it Time: 17 July 2009, 10:23:16 am UUID: e4d19f1e-407f-0944-9778-f9f5e92f4dca Ancestors: VersionNumberTests-it.1 Added tests for methods VersionNumber>>=, VersionNumber>>initializeNumbers and String>>asVersion. 29% Code Coverage. =============== Diff against VersionNumberTests-it.1 =============== Item was added: + ----- Method: VersionNumberTest>>testIsEqual (in category 'Tests') ----- + testIsEqual + "Test VersionNumber>>=" + + | version | + version := VersionNumber first. + self assert: (VersionNumber new initializeNumbers: #(1)) = version. + self assert: (VersionNumber new initializeNumbers: #(2)) = (version next). + self assert: (VersionNumber new initializeNumbers: #(1 1)) = (version branchNext).! Item was added: + ----- Method: VersionNumberTest>>testAsVersion (in category 'Tests') ----- + testAsVersion + "note: a version number string '3 2 1' will only consider the first number as a version, ignoring the trailing '2 1'. Whether it is a desired feature or not should be determined." + + | numbers version | + numbers := { + '' -> #(). '1 '-> #(1). '1.2' -> #(1 2). '3.4.5' -> #(3 4 5). + '6.7.890' -> #(6 7 890). '9 8' -> #(9). '98 7 6' -> #(98). '54.3 2 1' -> #(54 3) + }. + + numbers do: [:item | + version := (item key) asVersion. + + self assert: (VersionNumber = version class). + self assert: ((item value) = version numbers). + ]. + + self shouldnt: ['9999999999999999999' asVersion] raise: TestResult error. + + self should: ['-1' asVersion] raise: TestResult error. + self should: [' 1' asVersion] raise: TestResult error. "notice leading space!!" + self should: ['version' asVersion] raise: TestResult error. + self should: ['1.2.10.20.-1.4' asVersion] raise: TestResult error. + self should: ['1.2.10.20.R4' asVersion] raise: TestResult error. + ! Item was added: + ----- Method: VersionNumberTest>>testInitializeNumbers (in category 'Tests') ----- + testInitializeNumbers + | numbers version | + numbers := #(#(1) #(1 2) #(3 4 5) #(6 7 890)). + + numbers do: [:item | + version := VersionNumber new initializeNumbers: item. + + self assert: (VersionNumber = version class). + self assert: (item = version numbers). + ]. + + self shouldnt: [VersionNumber new initializeNumbers: #()] raise: TestResult error. + self shouldnt: [VersionNumber new initializeNumbers: #(9999999999999999999)] raise: TestResult error. + + self should: [VersionNumber new initializeNumbers: #(0)] raise: TestResult error. + self should: [VersionNumber new initializeNumbers: #(-1)] raise: TestResult error. + self should: [VersionNumber new initializeNumbers: #(1 2 10 20 -1 4)] raise: TestResult error. + self should: [VersionNumber new initializeNumbers: #(1 2 10 20 '1' 4)] raise: TestResult error. + self should: [VersionNumber new initializeNumbers: #('version')] raise: TestResult error. + ! |
Free forum by Nabble | Edit this page |