aboutsummaryrefslogtreecommitdiff
path: root/tests/ii/arrays/reference.cc
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.one>2026-10-16 20:53:55 +0800
committer_ov4 <ov4@ov4.one>2026-10-16 20:53:55 +0800
commitd19f9ddb866ac2415cbfe66966897a8efe8ddb63 (patch)
tree6be1a9a6e316e776a396813f7cb22c688287b21a /tests/ii/arrays/reference.cc
parent5c00b8cd03cbfc516cce92229f3f4974d7549c24 (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/arrays/reference.cc')
-rw-r--r--tests/ii/arrays/reference.cc13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/ii/arrays/reference.cc b/tests/ii/arrays/reference.cc
new file mode 100644
index 0000000..9a136bd
--- /dev/null
+++ b/tests/ii/arrays/reference.cc
@@ -0,0 +1,13 @@
+#include <cstdint>
+#include <iostream>
+int main() {
+ int count;
+ if (!(std::cin >> count)) return 1;
+ for (int record = 0; record < count; ++record) {
+ std::int64_t lower, size, step, base;
+ if (!(std::cin >> lower >> size >> step >> base) || size < 1) return 1;
+ // Closed form is independent of pseudocode's indexed loop.
+ auto sum = size * base + step * size * (size - 1) / 2;
+ std::cout << sum << ':' << base << ':' << base + (size - 1) * step << '\n';
+ }
+}