daily pastebin goal
53%
SHARE
TWEET

Untitled

a guest Jan 12th, 2018 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Part 4 Tests:
  2.  
  3. Simple tests with non-negative values…
  4.  
  5. //starting with the most basic test...
  6. java Endianness 0 0 0 0
  7. Memory Contents
  8.   Addr   Value
  9.     0:   0x0    
  10.     1:   0x0    
  11.     2:   0x0    
  12.     3:   0x0    
  13. The big    endian integer value at address 0 is 0
  14. The little endian integer value at address 0 is 0
  15.  
  16. java Endianness 0 0 0 1
  17. Memory Contents
  18.   Addr   Value
  19.     0:   0x0    
  20.     1:   0x0    
  21.     2:   0x0    
  22.     3:   0x1    
  23. The big    endian integer value at address 0 is 1
  24. The little endian integer value at address 0 is 16777216
  25.  
  26.  
  27. java Endianness 1 2 3 4
  28. Memory Contents
  29.   Addr   Value
  30.     0:   0x1    
  31.     1:   0x2    
  32.     2:   0x3    
  33.     3:   0x4    
  34. The big    endian integer value at address 0 is 16909060
  35. The little endian integer value at address 0 is 67305985
  36.  
  37. //flipping the entered bytes to check if produced value is correct...
  38. java Endianness 4 3 2 1
  39. Memory Contents
  40.   Addr   Value
  41.     0:   0x4    
  42.     1:   0x3    
  43.     2:   0x2    
  44.     3:   0x1    
  45. The big    endian integer value at address 0 is 67305985
  46. The little endian integer value at address 0 is 16909060
  47.  
  48. //This test checks to see if big- and little-endian return the same value as expected...
  49. java Endianness 9 7 7 9
  50. Memory Contents
  51.   Addr   Value
  52.     0:   0x9    
  53.     1:   0x7    
  54.     2:   0x7    
  55.     3:   0x9    
  56. The big    endian integer value at address 0 is 151455497
  57. The little endian integer value at address 0 is 151455497
  58.  
  59. //Tests with bigger numbers...
  60. java Endianness 4 AD BD 9
  61. Memory Contents
  62.   Addr   Value
  63.     0:   0x4    
  64.     1:   0xad  
  65.     2:   0xbd  
  66.     3:   0x9    
  67. The big    endian integer value at address 0 is 78494985
  68. The little endian integer value at address 0 is 163425540
  69.  
  70. //Testing biggest possible positive value with a 32-bit integer...
  71. java Endianness 7F FF FF FF
  72. Memory Contents
  73.   Addr   Value
  74.     0:   0x7f  
  75.     1:   0xff  
  76.     2:   0xff  
  77.     3:   0xff  
  78. The big    endian integer value at address 0 is 2147483647
  79. The little endian integer value at address 0 is -129
  80.  
  81. Testing bytes with 1 as the eighth bit:
  82.  
  83. //checks if unsigned/signed bytes work as intended..
  84. java Endianness 00 00 00 FF
  85. Memory Contents
  86.   Addr   Value
  87.     0:   0x0    
  88.     1:   0x0    
  89.     2:   0x0    
  90.     3:   0xff  
  91. The big    endian integer value at address 0 is 255
  92. The little endian integer value at address 0 is -16777216
  93.  
  94. //checks if both interpretations produce the same value, with negative bytes
  95. java Endianness FF 00 00 FF
  96. Memory Contents
  97.   Addr   Value
  98.     0:   0xff  
  99.     1:   0x0    
  100.     2:   0x0    
  101.     3:   0xff  
  102. The big    endian integer value at address 0 is -16776961
  103. The little endian integer value at address 0 is -16776961
  104.  
  105. //another interesting case that is worth testing to see if -1 is produced
  106. java Endianness ff ff ff ff
  107. Memory Contents
  108.   Addr   Value
  109.     0:   0xff  
  110.     1:   0xff  
  111.     2:   0xff  
  112.     3:   0xff  
  113. The big    endian integer value at address 0 is -1
  114. The little endian integer value at address 0 is -1
  115.  
  116. //now moving onto bigger bytes and seeing if they work as intended
  117. java Endianness b2 5e 94 9A
  118. Memory Contents
  119.   Addr   Value
  120.     0:   0xb2  
  121.     1:   0x5e  
  122.     2:   0x94  
  123.     3:   0x9a  
  124. The big    endian integer value at address 0 is -1302424422
  125. The little endian integer value at address 0 is -1701552462
  126.  
  127. java Endianness 9A 94 5e b2
  128. Memory Contents
  129.   Addr   Value
  130.     0:   0x9a  
  131.     1:   0x94  
  132.     2:   0x5e  
  133.     3:   0xb2  
  134. The big    endian integer value at address 0 is -1701552462
  135. The little endian integer value at address 0 is -1302424422
  136.  
  137. java Endianness 80 1 2 3
  138. Memory Contents
  139.   Addr   Value
  140.     0:   0x80  
  141.     1:   0x1    
  142.     2:   0x2    
  143.     3:   0x3    
  144. The big    endian integer value at address 0 is -2147417597
  145. The little endian integer value at address 0 is 50463104
  146.  
  147. //last test to check the smallest possible number produced by a 32-bit integer
  148. java Endianness 80 00 00 00
  149. Memory Contents
  150.   Addr   Value
  151.     0:   0x80  
  152.     1:   0x0    
  153.     2:   0x0    
  154.     3:   0x0    
  155. The big    endian integer value at address 0 is -2147483648
  156. The little endian integer value at address 0 is 128
RAW Paste Data
Top