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
| Feature | Description |
|---|---|
make | Time-based seed (non-reproducible) |
make_with_seed (seed) | Fixed seed for reproducible sequences |
Random Numbers
| Feature | Description |
|---|---|
random_integer | Random integer |
random_integer_in_range (range) | Integer within INTEGER_INTERVAL |
random_real | Real between 0 and 1 |
random_real_in_range (lower, upper) | Real within bounds |
random_boolean | 50/50 true/false |
random_boolean_weighted (percent) | Weighted probability |
unique_integers (count, range) | Array of unique integers |
Random Characters
| Feature | Description |
|---|---|
random_digit | '0'..'9' |
random_letter_lower | 'a'..'z' |
random_letter_upper | 'A'..'Z' |
random_letter | Any case letter |
random_alphanumeric | Letter or digit |
random_character_from (string) | Character from source |
Random Strings
| Feature | Description |
|---|---|
random_digits (length) | String of digits |
random_letters (length) | String of lowercase letters |
random_alphanumeric_string (length) | Mixed string |
random_word | Pronounceable word (2-3 syllables) |
random_word_capitalized | Capitalized word |
random_words (count) | Space-separated words |
random_sentence | Capitalized with period |
random_paragraph | Multiple sentences |
random_identifier | Code-safe identifier |
Random Dates
| Feature | Description |
|---|---|
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
| Feature | Description |
|---|---|
random_uuid | UUID object |
random_uuid_string | Hyphenated format (36 chars) |
random_uuid_compact | No hyphens (32 chars) |
Selection
| Feature | Description |
|---|---|
random_item_from_array (array) | Random array element |
random_string_from_list (list) | Random string from array |