/*----
  signature: main: void -> int
  purpose: testing program for the function rand_int

  by: Sharon Tuttle
  last modified: 2022-02-04
----*/

#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include "rand_int.h"    
using namespace std;

int main()
{
    cout << boolalpha;

    cout << "*** Testing rand_int ***" << endl;

    bool any_failed = false;
    int looky;
    
    for (int i=0; i < 1000; i++)
    {
        looky = rand_int(1, 10);
	
        if (not (1 <= looky) && (looky <= 10))
	{
	    any_failed = true;
	}
    }

    cout << (any_failed == false) << endl;

    int val;
    any_failed = false;

    for (int i=0; i < 1000; i++)
    {
        val = rand_int(-5, 3);
	
        if (not (-5 <= val) && (val <= 3))
	{
	    any_failed = true;
	}
    }

    cout << (any_failed == false) << endl;

    cout << "\nBut do they vary on different runs?" << endl;

    cout << "\nShould be in [1, 10]:" << endl;
    
    for (int i = 0; i < 10; i++)
    {
        cout << rand_int(1, 10) << endl;
    }

    cout << "\nShould be in [-5, 3]:" << endl;
    
    for (int i = 0; i < 10; i++)
    {
        cout << rand_int(-5, 3) << endl;
    }

    return EXIT_SUCCESS;
}