SHARE
TWEET

Untitled

a guest Oct 12th, 2017 45 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var photos = [MWPhoto] = [MWPhoto]()
  2.  
  3. func numberOfPhotosInPhotoBrowser(photoBrowser: MWPhotoBrowser!) -> UInt {
  4.  
  5.     return self.photos.count
  6. }
  7.  
  8. func photoBrowser(photoBrowser: MWPhotoBrowser!, photoAtIndex index: UInt) -> MWPhotoProtocol! {
  9.  
  10.     return self.photos[index]
  11. }
  12.    
  13. func numberOfPhotosInPhotoBrowser(photoBrowser: MWPhotoBrowser!) -> UInt {
  14.  
  15.     return UInt(self.photos.count)
  16. }
  17.    
  18. func photoBrowser(photoBrowser: MWPhotoBrowser!, photoAtIndex index: UInt) -> MWPhotoProtocol! {
  19.  
  20.     return self.photos[Int(index)]
  21. }
  22.    
  23. // initializing Int
  24. var someInt: Int = 8
  25. someInt
  26.  
  27. // Converting Int to UInt
  28. var someIntToUInt: UInt = UInt(someInt)
  29. someIntToUInt
  30.  
  31. // initializing UInt  
  32. var someUInt: UInt = 10
  33. someUInt
  34.  
  35. // Converting UInt to Int  
  36. var someUIntToInt: Int = Int(someUInt)
  37. someUIntToInt
  38.    
  39. let intVal = -1
  40. let uintVal = UInt(bitPattern: intVal) // uintVal == 0xffffffffffffffff
  41.    
  42. extension UInt {
  43.     /// SwiftExtensionKit
  44.     var toInt: Int { return Int(self) }
  45. }
  46.    
  47. self.photos[index].toInt
  48.    
  49. /// Class containing a large number of static methods to convert an Int to a UInt or vice-versa, and
  50. /// also to perform conversions between different bit sizes, for example UInt32 to UInt8.
  51. ///
  52. /// Many of these "conversions" are trivial, and are only included for the sake of completeness.
  53. ///
  54. /// A few of the conversions involving Int and UInt can give different results when run on 32-bit
  55. /// and 64-bit systems. All of the conversion where the bit size of both the source and the target
  56. /// are specified will always give the same result independent of platform.
  57. public class JDI {
  58.  
  59.    // MARK: - To signed Int
  60.  
  61.    // To Int8
  62.    public static func ToInt8(_ x : Int8) -> Int8 {
  63.       return x
  64.    }
  65.    public static func ToInt8(_ x : Int32) -> Int8 {
  66.       return Int8(truncatingBitPattern: x)
  67.    }
  68.    public static func ToInt8(_ x : Int64) -> Int8 {
  69.       return Int8(truncatingBitPattern: x)
  70.    }
  71.    public static func ToInt8(_ x : Int) -> Int8 {
  72.       return Int8(truncatingBitPattern: x)
  73.    }
  74.    public static func ToInt8(_ x : UInt8) -> Int8 {
  75.       return Int8(bitPattern: x)
  76.    }
  77.    public static func ToInt8(_ x : UInt32) -> Int8 {
  78.       return Int8(truncatingBitPattern: x)
  79.    }
  80.    public static func ToInt8(_ x : UInt64) -> Int8 {
  81.       return Int8(truncatingBitPattern: x)
  82.    }
  83.    public static func ToInt8(_ x : UInt) -> Int8 {
  84.       return Int8(truncatingBitPattern: x)
  85.    }
  86.  
  87.    // To Int32
  88.    public static func ToInt32(_ x : Int8) -> Int32 {
  89.       return Int32(x)
  90.    }
  91.    public static func ToInt32(_ x : Int32) -> Int32 {
  92.       return x
  93.    }
  94.    public static func ToInt32(_ x : Int64) -> Int32 {
  95.       return Int32(truncatingBitPattern: x)
  96.    }
  97.    public static func ToInt32(_ x : Int) -> Int32 {
  98.       return Int32(truncatingBitPattern: x)
  99.    }
  100.    public static func ToInt32(_ x : UInt8) -> Int32 {
  101.       return Int32(x)
  102.    }
  103.    public static func ToInt32(_ x : UInt32) -> Int32 {
  104.       return Int32(bitPattern: x)
  105.    }
  106.    public static func ToInt32(_ x : UInt64) -> Int32 {
  107.       return Int32(truncatingBitPattern: x)
  108.    }
  109.    public static func ToInt32(_ x : UInt) -> Int32 {
  110.       return Int32(truncatingBitPattern: x)
  111.    }
  112.  
  113.    // To Int64
  114.    public static func ToInt64(_ x : Int8) -> Int64 {
  115.       return Int64(x)
  116.    }
  117.    public static func ToInt64(_ x : Int32) -> Int64 {
  118.       return Int64(x)
  119.    }
  120.    public static func ToInt64(_ x : Int64) -> Int64 {
  121.       return x
  122.    }
  123.    public static func ToInt64(_ x : Int) -> Int64 {
  124.       return Int64(x)
  125.    }
  126.    public static func ToInt64(_ x : UInt8) -> Int64 {
  127.       return Int64(x)
  128.    }
  129.    public static func ToInt64(_ x : UInt32) -> Int64 {
  130.       return Int64(x)
  131.    }
  132.    public static func ToInt64(_ x : UInt64) -> Int64 {
  133.       return Int64(bitPattern: x)
  134.    }
  135.    public static func ToInt64(_ x : UInt) -> Int64 {
  136.       return Int64(bitPattern: UInt64(x))  // Does not extend high bit of 32-bit input
  137.    }
  138.  
  139.    // To Int
  140.    public static func ToInt(_ x : Int8) -> Int {
  141.       return Int(x)
  142.    }
  143.    public static func ToInt(_ x : Int32) -> Int {
  144.       return Int(x)
  145.    }
  146.    public static func ToInt(_ x : Int64) -> Int {
  147.       return Int(truncatingBitPattern: x)
  148.    }
  149.    public static func ToInt(_ x : Int) -> Int {
  150.       return x
  151.    }
  152.    public static func ToInt(_ x : UInt8) -> Int {
  153.       return Int(x)
  154.    }
  155.    public static func ToInt(_ x : UInt32) -> Int {
  156.       if MemoryLayout<Int>.size == MemoryLayout<Int32>.size {
  157.          return Int(Int32(bitPattern: x))  // For 32-bit systems, non-authorized interpretation
  158.       }
  159.       return Int(x)
  160.    }
  161.    public static func ToInt(_ x : UInt64) -> Int {
  162.       return Int(truncatingBitPattern: x)
  163.    }
  164.    public static func ToInt(_ x : UInt) -> Int {
  165.       return Int(bitPattern: x)
  166.    }
  167.  
  168.    // MARK: - To unsigned Int
  169.  
  170.    // To UInt8
  171.    public static func ToUInt8(_ x : Int8) -> UInt8 {
  172.       return UInt8(bitPattern: x)
  173.    }
  174.    public static func ToUInt8(_ x : Int32) -> UInt8 {
  175.       return UInt8(truncatingBitPattern: x)
  176.    }
  177.    public static func ToUInt8(_ x : Int64) -> UInt8 {
  178.       return UInt8(truncatingBitPattern: x)
  179.    }
  180.    public static func ToUInt8(_ x : Int) -> UInt8 {
  181.       return UInt8(truncatingBitPattern: x)
  182.    }
  183.    public static func ToUInt8(_ x : UInt8) -> UInt8 {
  184.       return x
  185.    }
  186.    public static func ToUInt8(_ x : UInt32) -> UInt8 {
  187.       return UInt8(truncatingBitPattern: x)
  188.    }
  189.    public static func ToUInt8(_ x : UInt64) -> UInt8 {
  190.       return UInt8(truncatingBitPattern: x)
  191.    }
  192.    public static func ToUInt8(_ x : UInt) -> UInt8 {
  193.       return UInt8(truncatingBitPattern: x)
  194.    }
  195.  
  196.    // To UInt32
  197.    public static func ToUInt32(_ x : Int8) -> UInt32 {
  198.       return UInt32(bitPattern: Int32(x))  // Extend sign bit, assume minus input significant
  199.    }
  200.    public static func ToUInt32(_ x : Int32) -> UInt32 {
  201.       return UInt32(bitPattern: x)
  202.    }
  203.    public static func ToUInt32(_ x : Int64) -> UInt32 {
  204.       return UInt32(truncatingBitPattern: x)
  205.    }
  206.    public static func ToUInt32(_ x : Int) -> UInt32 {
  207.       return UInt32(truncatingBitPattern: x)
  208.    }
  209.    public static func ToUInt32(_ x : UInt8) -> UInt32 {
  210.       return UInt32(x)
  211.    }
  212.    public static func ToUInt32(_ x : UInt32) -> UInt32 {
  213.       return x
  214.    }
  215.    public static func ToUInt32(_ x : UInt64) -> UInt32 {
  216.       return UInt32(truncatingBitPattern: x)
  217.    }
  218.    public static func ToUInt32(_ x : UInt) -> UInt32 {
  219.       return UInt32(truncatingBitPattern: x)
  220.    }
  221.  
  222.    // To UInt64
  223.    public static func ToUInt64(_ x : Int8) -> UInt64 {
  224.       return UInt64(bitPattern: Int64(x))  // Extend sign bit, assume minus input significant
  225.    }
  226.    public static func ToUInt64(_ x : Int32) -> UInt64 {
  227.       return UInt64(bitPattern: Int64(x))  // Extend sign bit, assume minus input significant
  228.    }
  229.    public static func ToUInt64(_ x : Int64) -> UInt64 {
  230.       return UInt64(bitPattern: x)
  231.    }
  232.    public static func ToUInt64(_ x : Int) -> UInt64 {
  233.       return UInt64(bitPattern: Int64(x))  // Extend sign bit if necessary, assume minus input significant
  234.    }
  235.    public static func ToUInt64(_ x : UInt8) -> UInt64 {
  236.       return UInt64(x)
  237.    }
  238.    public static func ToUInt64(_ x : UInt32) -> UInt64 {
  239.       return UInt64(x)
  240.    }
  241.    public static func ToUInt64(_ x : UInt64) -> UInt64 {
  242.       return x
  243.    }
  244.    public static func ToUInt64(_ x : UInt) -> UInt64 {
  245.       return UInt64(x)  // Does not extend high bit of 32-bit input
  246.    }
  247.  
  248.    // To UInt
  249.    public static func ToUInt(_ x : Int8) -> UInt {
  250.       return UInt(bitPattern: Int(x))  // Extend sign bit, assume minus input significant
  251.    }
  252.    public static func ToUInt(_ x : Int32) -> UInt {
  253.       return UInt(truncatingBitPattern: Int64(x))  // Extend sign bit, assume minus input significant
  254.    }
  255.    public static func ToUInt(_ x : Int64) -> UInt {
  256.       return UInt(truncatingBitPattern: x)
  257.    }
  258.    public static func ToUInt(_ x : Int) -> UInt {
  259.       return UInt(bitPattern: x)
  260.    }
  261.    public static func ToUInt(_ x : UInt8) -> UInt {
  262.       return UInt(x)
  263.    }
  264.    public static func ToUInt(_ x : UInt32) -> UInt {
  265.       return UInt(x)
  266.    }
  267.    public static func ToUInt(_ x : UInt64) -> UInt {
  268.       return UInt(truncatingBitPattern: x)
  269.    }
  270.    public static func ToUInt(_ x : UInt) -> UInt {
  271.       return x
  272.    }
  273. }
  274.    
  275. public func doTest() {
  276.  
  277.       // To Int8
  278.  
  279.       assert(JDI.ToInt8(42 as Int8) == 42)
  280.       assert(JDI.ToInt8(-13 as Int8) == -13)
  281.  
  282.       assert(JDI.ToInt8(42 as Int32) == 42)
  283.       assert(JDI.ToInt8(257 as Int32) == 1)
  284.  
  285.       assert(JDI.ToInt8(42 as Int64) == 42)
  286.       assert(JDI.ToInt8(257 as Int64) == 1)
  287.  
  288.       assert(JDI.ToInt8(42 as Int) == 42)
  289.       assert(JDI.ToInt8(257 as Int) == 1)
  290.  
  291.       assert(JDI.ToInt8(42 as UInt8) == 42)
  292.       assert(JDI.ToInt8(0xf3 as UInt8) == -13)
  293.  
  294.       assert(JDI.ToInt8(42 as UInt32) == 42)
  295.       assert(JDI.ToInt8(0xfffffff3 as UInt32) == -13)
  296.  
  297.       assert(JDI.ToInt8(42 as UInt64) == 42)
  298.       assert(JDI.ToInt8(UInt64.max - 12) == -13)
  299.  
  300.       assert(JDI.ToInt8(42 as UInt) == 42)
  301.       assert(JDI.ToInt8(UInt.max - 12) == -13)
  302.  
  303.       // To Int32
  304.  
  305.       assert(JDI.ToInt32(42 as Int8) == 42)
  306.       assert(JDI.ToInt32(-13 as Int8) == -13)
  307.  
  308.       assert(JDI.ToInt32(42 as Int32) == 42)
  309.       assert(JDI.ToInt32(-13 as Int32) == -13)
  310.  
  311.       assert(JDI.ToInt32(42 as Int64) == 42)
  312.       assert(JDI.ToInt32(Int64(Int32.min) - 1) == Int32.max)
  313.  
  314.       assert(JDI.ToInt32(42 as Int) == 42)
  315.       assert(JDI.ToInt32(-13 as Int) == -13)
  316.  
  317.       assert(JDI.ToInt32(42 as UInt8) == 42)
  318.       assert(JDI.ToInt32(0xf3 as UInt8) == 243)
  319.  
  320.       assert(JDI.ToInt32(42 as UInt32) == 42)
  321.       assert(JDI.ToInt32(0xfffffff3 as UInt32) == -13)
  322.  
  323.       assert(JDI.ToInt32(42 as UInt64) == 42)
  324.       assert(JDI.ToInt32(UInt64.max - 12) == -13)
  325.  
  326.       assert(JDI.ToInt32(42 as UInt) == 42)
  327.       assert(JDI.ToInt32(UInt.max - 12) == -13)
  328.  
  329.       // To Int64
  330.  
  331.       assert(JDI.ToInt64(42 as Int8) == 42)
  332.       assert(JDI.ToInt64(-13 as Int8) == -13)
  333.  
  334.       assert(JDI.ToInt64(42 as Int32) == 42)
  335.       assert(JDI.ToInt64(-13 as Int32) == -13)
  336.  
  337.       assert(JDI.ToInt64(42 as Int64) == 42)
  338.       assert(JDI.ToInt64(-13 as Int64) == -13)
  339.  
  340.       assert(JDI.ToInt64(42 as Int) == 42)
  341.       assert(JDI.ToInt64(-13 as Int) == -13)
  342.  
  343.       assert(JDI.ToInt64(42 as UInt8) == 42)
  344.       assert(JDI.ToInt64(0xf3 as UInt8) == 243)
  345.  
  346.       assert(JDI.ToInt64(42 as UInt32) == 42)
  347.       assert(JDI.ToInt64(0xfffffff3 as UInt32) == 4294967283)
  348.  
  349.       assert(JDI.ToInt64(42 as UInt64) == 42)
  350.       assert(JDI.ToInt64(UInt64.max - 12) == -13)
  351.  
  352.       assert(JDI.ToInt64(42 as UInt) == 42)
  353.       #if (arch(i386) || arch(arm))
  354.          assert(JDI.ToInt64(UInt.max - 12) == 4294967283)  // For 32-bit systems
  355.       #else
  356.          assert(JDI.ToInt64(UInt.max - 12) == -13)  // For 64-bit systems
  357.       #endif
  358.  
  359.       // To Int
  360.  
  361.       assert(JDI.ToInt(42 as Int8) == 42)
  362.       assert(JDI.ToInt(-13 as Int8) == -13)
  363.  
  364.       assert(JDI.ToInt(42 as Int32) == 42)
  365.       assert(JDI.ToInt(-13 as Int32) == -13)
  366.  
  367.       assert(JDI.ToInt(42 as Int64) == 42)
  368.       assert(JDI.ToInt(-13 as Int64) == -13)
  369.  
  370.       assert(JDI.ToInt(42 as Int) == 42)
  371.       assert(JDI.ToInt(-13 as Int) == -13)
  372.  
  373.       assert(JDI.ToInt(42 as UInt8) == 42)
  374.       assert(JDI.ToInt(0xf3 as UInt8) == 243)
  375.  
  376.       assert(JDI.ToInt(42 as UInt32) == 42)
  377.       #if (arch(i386) || arch(arm))
  378.          assert(JDI.ToInt(0xfffffff3 as UInt32) == -13)  // For 32-bit systems
  379.       #else
  380.          assert(JDI.ToInt(0xfffffff3 as UInt32) == 4294967283)  // For 64-bit systems
  381.       #endif
  382.  
  383.       assert(JDI.ToInt(42 as UInt64) == 42)
  384.       assert(JDI.ToInt(UInt64.max - 12) == -13)
  385.  
  386.       assert(JDI.ToInt(42 as UInt) == 42)
  387.       assert(JDI.ToInt(UInt.max - 12) == -13)
  388.  
  389.       // To UInt8
  390.  
  391.       assert(JDI.ToUInt8(42 as Int8) == 42)
  392.       assert(JDI.ToUInt8(-13 as Int8) == 0xf3)
  393.  
  394.       assert(JDI.ToUInt8(42 as Int32) == 42)
  395.       assert(JDI.ToUInt8(-13 as Int32) == 0xf3)
  396.  
  397.       assert(JDI.ToUInt8(42 as Int64) == 42)
  398.       assert(JDI.ToUInt8(-13 as Int64) == 0xf3)
  399.       assert(JDI.ToUInt8(Int64.max - 12) == 0xf3)
  400.  
  401.       assert(JDI.ToUInt8(42 as Int) == 42)
  402.       assert(JDI.ToUInt8(-13 as Int) == 0xf3)
  403.       assert(JDI.ToUInt8(Int.max - 12) == 0xf3)
  404.  
  405.       assert(JDI.ToUInt8(42 as UInt8) == 42)
  406.       assert(JDI.ToUInt8(0xf3 as UInt8) == 0xf3)
  407.  
  408.       assert(JDI.ToUInt8(42 as UInt32) == 42)
  409.       assert(JDI.ToUInt8(0xfffffff3 as UInt32) == 0xf3)
  410.  
  411.       assert(JDI.ToUInt8(42 as UInt64) == 42)
  412.       assert(JDI.ToUInt8(UInt64.max - 12) == 0xf3)
  413.  
  414.       assert(JDI.ToUInt8(42 as UInt) == 42)
  415.       assert(JDI.ToUInt8(UInt.max - 12) == 0xf3)
  416.  
  417.       // To UInt32
  418.  
  419.       assert(JDI.ToUInt32(42 as Int8) == 42)
  420.       assert(JDI.ToUInt32(-13 as Int8) == 0xfffffff3)
  421.  
  422.       assert(JDI.ToUInt32(42 as Int32) == 42)
  423.       assert(JDI.ToUInt32(-13 as Int32) == 0xfffffff3)
  424.  
  425.       assert(JDI.ToUInt32(42 as Int64) == 42)
  426.       assert(JDI.ToUInt32(-13 as Int64) == 0xfffffff3)
  427.       assert(JDI.ToUInt32(Int64.max - 12) == 0xfffffff3)
  428.  
  429.       assert(JDI.ToUInt32(42 as Int) == 42)
  430.       assert(JDI.ToUInt32(-13 as Int) == 0xfffffff3)
  431.       #if (arch(i386) || arch(arm))
  432.          assert(JDI.ToUInt32(Int.max - 12) == 0x7ffffff3)  // For 32-bit systems
  433.       #else
  434.          assert(JDI.ToUInt32(Int.max - 12) == 0xfffffff3)  // For 64-bit systems
  435.       #endif
  436.  
  437.       assert(JDI.ToUInt32(42 as UInt8) == 42)
  438.       assert(JDI.ToUInt32(0xf3 as UInt8) == 0xf3)
  439.  
  440.       assert(JDI.ToUInt32(42 as UInt32) == 42)
  441.       assert(JDI.ToUInt32(0xfffffff3 as UInt32) == 0xfffffff3)
  442.  
  443.       assert(JDI.ToUInt32(42 as UInt64) == 42)
  444.       assert(JDI.ToUInt32(UInt64.max - 12) == 0xfffffff3)
  445.  
  446.       assert(JDI.ToUInt32(42 as UInt) == 42)
  447.       assert(JDI.ToUInt32(UInt.max - 12) == 0xfffffff3)
  448.  
  449.       // To UInt64
  450.  
  451.       assert(JDI.ToUInt64(42 as Int8) == 42)
  452.       assert(JDI.ToUInt64(-13 as Int8) == 0xfffffffffffffff3)
  453.  
  454.       assert(JDI.ToUInt64(42 as Int32) == 42)
  455.       assert(JDI.ToUInt64(-13 as Int32) == 0xfffffffffffffff3)
  456.  
  457.       assert(JDI.ToUInt64(42 as Int64) == 42)
  458.       assert(JDI.ToUInt64(-13 as Int64) == 0xfffffffffffffff3)
  459.       assert(JDI.ToUInt64(Int64.max - 12) == (UInt64.max >> 1) - 12)
  460.  
  461.       assert(JDI.ToUInt64(42 as Int) == 42)
  462.       assert(JDI.ToUInt64(-13 as Int) == 0xfffffffffffffff3)
  463.       #if (arch(i386) || arch(arm))
  464.          assert(JDI.ToUInt64(Int.max - 12) == 0x7ffffff3)  // For 32-bit systems
  465.       #else
  466.          assert(JDI.ToUInt64(Int.max - 12) == 0x7ffffffffffffff3)  // For 64-bit systems
  467.       #endif
  468.  
  469.       assert(JDI.ToUInt64(42 as UInt8) == 42)
  470.       assert(JDI.ToUInt64(0xf3 as UInt8) == 0xf3)
  471.  
  472.       assert(JDI.ToUInt64(42 as UInt32) == 42)
  473.       assert(JDI.ToUInt64(0xfffffff3 as UInt32) == 0xfffffff3)
  474.  
  475.       assert(JDI.ToUInt64(42 as UInt64) == 42)
  476.       assert(JDI.ToUInt64(UInt64.max - 12) == 0xfffffffffffffff3)
  477.  
  478.       assert(JDI.ToUInt64(42 as UInt) == 42)
  479.       #if (arch(i386) || arch(arm))
  480.          assert(JDI.ToUInt64(UInt.max - 12) == 0xfffffff3)  // For 32-bit systems
  481.       #else
  482.          assert(JDI.ToUInt64(UInt.max - 12) == 0xfffffffffffffff3)  // For 64-bit systems
  483.       #endif
  484.  
  485.       // To UInt
  486.  
  487.       assert(JDI.ToUInt(42 as Int8) == 42)
  488.       #if (arch(i386) || arch(arm))
  489.          assert(JDI.ToUInt(-13 as Int8) == 0xfffffff3)  // For 32-bit systems
  490.       #else
  491.          assert(JDI.ToUInt(-13 as Int8) == 0xfffffffffffffff3)  // For 64-bit systems
  492.       #endif
  493.  
  494.       assert(JDI.ToUInt(42 as Int32) == 42)
  495.       #if (arch(i386) || arch(arm))
  496.          assert(JDI.ToUInt(-13 as Int32) == 0xfffffff3)  // For 32-bit systems
  497.       #else
  498.          assert(JDI.ToUInt(-13 as Int32) == 0xfffffffffffffff3)  // For 64-bit systems
  499.       #endif
  500.  
  501.       assert(JDI.ToUInt(42 as Int64) == 42)
  502.       #if (arch(i386) || arch(arm))
  503.          assert(JDI.ToUInt(-13 as Int64) == 0xfffffff3)  // For 32-bit systems
  504.          assert(JDI.ToUInt(Int64.max - 12) == 0xfffffff3)
  505.       #else
  506.          assert(JDI.ToUInt(-13 as Int64) == 0xfffffffffffffff3)  // For 64-bit systems
  507.          assert(JDI.ToUInt(Int64.max - 12) == 0x7ffffffffffffff3)
  508.       #endif
  509.  
  510.       assert(JDI.ToUInt(42 as Int) == 42)
  511.       #if (arch(i386) || arch(arm))
  512.          assert(JDI.ToUInt(Int.max - 12) == 0x7ffffff3)  // For 32-bit systems
  513.       #else
  514.          assert(JDI.ToUInt(Int.max - 12) == 0x7ffffffffffffff3)  // For 64-bit systems
  515.       #endif
  516.  
  517.       assert(JDI.ToUInt(42 as UInt8) == 42)
  518.       assert(JDI.ToUInt(0xf3 as UInt8) == 0xf3)
  519.  
  520.       assert(JDI.ToUInt(42 as UInt32) == 42)
  521.       assert(JDI.ToUInt(0xfffffff3 as UInt32) == 0xfffffff3)
  522.  
  523.       assert(JDI.ToUInt(42 as UInt64) == 42)
  524.       #if (arch(i386) || arch(arm))
  525.          assert(JDI.ToUInt(UInt64.max - 12) == 0xfffffff3)  // For 32-bit systems
  526.       #else
  527.          assert(JDI.ToUInt(UInt64.max - 12) == 0xfffffffffffffff3)  // For 64-bit systems
  528.       #endif
  529.  
  530.       assert(JDI.ToUInt(42 as UInt) == 42)
  531.       #if (arch(i386) || arch(arm))
  532.          assert(JDI.ToUInt(UInt.max - 12) == 0xfffffff3)  // For 32-bit systems
  533.       #else
  534.          assert(JDI.ToUInt(UInt.max - 12) == 0xfffffffffffffff3)  // For 64-bit systems
  535.       #endif
  536.  
  537.       print("nTesting JDI complete.n")
  538.    }
RAW Paste Data
Top