]> git.draconx.ca Git - cdecl99.git/blobdiff - t/declgen.c
tests: Eliminate random floating-point generation.
[cdecl99.git] / t / declgen.c
index 0e76348c84c352acbf280bd206d3e4e1bbf6136d..459a68e077ae19958ef5d8ce2d2651e75df22b67 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *  Generate random C declarations for testing.
- *  Copyright © 2012, 2021-2022 Nick Bowler
+ *  Copyright © 2012, 2021-2023 Nick Bowler
  *
  *  This program is free software: you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License as published by
@@ -105,7 +105,7 @@ struct cdecl_declspec *gen_qualifiers(struct test_rng *rng, bool restrictqual)
 {
        struct cdecl_declspec *s = NULL;
 
-       while (test_rng_uniform(rng) < 0.5) {
+       while (test_rng_50_50(rng)) {
                s = new_specifier(s);
 
                switch (test_rng_uniform_int(rng, 2+restrictqual)) {
@@ -134,7 +134,7 @@ struct cdecl_declspec *gen_funcspecs(struct test_rng *rng)
 {
        struct cdecl_declspec *s = NULL;
 
-       while (test_rng_uniform(rng) < 0.5) {
+       while (test_rng_50_50(rng)) {
                s = new_specifier(s);
                s->type = CDECL_FUNC_INLINE;
        }
@@ -151,7 +151,7 @@ struct cdecl_declspec *gen_storspecs(struct test_rng *rng, bool registeronly)
 {
        struct cdecl_declspec *s;
 
-       if (test_rng_uniform(rng) < 0.5)
+       if (test_rng_50_50(rng))
                return NULL;
 
        s = new_specifier(NULL);
@@ -334,7 +334,7 @@ static void gen_function(struct test_rng *rng, struct cdecl_declarator *d)
        d->type = CDECL_DECL_FUNCTION;
        d->u.function.parameters = NULL;
 
-       while (test_rng_uniform(rng) < 0.5) {
+       while (test_rng_50_50(rng)) {
                unsigned flags = GEN_ONLY_REGISTER | GEN_NO_FUNCTION;
                struct cdecl *param;
 
@@ -350,8 +350,8 @@ static void gen_function(struct test_rng *rng, struct cdecl_declarator *d)
        }
 
        if (d->u.function.parameters) {
-               d->u.function.variadic = test_rng_uniform(rng) < 0.5;
-       } else if (test_rng_uniform(rng) < 0.5) {
+               d->u.function.variadic = test_rng_50_50(rng);
+       } else if (test_rng_50_50(rng)) {
                struct cdecl *param;
 
                /* We will never generate (void) above; do it here. */
@@ -375,12 +375,12 @@ struct cdecl_declarator *gen_declarators(struct test_rng *rng)
        unsigned limit = 3;
 
        d = new_declarator(NULL);
-       if (test_rng_uniform(rng) < 0.5) {
+       if (test_rng_50_50(rng)) {
                d->type = CDECL_DECL_IDENT;
                d->u.ident = gen_identifier(rng);
        }
 
-       while (test_rng_uniform(rng) < 0.5) {
+       while (test_rng_50_50(rng)) {
                d = new_declarator((p = d));
 
                switch (test_rng_uniform_int(rng, limit)) {