simple_randomizer

Lightweight Random Data Generation for Eiffel Testing

Foundation Layer v1.0.0 MIT

Overview

simple_randomizer provides core randomization features for generating test data without domain-specific baggage or file dependencies. It's a lean replacement for heavier randomizer libraries.

Part of the simple_* ecosystem of focused, single-purpose Eiffel libraries.

Quick Start

Installation

<library name="simple_randomizer" location="$SIMPLE_RANDOMIZER\simple_randomizer.ecf"/>

Basic Usage

local
    randomizer: SIMPLE_RANDOMIZER
    name: STRING
    age: INTEGER
    hire_date: DATE
do
    -- Time-based seed (non-reproducible)
    create randomizer.make

    -- Or fixed seed for reproducible tests
    -- create randomizer.make_with_seed (12345)

    name := randomizer.random_word_capitalized
    age := randomizer.random_integer_in_range (18 |..| 65)
    hire_date := randomizer.random_date_in_past_days (365)
end

Pronounceable Words

-- Generate readable random words
randomizer.random_word           -- "teko", "vami", "belu"
randomizer.random_word_capitalized -- "Teko", "Vami"
randomizer.random_sentence       -- "Mebo tiva kelu rano."
randomizer.random_paragraph      -- Multiple sentences

Features

Random Numbers

Integers, reals, booleans with range support

Random Strings

Words, sentences, paragraphs, identifiers

Random Dates

Past, future, ranges, around now

UUID Generation

Full UUID, string, and compact formats

Reproducible

Seed-based deterministic randomness for tests

Design by Contract

Full preconditions and postconditions

API Reference

Creation

FeatureDescription
makeTime-based seed (non-reproducible)
make_with_seed (seed)Fixed seed for reproducible sequences

Random Numbers

FeatureDescription
random_integerRandom integer
random_integer_in_range (range)Integer within INTEGER_INTERVAL
random_realReal between 0 and 1
random_real_in_range (lower, upper)Real within bounds
random_boolean50/50 true/false
random_boolean_weighted (percent)Weighted probability
unique_integers (count, range)Array of unique integers

Random Characters

FeatureDescription
random_digit'0'..'9'
random_letter_lower'a'..'z'
random_letter_upper'A'..'Z'
random_letterAny case letter
random_alphanumericLetter or digit
random_character_from (string)Character from source

Random Strings

FeatureDescription
random_digits (length)String of digits
random_letters (length)String of lowercase letters
random_alphanumeric_string (length)Mixed string
random_wordPronounceable word (2-3 syllables)
random_word_capitalizedCapitalized word
random_words (count)Space-separated words
random_sentenceCapitalized with period
random_paragraphMultiple sentences
random_identifierCode-safe identifier

Random Dates

FeatureDescription
random_date_in_past_days (days)Date within N days ago
random_date_in_future_days (days)Date within N days ahead
random_date_in_range (start, end)Date between bounds
random_date_around_now (days)Date +/- N days from today

UUID Generation

FeatureDescription
random_uuidUUID object
random_uuid_stringHyphenated format (36 chars)
random_uuid_compactNo hyphens (32 chars)

Selection

FeatureDescription
random_item_from_array (array)Random array element
random_string_from_list (list)Random string from array