{"id":15033231,"url":"https://github.com/mikemirzayanov/testlib","last_synced_at":"2025-05-15T07:06:57.617Z","repository":{"id":33152458,"uuid":"36792683","full_name":"MikeMirzayanov/testlib","owner":"MikeMirzayanov","description":"C++ library to develop competitive programming problems","archived":false,"fork":false,"pushed_at":"2024-09-25T14:57:13.000Z","size":57481,"stargazers_count":1535,"open_issues_count":22,"forks_count":482,"subscribers_count":36,"default_branch":"master","last_synced_at":"2025-05-15T07:06:52.007Z","etag":null,"topics":["codeforces","contests","icpc","ioi","polygon"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MikeMirzayanov.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-06-03T09:10:12.000Z","updated_at":"2025-05-15T02:04:28.000Z","dependencies_parsed_at":"2024-07-31T21:29:36.857Z","dependency_job_id":"f17f9506-0100-4998-b580-2306c09cf871","html_url":"https://github.com/MikeMirzayanov/testlib","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeMirzayanov%2Ftestlib","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeMirzayanov%2Ftestlib/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeMirzayanov%2Ftestlib/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MikeMirzayanov%2Ftestlib/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MikeMirzayanov","download_url":"https://codeload.github.com/MikeMirzayanov/testlib/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254292042,"owners_count":22046426,"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","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":["codeforces","contests","icpc","ioi","polygon"],"created_at":"2024-09-24T20:20:27.027Z","updated_at":"2025-05-15T07:06:52.589Z","avatar_url":"https://github.com/MikeMirzayanov.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Testlib\n\n## Intro\n\nThis project contains a C++ implementation of testlib. It is already being used in many programming contests in Russia, such as the Russian National Olympiad in Informatics and different stages of ICPC. Join!\n\nThe library's C++ code is tested for compatibility with standard C++11 and higher on different versions of `g++`, `clang++`, and Microsoft Visual C++.\n\nThis code has been used many times in Codeforces contests.\n\n## Samples\n\n### Checker\n\nThis sample checker expects the same integer in the output and the answer. It ignores all white-spaces. See more examples in the package.\n\n```c++\n#include \"testlib.h\"\n\nint main(int argc, char * argv[]) {\n    setName(\"compares two signed integers\");\n    registerTestlibCmd(argc, argv);\n    int ja = ans.readInt();\n    int pa = ouf.readInt();\n    if (ja != pa)\n        quitf(_wa, \"expected %d, found %d\", ja, pa);\n    quitf(_ok, \"answer is %d\", ja);\n}\n```\n\n### Interactor\n\nThis sample interactor reads pairs of numbers from the input file, sends them to another program, reads\nthe result, and writes it to an output file (to be verified later). Another option could be to terminate\nthe interactor with `quitf(_wa, \u003ccomment\u003e)`.\n\n```c++\n#include \"testlib.h\"\n#include \u003ciostream\u003e\n\nusing namespace std;\n\nint main(int argc, char* argv[]) {\n    setName(\"Interactor A+B\");\n    registerInteraction(argc, argv);\n\n    // reads number of queries from test (input) file\n    int n = inf.readInt();\n    for (int i = 0; i \u003c n; i++) {\n        // reads query from test (input) file\n        int a = inf.readInt();\n        int b = inf.readInt();\n\n        // writes query to the solution, endl makes flush\n        cout \u003c\u003c a \u003c\u003c \" \" \u003c\u003c b \u003c\u003c endl;\n\n        // writes output file to be verified by checker later\n        tout \u003c\u003c ouf.readInt() \u003c\u003c endl;\n    }\n\n    // just message\n    quitf(_ok, \"%d queries processed\", n);\n}\n```\n\n### Validator\n\nThis code reads input from the standard input and checks that it contains only one integer between 1 and 100, inclusive. It also validates that the file ends with EOLN and EOF. On Windows, it expects #13#10 as EOLN, and it expects #10 as EOLN on other platforms. It does not ignore white-spaces, so it works very strictly. It will return a non-zero code in the case of illegal input and write a message to the standard output. See more examples in the package.\n\n```c++\n#include \"testlib.h\"\n\nint main(int argc, char* argv[]) {\n    registerValidation(argc, argv);\n    inf.readInt(1, 100, \"n\");\n    inf.readEoln();\n    inf.readEof();\n}\n```\n\n### Generator\n\nThis generator outputs a random token to the standard output, containing Latin letters or digits. The length of the token will be between 1 and 1000, inclusive. It will use a uniformly distributed random generator. To generate different values, call it with different command-line parameters. It is typical behavior for a testlib generator to set up randseed by command line. See more examples in the package.\n\n```c++\n#include \"testlib.h\"\n\nint main(int argc, char* argv[]) {\n    registerGen(argc, argv, 1);\n    println(rnd.next(1, 10)); /* Random number in the range [1,10]. */\n    println(rnd.next(\"[a-zA-Z0-9]{1,1000}\")); /* Random word of length [1,1000]. */\n}\n```\n\nThis generator outputs a random permutation; the size is equal to the first command-line argument.\n\n```c++\n#include \"testlib.h\"\n\nint main(int argc, char* argv[]) {\n    registerGen(argc, argv, 1);\n    \n    int n = opt\u003cint\u003e(1);\n    println(n);\n    println(rnd.perm(n, 1));\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikemirzayanov%2Ftestlib","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmikemirzayanov%2Ftestlib","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmikemirzayanov%2Ftestlib/lists"}