The story
Suppose we have a function called 'bits_serialize'.
This function should serialize a given data into bits_per_io bits per package (for examples see the tests below and what they return).
This function have the following signature: bits_serialize {bits_per_io description}, where:
- bits_per_io
- How much bits each package have.
- description
- a pair of {data bits}, where:
- data
- the data we want to serialize.
- bits
- the size, in bits, we want to serialize this data.
Test code
# Generated using http://pygments.org/
source unit-under-test.tcl ;# contains the definition of bits_serealize test base--always-ok {This is as simple as it gets.} -constraints { } -setup { } -body { return TRUE } -cleanup { } -result TRUE test bits_serealize--partial-quanta {description here...} -constraints { } -setup { } -body { return [bits_serealize 32 " 0x01 16 "] } -cleanup { } -result [list 1] test bits_serealize--full-quanta {description here...} -constraints { } -setup { } -body { return [bits_serealize 32 " 0xFFFFFFFF 32 "] } -cleanup { } -result [list [ format "%u" 0xFFFFFFFF ]] test bits_serealize--over-quanta {description here...} -constraints { } -setup { } -body { return [bits_serealize 32 " 0x060504030201 64 "] } -cleanup { } -result [list [ format "%u" 0x04030201 ] [ format "%u" 0x0605 ]] test bits_serealize--way-over-quanta {description here...} -constraints { } -setup { } -body { return [bits_serealize 32 " 0x060504030201 320 "] } -cleanup { } -result [list [ format "%u" 0x04030201 ] [ format "%u" 0x0605 ] 0 0 0 0 0 0 0 0] test bits_serealize--cross-quanta {description here...} -constraints { } -setup { } -body { return [bits_serealize 32 " 0xFF 1 0xFF 2 0xFF 3 0xFF 4 0xFF 6 0x04030201 32 "] } -cleanup { } -result [list [ format "%u" 0x201FFFF ] [ format "%u" 0x403 ]] test bits_serealize--quanta-and-half {description here...} -constraints { } -setup { } -body { return [bits_serealize 32 " 0xFFEEDDCCBBAA 48 "] } -cleanup { } -result [list [ format "%u" 0xDDCCBBAA ] [ format "%u" 0xFFEE ]]
eclipse-unit-testing |
Results
++++ base--always-ok PASSED
++++ bits_serealize--partial-quanta PASSED
++++ bits_serealize--full-quanta PASSED
++++ bits_serealize--over-quanta PASSED
++++ bits_serealize--way-over-quanta PASSED
++++ bits_serealize--cross-quanta PASSED
++++ bits_serealize--quanta-and-half PASSED
My impression
I definitely recommend using this unit!! and to my surprise eclipse supports it built in (see picture ==>).
Thanks of your posting, which made me to join Testing tools online training @ www.Monstercourses.com
ReplyDelete