Skip to content

Commit 9ecb111

Browse files
Merge pull request MikeMirzayanov#213 from MikeMirzayanov/fix-workflows
Fix workflows/tests
2 parents a6e57ad + f5d2265 commit 9ecb111

File tree

26 files changed

+365
-93
lines changed

26 files changed

+365
-93
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -146,12 +146,12 @@ jobs:
146146
cd tests
147147
bash ./run.sh ${{ matrix.compiler }} v${{ matrix.version }} 32
148148
149-
tests-macos11-gpp:
149+
tests-macos12-gpp:
150150
strategy:
151151
matrix:
152-
os: [macos-11]
152+
os: [macos-12]
153153
compiler: [g++]
154-
version: [10, 11, 12]
154+
version: [12, 13, 14]
155155
name: Use ${{ matrix.compiler }}-${{ matrix.version }} on ${{ matrix.os }}
156156
runs-on: ${{ matrix.os }}
157157
steps:
@@ -161,10 +161,10 @@ jobs:
161161
cd tests
162162
bash ./run.sh ${{ matrix.compiler }} v${{ matrix.version }}
163163
164-
tests-macos11-clang:
164+
tests-macos12-clang:
165165
strategy:
166166
matrix:
167-
os: [macos-11]
167+
os: [macos-12]
168168
compiler: [clang++]
169169
name: Use ${{ matrix.compiler }} on ${{ matrix.os }}
170170
runs-on: ${{ matrix.os }}
@@ -175,12 +175,12 @@ jobs:
175175
cd tests
176176
bash ./run.sh ${{ matrix.compiler }}
177177
178-
tests-macos12-gpp:
178+
tests-macos13-gpp:
179179
strategy:
180180
matrix:
181-
os: [macos-12]
181+
os: [macos-13]
182182
compiler: [g++]
183-
version: [11, 12, 13]
183+
version: [12, 13, 14]
184184
name: Use ${{ matrix.compiler }}-${{ matrix.version }} on ${{ matrix.os }}
185185
runs-on: ${{ matrix.os }}
186186
steps:
@@ -190,10 +190,10 @@ jobs:
190190
cd tests
191191
bash ./run.sh ${{ matrix.compiler }} v${{ matrix.version }}
192192
193-
tests-macos12-clang:
193+
tests-macos13-clang:
194194
strategy:
195195
matrix:
196-
os: [macos-12]
196+
os: [macos-13]
197197
compiler: [clang++]
198198
name: Use ${{ matrix.compiler }} on ${{ matrix.os }}
199199
runs-on: ${{ matrix.os }}
@@ -204,12 +204,12 @@ jobs:
204204
cd tests
205205
bash ./run.sh ${{ matrix.compiler }}
206206
207-
tests-macos13-gpp:
207+
tests-macos14-gpp:
208208
strategy:
209209
matrix:
210-
os: [macos-13]
210+
os: [macos-14]
211211
compiler: [g++]
212-
version: [11, 12, 13]
212+
version: [12, 13, 14]
213213
name: Use ${{ matrix.compiler }}-${{ matrix.version }} on ${{ matrix.os }}
214214
runs-on: ${{ matrix.os }}
215215
steps:
@@ -219,10 +219,10 @@ jobs:
219219
cd tests
220220
bash ./run.sh ${{ matrix.compiler }} v${{ matrix.version }}
221221
222-
tests-macos13-clang:
222+
tests-macos14-clang:
223223
strategy:
224224
matrix:
225-
os: [macos-13]
225+
os: [macos-14]
226226
compiler: [clang++]
227227
name: Use ${{ matrix.compiler }} on ${{ matrix.os }}
228228
runs-on: ${{ matrix.os }}

docs/read.me

Lines changed: 107 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,107 @@
1-
TESTLIB
2-
3-
== What is it? ==
4-
Testlib is simple library which helps you to write
5-
* checkers
6-
* validators
7-
* generators
8-
* interactors
9-
for programming competitions problems.
10-
You can find latest release of the library on https://github.com/MikeMirzayanov/testlib/
11-
Problem development management system Polygon completely supports testlib.
12-
13-
== How to use? ==
14-
Easest way is to read c++ sources in the checkers/, validators/, generators/ and interactors/ folders.
15-
Also some classes and methods in testlib have documentation.
16-
17-
Thanks for using testlib,
18-
Mike Mirzayanov
19-
1+
# Testlib
2+
3+
## Intro
4+
5+
This 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!
6+
7+
The library's C++ code is tested for compatibility with standard C++11 and higher on different versions of `g++`, `clang++`, and Microsoft Visual C++.
8+
9+
This code has been used many times in Codeforces contests.
10+
11+
## Samples
12+
13+
### Checker
14+
15+
This sample checker expects the same integer in the output and the answer. It ignores all white-spaces. See more examples in the package.
16+
17+
```c++
18+
#include "testlib.h"
19+
20+
int main(int argc, char * argv[]) {
21+
setName("compares two signed integers");
22+
registerTestlibCmd(argc, argv);
23+
int ja = ans.readInt();
24+
int pa = ouf.readInt();
25+
if (ja != pa)
26+
quitf(_wa, "expected %d, found %d", ja, pa);
27+
quitf(_ok, "answer is %d", ja);
28+
}
29+
```
30+
31+
### Interactor
32+
33+
This sample interactor reads pairs of numbers from the input file, sends them to another program, reads
34+
the result, and writes it to an output file (to be verified later). Another option could be to terminate
35+
the interactor with `quitf(_wa, <comment>)`.
36+
37+
```c++
38+
#include "testlib.h"
39+
#include <iostream>
40+
41+
using namespace std;
42+
43+
int main(int argc, char* argv[]) {
44+
setName("Interactor A+B");
45+
registerInteraction(argc, argv);
46+
47+
// reads number of queries from test (input) file
48+
int n = inf.readInt();
49+
for (int i = 0; i < n; i++) {
50+
// reads query from test (input) file
51+
int a = inf.readInt();
52+
int b = inf.readInt();
53+
54+
// writes query to the solution, endl makes flush
55+
cout << a << " " << b << endl;
56+
57+
// writes output file to be verified by checker later
58+
tout << ouf.readInt() << endl;
59+
}
60+
61+
// just message
62+
quitf(_ok, "%d queries processed", n);
63+
}
64+
```
65+
66+
### Validator
67+
68+
This 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.
69+
70+
```c++
71+
#include "testlib.h"
72+
73+
int main(int argc, char* argv[]) {
74+
registerValidation(argc, argv);
75+
inf.readInt(1, 100, "n");
76+
inf.readEoln();
77+
inf.readEof();
78+
}
79+
```
80+
81+
### Generator
82+
83+
This 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.
84+
85+
```c++
86+
#include "testlib.h"
87+
88+
int main(int argc, char* argv[]) {
89+
registerGen(argc, argv, 1);
90+
println(rnd.next(1, 10)); /* Random number in the range [1,10]. */
91+
println(rnd.next("[a-zA-Z0-9]{1,1000}")); /* Random word of length [1,1000]. */
92+
}
93+
```
94+
95+
This generator outputs a random permutation; the size is equal to the first command-line argument.
96+
97+
```c++
98+
#include "testlib.h"
99+
100+
int main(int argc, char* argv[]) {
101+
registerGen(argc, argv, 1);
102+
103+
int n = opt<int>(1);
104+
println(n);
105+
println(rnd.perm(n, 1));
106+
}
107+
```

0 commit comments

Comments
 (0)