From d6f67906ea5b369b47bce8e0a7125d66114fdbde Mon Sep 17 00:00:00 2001
From: alexvru <alexvru@ydb.tech>
Date: Tue, 15 Aug 2023 21:09:36 +0300
Subject: Support BS autoconfig KIKIMR-19031

---
 .../cpp/openssl/big_integer/ut/big_integer_ut.cpp  | 43 ++++++++++++++++++++++
 library/cpp/openssl/big_integer/ut/ya.make         |  7 ++++
 2 files changed, 50 insertions(+)
 create mode 100644 library/cpp/openssl/big_integer/ut/big_integer_ut.cpp
 create mode 100644 library/cpp/openssl/big_integer/ut/ya.make

(limited to 'library/cpp/openssl/big_integer/ut')

diff --git a/library/cpp/openssl/big_integer/ut/big_integer_ut.cpp b/library/cpp/openssl/big_integer/ut/big_integer_ut.cpp
new file mode 100644
index 0000000000..8a0050f531
--- /dev/null
+++ b/library/cpp/openssl/big_integer/ut/big_integer_ut.cpp
@@ -0,0 +1,43 @@
+#include "big_integer.h"
+
+#include <library/cpp/testing/unittest/registar.h>
+
+#include <util/system/byteorder.h>
+#include <util/stream/str.h>
+
+Y_UNIT_TEST_SUITE(BigInteger) {
+    using NOpenSsl::TBigInteger;
+
+    Y_UNIT_TEST(Initialization) {
+        constexpr ui64 testVal = 12345678900;
+        const auto fromULong = TBigInteger::FromULong(testVal);
+
+        const ui64 testArea = HostToInet(testVal); // transform to big-endian
+        const auto fromRegion = TBigInteger::FromRegion(&testArea, sizeof(testArea));
+        UNIT_ASSERT(fromULong == fromRegion);
+        UNIT_ASSERT_VALUES_EQUAL(fromULong, fromRegion);
+
+        const auto fromULongOther = TBigInteger::FromULong(22345678900);
+        UNIT_ASSERT(fromULong != fromULongOther);
+    }
+
+    Y_UNIT_TEST(Decimal) {
+        UNIT_ASSERT_VALUES_EQUAL(TBigInteger::FromULong(123456789).ToDecimalString(), "123456789");
+    }
+
+    Y_UNIT_TEST(Region) {
+        const auto v1 = TBigInteger::FromULong(1234567890);
+        char buf[1024];
+        const auto v2 = TBigInteger::FromRegion(buf, v1.ToRegion(buf));
+
+        UNIT_ASSERT_VALUES_EQUAL(v1, v2);
+    }
+
+    Y_UNIT_TEST(Output) {
+        TStringStream ss;
+
+        ss << TBigInteger::FromULong(123456789);
+
+        UNIT_ASSERT_VALUES_EQUAL(ss.Str(), "123456789");
+    }
+}
diff --git a/library/cpp/openssl/big_integer/ut/ya.make b/library/cpp/openssl/big_integer/ut/ya.make
new file mode 100644
index 0000000000..473b5c6a9c
--- /dev/null
+++ b/library/cpp/openssl/big_integer/ut/ya.make
@@ -0,0 +1,7 @@
+UNITTEST_FOR(library/cpp/openssl/big_integer)
+
+SRCS(
+    big_integer_ut.cpp
+)
+
+END()
-- 
cgit v1.2.3