{"id":16645965,"url":"https://github.com/ninjaclasher/testcase-generator","last_synced_at":"2025-10-07T05:27:31.643Z","repository":{"id":57474411,"uuid":"181363405","full_name":"Ninjaclasher/testcase-generator","owner":"Ninjaclasher","description":"A testcase generator for easily creating testcases for online judges.","archived":false,"fork":false,"pushed_at":"2020-03-16T16:28:44.000Z","size":73,"stargazers_count":13,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-27T08:41:59.867Z","etag":null,"topics":["online-judges","testcase-generator"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Ninjaclasher.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2019-04-14T20:11:39.000Z","updated_at":"2023-08-07T03:08:16.000Z","dependencies_parsed_at":"2022-09-10T02:20:44.950Z","dependency_job_id":null,"html_url":"https://github.com/Ninjaclasher/testcase-generator","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/Ninjaclasher/testcase-generator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ninjaclasher%2Ftestcase-generator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ninjaclasher%2Ftestcase-generator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ninjaclasher%2Ftestcase-generator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ninjaclasher%2Ftestcase-generator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Ninjaclasher","download_url":"https://codeload.github.com/Ninjaclasher/testcase-generator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Ninjaclasher%2Ftestcase-generator/sbom","scorecard":{"id":101842,"data":{"date":"2025-08-11","repo":{"name":"github.com/Ninjaclasher/testcase-generator","commit":"4176c7ba5551a75606cf3ce3fb1225ebf4cc7906"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.2,"checks":[{"name":"Code-Review","score":0,"reason":"Found 0/30 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/flake8.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/flake8.yml:7: update your workflow using https://app.stepsecurity.io/secureworkflow/Ninjaclasher/testcase-generator/flake8.yml/master?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/flake8.yml:9: update your workflow using https://app.stepsecurity.io/secureworkflow/Ninjaclasher/testcase-generator/flake8.yml/master?enable=pin","Warn: pipCommand not pinned by hash: .github/workflows/flake8.yml:14","Info:   0 out of   2 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   1 pipCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: GNU Affero General Public License v3.0: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"Vulnerabilities","score":8,"reason":"2 existing vulnerabilities detected","details":["Warn: Project is vulnerable to: PYSEC-2021-142 / GHSA-8q59-q68h-6hv4","Warn: Project is vulnerable to: PYSEC-2018-49 / GHSA-rprw-h62v-c2w7"],"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}}]},"last_synced_at":"2025-08-15T10:18:25.192Z","repository_id":57474411,"created_at":"2025-08-15T10:18:25.192Z","updated_at":"2025-08-15T10:18:25.192Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":278722993,"owners_count":26034498,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-07T02:00:06.786Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["online-judges","testcase-generator"],"created_at":"2024-10-12T08:26:00.466Z","updated_at":"2025-10-07T05:27:31.592Z","avatar_url":"https://github.com/Ninjaclasher.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Testcase Generator\n\nA testcase generator for easily creating testcases for online judges.\n\n## Installation\n```\n$ pip install testcase-generator\n```\n\nAlternatively, just clone this repository!\n\n## Usage\n```python\nimport random\n\nfrom testcase_generator import BoundedConstraint, Case, Batch, Generator, ConstraintParser\n\ndef set_constraints(self):\n    ## Write main constraints here ##\n    # Sets the constraint of N to be between 1 and 10^3 inclusive.\n    self.N = BoundedConstraint(1, 10**3)\n    # Sets the constraint of M to be a floating-point value between 1 and 10 inclusive.\n    self.M = BoundedConstraint(1, 10, generator=random.uniform)\n\ndef generate_input(self, **kwargs):\n    ## Write generator here ##\n    # Generates a value for N and M on the same line\n    yield self.N.next, self.M.next\n\n\nCase.SET_CONSTRAINTS = set_constraints\nCase.SET_INPUT = generate_input\n\n\n# Using the yaml config to create the batches:\nconfig_yaml = \"\"\"\n- batch: 1 # initializes a batch where cases go inside a directory called \"batch1\".\n  constraints: {N: 1~10**2} # sets the batch constraints.\n  cases: # individual cases for this batch.\n   - {N: MIN} # sets N to be the minimum value in this batch (N = 1).\n   - {N: MAX} # sets N to be the maximum value in this batch (N = 10**2).\n   - {N: 2~2**3} # sets N to be some random value between 2 and 2**3, inclusive.\n   - {N: MAX-1~} # sets N to be some random value between the global maximum minus 1 and the global maximum of 10**2.\n- batch: 2\n  constraints: {} # no batch constraints, so all the constraints are the global constraints.\n  cases:\n   - {}\n   - {N: ~2, M: 1}\n\"\"\"\n\np = ConstraintParser(data=config_yaml)\np.parse()\nbatches = p.batches\n\n\n# alternatively, you can create the batches manually\nbatches = [\n    Batch(num=1, cases=[Case() for i in range(4)]),\n    Batch(num=2, cases=[Case(N=BoundedConstraint(1, 10)) for i in range(2)]),\n]\n\n\nGenerator(batches=batches, exe='COMMAND_TO_GENERATE_OUTPUT').start()\n```\n\n## Custom Generators\n### GraphGenerator\nThis generator can be used to generate a variety of graph types, such as trees.\n\nExample code:\n```python\nfrom testcase_generator import BoundedConstraint, CustomGeneratorConstraint, Case, Batch, Generator, ConstraintParser, GraphGenerator\n\n\"\"\"\n |  __init__(self, N, type, *args, **kwargs)\n |      N: a BoundedConstraint object or an integer for the number of nodes\n |      type:\n |               1: normal graph\n |               2: connected graph\n |               3: complete graph\n |               4: circle\n |               10: line\n |               11: normal tree\n |               12: tree, all nodes connected to one node\n |               13: caterpillar tree\n |               14: binary tree\n |      kwargs:\n |          M: number of edges, leave blank if it is a tree\n |          duplicates: allow for duplicate edges between nodes\n |          self_loops: allow for edges between the same node\n\"\"\"\n\ndef set_constraints(self):\n    ## Write main constraints here ##\n    # Sets the constraint of N to be between 1 and 10^3 inclusive.\n    # In this case, this is a graph with N nodes.\n    self.N = BoundedConstraint(1, 10**3)\n    # Creates the graph constraint.\n    self.E = CustomGeneratorConstraint(generator=GraphGenerator)\n    # Sets the graph type to be some graph type between 10 and 14.\n    # Please read the initialize method doc for details.\n    # In this case, the graph type is some form of a tree.\n    self.graph_type = BoundedConstraint(10, 14)\n\ndef generate_input(self, **kwargs):\n    ## Write generator here ##\n    n = self.N.next\n    yield n\n    self.E.initialize(n, self.graph_type.next)\n    for i in range(n-1):\n        yield self.E.next\n\n\nCase.SET_CONSTRAINTS = set_constraints\nCase.SET_INPUT = generate_input\n\n\n# Using the yaml config to create the batches:\nconfig_yaml = \"\"\"\n- batch: 1\n  constraints: {N: 1~10**3-1}\n  cases:\n   - constraints: {}\n     repeat: 6\n   - constraints: {graph_type: 11}\n\"\"\"\n\np = ConstraintParser(data=config_yaml)\np.parse()\nbatches = p.batches\n\n# If you don't want to generate output, exclude the \"exe\" argument\nGenerator(batches=batches).start()\n```\n\n### StringGenerator\n\n```python\n\"\"\"\n |  __init__(self, N, *args, **kwargs)\n |      N: a BoundedConstraint object or an integer for the string length\n |      kwargs:\n |          type: type of string to generate\n |                  standard: default string\n |                  palindrome: palindromic string\n |                  space_separated: space separated \"words\"\n |                  repeating: string consisting of a substring that is repeated more than 1 time\n |          V: a ChoiceConstraint for the possible letters, the default is all lowercase letters\n\"\"\"\n```\n\n### ArrayGenerator\n\n```python\n\"\"\"\n |  __init__(self, N, *args, **kwargs)\n |      N: a BoundedConstraint object or an integer for the array size\n |      kwargs:\n |          type: type of array to generate\n |                  standard: default array\n |                  sorted: sorted default array\n |                  distinct: distinct elements in the array. set V appropriately for a permutation\n |                  palindrome: palindromic array\n |          V: a ChoiceConstraint or BoundedConstraint object for the array values\n |          additional arguments for the generator:\n |                  distinct: takes a value of \"k\" for number of times each element can occur (default is 1)\n\"\"\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fninjaclasher%2Ftestcase-generator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fninjaclasher%2Ftestcase-generator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fninjaclasher%2Ftestcase-generator/lists"}