diff options
| author | _ov4 <ov4@ov4.one> | 2026-10-16 20:53:55 +0800 |
|---|---|---|
| committer | _ov4 <ov4@ov4.one> | 2026-10-16 20:53:55 +0800 |
| commit | d19f9ddb866ac2415cbfe66966897a8efe8ddb63 (patch) | |
| tree | 6be1a9a6e316e776a396813f7cb22c688287b21a /tests/ii/files/reference.cc | |
| parent | 5c00b8cd03cbfc516cce92229f3f4974d7549c24 (diff) | |
test(compiler): add seeded C++ differential tests across seven groups
Generate 10000 random records per group plus boundary inputs using a
portable SHA-256 stream. Compare native and runner output independently.
Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Diffstat (limited to 'tests/ii/files/reference.cc')
| -rw-r--r-- | tests/ii/files/reference.cc | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tests/ii/files/reference.cc b/tests/ii/files/reference.cc new file mode 100644 index 0000000..d9b784c --- /dev/null +++ b/tests/ii/files/reference.cc @@ -0,0 +1,20 @@ +#include <fstream> +#include <iostream> +#include <string> +int main() { + int count; + if (!(std::cin >> count)) return 1; + for (int i = 0; i < count; ++i) { + std::string text, extra; + if (!(std::cin >> text >> extra)) return 1; + { std::ofstream file("roundtrip.txt"); file << text << "\n\n"; if (!file) return 1; } + { std::ofstream file("roundtrip.txt", std::ios::app); file << extra << '\n'; if (!file) return 1; } + std::ifstream file("roundtrip.txt"); + if (!file) return 1; + std::string line, combined; + int lines = 0; + while (std::getline(file, line)) { combined += '[' + line + ']'; ++lines; } + if (!file.eof()) return 1; + std::cout << lines << ':' << combined << '\n'; + } +} |
