Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Part 4 Tests:
- Simple tests with non-negative values…
- //starting with the most basic test...
- java Endianness 0 0 0 0
- Memory Contents
- Addr Value
- 0: 0x0
- 1: 0x0
- 2: 0x0
- 3: 0x0
- The big endian integer value at address 0 is 0
- The little endian integer value at address 0 is 0
- java Endianness 0 0 0 1
- Memory Contents
- Addr Value
- 0: 0x0
- 1: 0x0
- 2: 0x0
- 3: 0x1
- The big endian integer value at address 0 is 1
- The little endian integer value at address 0 is 16777216
- java Endianness 1 2 3 4
- Memory Contents
- Addr Value
- 0: 0x1
- 1: 0x2
- 2: 0x3
- 3: 0x4
- The big endian integer value at address 0 is 16909060
- The little endian integer value at address 0 is 67305985
- //flipping the entered bytes to check if produced value is correct...
- java Endianness 4 3 2 1
- Memory Contents
- Addr Value
- 0: 0x4
- 1: 0x3
- 2: 0x2
- 3: 0x1
- The big endian integer value at address 0 is 67305985
- The little endian integer value at address 0 is 16909060
- //This test checks to see if big- and little-endian return the same value as expected...
- java Endianness 9 7 7 9
- Memory Contents
- Addr Value
- 0: 0x9
- 1: 0x7
- 2: 0x7
- 3: 0x9
- The big endian integer value at address 0 is 151455497
- The little endian integer value at address 0 is 151455497
- //Tests with bigger numbers...
- java Endianness 4 AD BD 9
- Memory Contents
- Addr Value
- 0: 0x4
- 1: 0xad
- 2: 0xbd
- 3: 0x9
- The big endian integer value at address 0 is 78494985
- The little endian integer value at address 0 is 163425540
- //Testing biggest possible positive value with a 32-bit integer...
- java Endianness 7F FF FF FF
- Memory Contents
- Addr Value
- 0: 0x7f
- 1: 0xff
- 2: 0xff
- 3: 0xff
- The big endian integer value at address 0 is 2147483647
- The little endian integer value at address 0 is -129
- Testing bytes with 1 as the eighth bit:
- //checks if unsigned/signed bytes work as intended..
- java Endianness 00 00 00 FF
- Memory Contents
- Addr Value
- 0: 0x0
- 1: 0x0
- 2: 0x0
- 3: 0xff
- The big endian integer value at address 0 is 255
- The little endian integer value at address 0 is -16777216
- //checks if both interpretations produce the same value, with negative bytes
- java Endianness FF 00 00 FF
- Memory Contents
- Addr Value
- 0: 0xff
- 1: 0x0
- 2: 0x0
- 3: 0xff
- The big endian integer value at address 0 is -16776961
- The little endian integer value at address 0 is -16776961
- //another interesting case that is worth testing to see if -1 is produced
- java Endianness ff ff ff ff
- Memory Contents
- Addr Value
- 0: 0xff
- 1: 0xff
- 2: 0xff
- 3: 0xff
- The big endian integer value at address 0 is -1
- The little endian integer value at address 0 is -1
- //now moving onto bigger bytes and seeing if they work as intended
- java Endianness b2 5e 94 9A
- Memory Contents
- Addr Value
- 0: 0xb2
- 1: 0x5e
- 2: 0x94
- 3: 0x9a
- The big endian integer value at address 0 is -1302424422
- The little endian integer value at address 0 is -1701552462
- java Endianness 9A 94 5e b2
- Memory Contents
- Addr Value
- 0: 0x9a
- 1: 0x94
- 2: 0x5e
- 3: 0xb2
- The big endian integer value at address 0 is -1701552462
- The little endian integer value at address 0 is -1302424422
- java Endianness 80 1 2 3
- Memory Contents
- Addr Value
- 0: 0x80
- 1: 0x1
- 2: 0x2
- 3: 0x3
- The big endian integer value at address 0 is -2147417597
- The little endian integer value at address 0 is 50463104
- //last test to check the smallest possible number produced by a 32-bit integer
- java Endianness 80 00 00 00
- Memory Contents
- Addr Value
- 0: 0x80
- 1: 0x0
- 2: 0x0
- 3: 0x0
- The big endian integer value at address 0 is -2147483648
- The little endian integer value at address 0 is 128
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement