Skip to main content

Configurable test case generator for competitive programming.

Project description

📚 About

Jen is a configurable test case generator for competitive programming. The format of the test cases is specified in a TOML configuration file.

🔌 Installation

Python version >=3.11 is required to install the python library. Install with:

pip install cp-jen

This will create a jen script in your python bin folder. To call this script from anyware, ensure the python bin folder is in your PATH.

💼 Usage

Calling jen with a configuration file creates a test case and saves it in the current directory.

jen config.toml

To stress test your program, run jen with two additional arguments:

jen config.toml ./tst ./ref

Jen will continuously generate test cases and pipe them to the test and reference program's standard input. The outputs from both programs are compared until a test case that generates different outputs is found.

⚙️ Configuration

The configuration is a TOML file. Examples of input configurations for past problems are in the examples folder.

Example Configuration

As an example, we look at test cases for Atcoder contest ABC346, problem D.

in = """
N
S
{C}"""

[N]
type = 'int'
min = 2
max = 20

[S]
type = 'str'
allowed = ['0','1']
min = 'N'
max = 'N'

[C]
type = 'int'
min = 1
max = 1000000000

[1]
delimiter = ' '
count = 'N' 

Each test case will have an integer N, followed by a string of zeros and ones of size N, and finally N integers between 1 and 1,000,000,000 separated by spaces.

jen.toml Specifications

A variable called "in" is required. It is a string defining the input variables.

in rules:

  • Any latin script letter is considered a variable (case sensitive).
  • braces {} define a group. Groups are repeating sections of input.
  • The first group is called '1'. The second group is '2', ... etc.
  • group [1.1] is the first group within group 1.
  • Any other character is kept as-is when generating inputs.

Each variable has a type. The type of a variable can be inferred from its name or set explicitly in the variable configurations. Each type has allowed properties and default values for those properties, listed below.

Types

  • int:

    • default names: (a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,u,v,w)
    • min: 0
    • max: 1000
  • string:

    • default names: (s,t)
    • min: 0
    • max: 1000
  • float:

    • default names: (x,y,z)
    • min: 0.0
    • max: 1000.0
  • group:

    • count: 'n'
    • delimiter: " "

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cp_jen-2024.0.0.tar.gz (4.8 kB view details)

Uploaded Source

Built Distribution

cp_jen-2024.0.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file cp_jen-2024.0.0.tar.gz.

File metadata

  • Download URL: cp_jen-2024.0.0.tar.gz
  • Upload date:
  • Size: 4.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for cp_jen-2024.0.0.tar.gz
Algorithm Hash digest
SHA256 e14c852de4f54776466cad060d179668899b2f104916e8f128071014af552b79
MD5 a2358df85936f5145f5fdb2cabc4a231
BLAKE2b-256 1cc690f640bc604c4fa7d4e450321a035cfc565f7689a4973323f6b07fb8bcb1

See more details on using hashes here.

File details

Details for the file cp_jen-2024.0.0-py3-none-any.whl.

File metadata

  • Download URL: cp_jen-2024.0.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.31.0

File hashes

Hashes for cp_jen-2024.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 44fbc073a41c2bb223e84f6c208b4036d078e095bb97237b0cc0e9625ce3d93e
MD5 b8020e9be80991a662e29aa8ea09ad37
BLAKE2b-256 41295fb1c51f0c9a33ee2fc4ea5ea8b888b32b0770c60f65b185999585f248c1

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page