diff options
author | Marc Coquand <marc@mccd.space> | 2023-12-26 09:34:58 -0600 |
---|---|---|
committer | Marc Coquand <marc@mccd.space> | 2023-12-26 09:57:20 -0600 |
commit | 742c23d7c5d90b681dcbce92846d57042d2ea467 (patch) | |
tree | b6cf10333e15bc7b748744f7c7af805ca77f222c /lib/fixture.ml | |
parent | 8ac0e27adc8d14a77427351dede1757999c8c709 (diff) | |
download | fixgen-742c23d7c5d90b681dcbce92846d57042d2ea467.tar.gz fixgen-742c23d7c5d90b681dcbce92846d57042d2ea467.tar.bz2 fixgen-742c23d7c5d90b681dcbce92846d57042d2ea467.zip |
Add support for ints
Diffstat (limited to 'lib/fixture.ml')
-rw-r--r-- | lib/fixture.ml | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/fixture.ml b/lib/fixture.ml index 189d2fb..8806692 100644 --- a/lib/fixture.ml +++ b/lib/fixture.ml @@ -22,12 +22,13 @@ let names = let random_name () = List.nth names (Random.int (List.length names)) let%test "random_name" = List.mem (random_name ()) names -(* Support arbitrary amount *) -(* Support names *) +(* TODO: Support arbitrary amount *) +(* TODO: Support names *) type t = | Name of string | Uuidv4 of string | Foreign of (string * string list) + | Int of string * int * int (* (Name, foreign ids to pick from) *) let add_name name fixtures = Name name :: fixtures @@ -46,6 +47,7 @@ let generate_fixture fixture = | Name _ -> random_name () | Uuidv4 _ -> Uuidm.v `V4 |> Uuidm.to_string | Foreign (_, reference) -> random_value_in_list reference + | Int (_, min, max) -> Random.int (max - min) + min |> string_of_int let%test "generate_uuid" = @@ -57,6 +59,7 @@ let id_of_fixture fixture = | Name id -> id | Uuidv4 id -> id | Foreign (id, _) -> id + | Int (id, _, _) -> id let rec replicate element n = |