From b200c23ac30a7f953548cb164c0893f3fe7f36cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Szymon=20=C5=81ab=C4=99dziewski?= Date: Mon, 29 Dec 2025 12:35:11 +0100 Subject: [PATCH] Update test_fv.cpp MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * funkcja 'test_infinite_zip'= łączy dwa nieskończone źródła (liczby po kolei i liczby losowe). --- tests/test_fv.cpp | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/tests/test_fv.cpp b/tests/test_fv.cpp index b36241e..f7c0f5f 100644 --- a/tests/test_fv.cpp +++ b/tests/test_fv.cpp @@ -598,6 +598,31 @@ void test_free_stream() { } +void test_infinite_zip() { + // Generuje 0 - nieskończoność + auto infinite_ints = iota_stream(0); + + // Generuje liczby losowe (nieskończoność) + auto infinite_randoms = crandom_stream(); + + // Łączymy dwa nieskończone strumienie + // Bierzemy tylko 10 pierwszych par => bylaby pętla nieskończona + auto zipped = infinite_ints.zip(infinite_randoms).take(10); + + VALUE(zipped.size()) EXPECTED(10); + + // Sprawdzamy czy pierwszy element pary to kolejne liczby całkowite + VALUE(zipped.element_at(0).value().first) EXPECTED(0); + VALUE(zipped.element_at(5).value().first) EXPECTED(5); + VALUE(zipped.element_at(9).value().first) EXPECTED(9); + + // Czy da się iterować? + std::cout << "Infinite Zip Output: "; + zipped.foreach(S(std::cout << "[" << _.first << ":" << _.second << "] ")); + std::cout << "\n"; +} + + int main() { const int failed = + SUITE(test_type_presentation) @@ -627,8 +652,9 @@ int main() { + SUITE(test_array_view) + SUITE(test_string) + SUITE(test_underscore_macros) - + SUITE(test_free_stream); + + SUITE(test_free_stream) + + SUITE(test_infinite_zip); std::cout << (failed == 0 ? "ALL OK" : "FAILURE") << std::endl; return failed; -} \ No newline at end of file +}