tests
This commit is contained in:
parent
f3eecaef78
commit
0dd7d295a1
2 changed files with 18 additions and 2 deletions
|
@ -62,6 +62,8 @@ module Bits =
|
|||
x * (base_ ** (up - down)) |> kst
|
||||
|
||||
module Bytes =
|
||||
[<CustomEquality>]
|
||||
[<CustomComparison>]
|
||||
type Byte =
|
||||
| Byte of double
|
||||
| KB of double
|
||||
|
@ -75,6 +77,11 @@ module Bytes =
|
|||
| GiB of double
|
||||
| TiB of double
|
||||
| PiB of double
|
||||
with
|
||||
override a.Equals b =
|
||||
match b with
|
||||
| :? Byte as b -> b.bytes = a.bytes
|
||||
| _ -> false
|
||||
|
||||
member this.bytes =
|
||||
match this with
|
||||
|
@ -91,6 +98,15 @@ module Bytes =
|
|||
| Byte.TiB i -> i * 1024.0 * 1024.0 * 1024.0 * 1024.0
|
||||
| Byte.PiB i -> i * 1024.0 * 1024.0 * 1024.0 * 1024.0 * 1024.0
|
||||
|
||||
interface System.IComparable with
|
||||
member a.CompareTo b =
|
||||
match b with
|
||||
| :? Byte as b -> a.bytes.CompareTo b.bytes
|
||||
| _ -> -1
|
||||
override this.GetHashCode () = this.bytes.GetHashCode()
|
||||
|
||||
|
||||
|
||||
type System.Double with
|
||||
member this.byte = Byte.Byte this
|
||||
member this.KB = KB this
|
||||
|
|
|
@ -6,6 +6,6 @@ open Pentole.TestsExtensions
|
|||
open Pentole.BinaryPrefix
|
||||
|
||||
[<Test>]
|
||||
let split_test () =
|
||||
let equality_test () =
|
||||
Assert.are_equal (Bytes.KB 1) (Bytes.Byte 1000)
|
||||
Assert.are_equal (Bytes.KiB 1) (Bytes.Byte 1024)
|
||||
|
|
Loading…
Reference in a new issue