diff --git a/.idea/checkstyle-idea.xml b/.idea/checkstyle-idea.xml
new file mode 100644
index 0000000..2959b8e
--- /dev/null
+++ b/.idea/checkstyle-idea.xml
@@ -0,0 +1,15 @@
+
+
+
+ 13.4.2
+ JavaOnly
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/discord.xml b/.idea/discord.xml
new file mode 100644
index 0000000..912db82
--- /dev/null
+++ b/.idea/discord.xml
@@ -0,0 +1,14 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index 94a25f7..35eb1dd 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,6 +1,6 @@
-
+
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index f04fa62..6fe6ea4 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -3,7 +3,7 @@ plugins {
}
group = "ru.thiflict"
-version = "1.0-SNAPSHOT"
+version = "1.0.0"
repositories {
mavenCentral()
diff --git a/src/main/kotlin/BinCheck.kt b/src/main/kotlin/BinCheck.kt
index 941f0b7..94f9010 100644
--- a/src/main/kotlin/BinCheck.kt
+++ b/src/main/kotlin/BinCheck.kt
@@ -8,22 +8,24 @@ package ru.thiflict
* @author Thiflict
*
* @since[1.0.0]
- *
*/
object BinCheck {
/**
* Проверяет наличие единицы в заданом регистре
*
- * Тип данных [Int]
+ * Тип данных для проверяемого числа [Short].
+ * Тип данных для проверяемого регистра [Byte]
*
* Пример:
* ```
- * checkRegisterShort(0100, 2)
+ * checkRegisterShort(8, 3)
* ```
* @return true
*/
- fun checkRegisterShort(input: Int, register: Int): Boolean {
- val mask = 1 shl 2
+ fun checkRegisterShort(input: Short, register: Byte): Boolean {
+ val binaryString = String.format("%16s", input.toInt().toString(2).replace(' ', '0'))
+ val index = 15 - register.toInt()
+ return binaryString[index] == '1'
}
}
\ No newline at end of file
diff --git a/src/test/kotlin/CheckRegisterTest.kt b/src/test/kotlin/CheckRegisterTest.kt
new file mode 100644
index 0000000..796751e
--- /dev/null
+++ b/src/test/kotlin/CheckRegisterTest.kt
@@ -0,0 +1,38 @@
+import ru.thiflict.BinCheck.checkRegisterShort
+
+/**
+ * Тест [checkRegisterShort]
+ *
+ * Его писал Qwen3 Coder
+ */
+fun main() {
+ // Тест 1: Проверка значения 8 в регистре 3 (должно быть true)
+ println("Тест 1: checkRegisterShort(8, 3) = ${checkRegisterShort(8, 3.toByte())}")
+
+ // Тест 2: Проверка значения 16 в регистре 4 (должно быть true)
+ println("Тест 2: checkRegisterShort(16, 4) = ${checkRegisterShort(16, 4.toByte())}")
+
+ // Тест 3: Проверка значения 1 в регистре 0 (должно быть true)
+ println("Тест 3: checkRegisterShort(1, 0) = ${checkRegisterShort(1, 0.toByte())}")
+
+ // Тест 4: Проверка значения 0 в регистре 0 (должно быть false)
+ println("Тест 4: checkRegisterShort(0, 0) = ${checkRegisterShort(0, 0.toByte())}")
+
+ // Тест 5: Проверка значения 32767 в регистре 15 (должно быть false)
+ println("Тест 5: checkRegisterShort(32767, 15) = ${checkRegisterShort(32767, 15.toByte())}")
+
+ // Тест 6: Проверка значения 32767 в регистре 0 (должно быть true)
+ println("Тест 6: checkRegisterShort(32767, 0) = ${checkRegisterShort(32767, 0.toByte())}")
+
+ // Тест 7: Проверка значения 15 в регистре 3 (должно быть true)
+ println("Тест 7: checkRegisterShort(15, 3) = ${checkRegisterShort(15, 3.toByte())}")
+
+ // Тест 8: Проверка значения 15 в регистре 0 (должно быть true)
+ println("Тест 8: checkRegisterShort(15, 0) = ${checkRegisterShort(15, 0.toByte())}")
+
+ // Тест 9: Проверка значения 256 в регистре 8 (должно быть true)
+ println("Тест 9: checkRegisterShort(256, 8) = ${checkRegisterShort(256, 8.toByte())}")
+
+ // Тест 10: Проверка значения -1 в регистре 0 (должно быть true, так как все биты установлены)
+ println("Тест 10: checkRegisterShort(-1, 0) = ${checkRegisterShort(-1, 0.toByte())}")
+}
\ No newline at end of file