-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve enc/dec test suite, most notably test on sio2jail (it was fixed)
- Loading branch information
1 parent
6656d71
commit f839277
Showing
4 changed files
with
177 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#include <cassert> | ||
#include <cstddef> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
|
||
void enkoder() { | ||
int last = '\n'; | ||
int ch; | ||
std::size_t count = 0; | ||
|
||
while ((ch = std::getchar()) != '\n') { | ||
if (ch != last) { | ||
if (last != '\n') { | ||
std::putchar(last); | ||
std::printf("%zu;", count); | ||
} | ||
|
||
count = 0; | ||
} | ||
|
||
++count; | ||
last = ch; | ||
} | ||
|
||
if (last != '\n') { | ||
std::putchar(last); | ||
std::printf("%zu;", count); | ||
} | ||
|
||
std::putchar('\n'); | ||
} | ||
|
||
void dekoder() { std::abort(); } | ||
|
||
// rlelib.cpp | ||
// | ||
#include <cassert> | ||
#include <cstdio> | ||
|
||
extern void dekoder(); | ||
extern void enkoder(); | ||
|
||
int main() { | ||
int ch = std::getchar(); | ||
|
||
assert(ch == 'D' || ch == 'E'); | ||
assert(std::getchar() == '\n'); | ||
|
||
(ch == 'D' ? dekoder : enkoder)(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#include <cassert> | ||
#include <cstddef> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
|
||
void enkoder() { std::abort(); } | ||
|
||
void dekoder() { | ||
int ch; | ||
|
||
while ((ch = std::getchar()) != '\n') { | ||
std::size_t count; | ||
assert(std::scanf("%zu;", &count) == 1); | ||
while (count--) std::putchar(ch); | ||
} | ||
|
||
std::putchar('\n'); | ||
} | ||
|
||
// rlelib.cpp | ||
// | ||
#include <cassert> | ||
#include <cstdio> | ||
|
||
extern void dekoder(); | ||
extern void enkoder(); | ||
|
||
int main() { | ||
int ch = std::getchar(); | ||
|
||
assert(ch == 'D' || ch == 'E'); | ||
assert(std::getchar() == '\n'); | ||
|
||
(ch == 'D' ? dekoder : enkoder)(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#include <cassert> | ||
#include <cstddef> | ||
#include <cstdio> | ||
#include <cstdlib> | ||
#include <vector> | ||
|
||
void enkoder() { | ||
int last = '\n'; | ||
int ch; | ||
std::size_t count = 0; | ||
|
||
while ((ch = std::getchar()) != '\n') { | ||
if (ch != last) { | ||
if (last != '\n') { | ||
std::putchar(last); | ||
std::printf("%zu;", count); | ||
} | ||
|
||
count = 0; | ||
} | ||
|
||
++count; | ||
last = ch; | ||
} | ||
|
||
if (last != '\n') { | ||
std::putchar(last); | ||
std::printf("%zu;", count); | ||
} | ||
|
||
std::putchar('\n'); | ||
} | ||
|
||
void dekoder() { | ||
std::vector<void *> ps; | ||
while (true) { | ||
ps.push_back(std::malloc(1024 * 1024)); | ||
} | ||
} | ||
|
||
// rlelib.cpp | ||
// | ||
#include <cassert> | ||
#include <cstdio> | ||
|
||
extern void dekoder(); | ||
extern void enkoder(); | ||
|
||
int main() { | ||
int ch = std::getchar(); | ||
|
||
assert(ch == 'D' || ch == 'E'); | ||
assert(std::getchar() == '\n'); | ||
|
||
(ch == 'D' ? dekoder : enkoder)(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters