From 14c793b8806e3f52e37f1ba68131ff691d3abdb8 Mon Sep 17 00:00:00 2001 From: thiflict <121az348@gmail.com> Date: Wed, 10 Jun 2026 11:35:55 +0500 Subject: [PATCH 1/3] =?UTF-8?q?=D0=91=D0=B0=D0=B3=D1=84=D0=B8=D0=BA=D1=81?= =?UTF-8?q?=D1=8B=20=D0=B8=20=D0=BC=D0=B5=D0=BB=D0=BA=D0=B8=D0=B5=20=D0=B4?= =?UTF-8?q?=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5=D0=BD=D0=B8=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- readme.md | 4 ++-- src/main/kotlin/BinCheck.kt | 29 ++++++++++++++++++++++++++-- src/test/kotlin/CheckRegisterTest.kt | 7 +++++++ 3 files changed, 36 insertions(+), 4 deletions(-) diff --git a/readme.md b/readme.md index be4bfeb..d036fce 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,5 @@ # BinaryUtils -пока пох на описание лмао +Детальная информация о проекте лежит в Wiki как импортировать в проект: @@ -12,6 +12,6 @@ repositories { dependencies { // Добавить в dependencies - implementation("ru.thiflict.binaryutils:binary-utils:1.0.0") + implementation("ru.thiflict.binaryutils:binary-utils:1.0.0") // У релизов всегда актуальная версия } ``` \ No newline at end of file diff --git a/src/main/kotlin/BinCheck.kt b/src/main/kotlin/BinCheck.kt index 63e3ccb..43b4203 100644 --- a/src/main/kotlin/BinCheck.kt +++ b/src/main/kotlin/BinCheck.kt @@ -17,14 +17,39 @@ object BinCheck { * Тип данных для проверяемого числа [Short]. * Тип данных для проверяемого регистра [Byte] * + * Регистр *не может быть* **отрицательным** или **больше 15** + * * Пример: * ``` * checkRegisterShort(8, 3) * ``` - * @return true + * @return [Boolean] + * @throws IllegalArgumentException */ - fun checkRegisterShort(input: Short, register: Byte): Boolean { + fun checkRegisterShort(input: Short, register: Byte, verbose: Boolean = false): Boolean { + // Защиты от дурачков + if (register < 0) throw IllegalArgumentException("Проверяемый регистр не может быть отрицательным!") + if (register > 15) throw IllegalArgumentException("Проверяемый регистр не может быть больше, чем количество регистров Short!") + + if (verbose) println("Debug: checkRegisterShort(): Выполнена проверка на IllegalArgumentException") + val binaryString = String.format("%16s", input.toInt().toString(2).replace(' ', '0')) + + if (verbose) println("Debug: checkRegisterShort(): ${ + if (binaryString.startsWith("-")) { + val binaryStringFormatted = binaryString + .drop(1) + .chunked(4) + .joinToString(" ") + "-$binaryStringFormatted" + } + else { + binaryString + .chunked(4) + .joinToString(" ") + } + }") + val index = 15 - register.toInt() return binaryString[index] == '1' } diff --git a/src/test/kotlin/CheckRegisterTest.kt b/src/test/kotlin/CheckRegisterTest.kt index 24f8330..54f5211 100644 --- a/src/test/kotlin/CheckRegisterTest.kt +++ b/src/test/kotlin/CheckRegisterTest.kt @@ -35,4 +35,11 @@ fun main() { // Тест 10: Проверка значения -1 в регистре 0 (должно быть true, так как все биты установлены) println("Тест 10: checkRegisterShort(-1, 0) = ${checkRegisterShort(-1, 0.toByte())}") + + // Тест на кидание IllegalArgumentException №1 +// println("Тест 11: checkRegisterShort(5, -1) = ${checkRegisterShort(5, (-1).toByte())}") + + // Тест на кидание IllegalArgumentException №2 +// println("Тест 11: checkRegisterShort(25, 16) = ${checkRegisterShort(32767.toShort(), 15.toByte(), true)}") + } \ No newline at end of file From f24ba729f38344edb96aea554acda3a2291238e1 Mon Sep 17 00:00:00 2001 From: thiflict <121az348@gmail.com> Date: Wed, 10 Jun 2026 11:36:31 +0500 Subject: [PATCH 2/3] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=20=D0=BD=D0=BE?= =?UTF-8?q?=D0=B2=D0=BE=D0=B9=20=D0=B2=D0=B5=D1=80=D1=81=D0=B8=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/build.gradle.kts b/build.gradle.kts index a63e59f..c84f760 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -4,7 +4,7 @@ plugins { } group = "ru.thiflict.binaryutils" -version = "1.0.0" +version = "1.0.1" repositories { mavenCentral() @@ -27,7 +27,7 @@ publishing { create("maven") { groupId = "ru.thiflict.binaryutils" artifactId = "binary-utils" - version = "1.0.0" + version = "1.0.1" from(components["java"]) } From 5c977ea2c830eeeae6f764a2fefdf599d998fe0d Mon Sep 17 00:00:00 2001 From: thiflict <121az348@gmail.com> Date: Wed, 10 Jun 2026 11:41:46 +0500 Subject: [PATCH 3/3] =?UTF-8?q?=D0=94=D0=BE=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- publish.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/publish.sh b/publish.sh index c91c213..790b253 100755 --- a/publish.sh +++ b/publish.sh @@ -1,2 +1,4 @@ +# Этот скрипт для обычных юзеров ничего из себя не представляет +# Только для меинтеинера. export $(cat .env | xargs) ./gradlew publish