fix tests
This commit is contained in:
parent
e901c2bee8
commit
c84e7ec326
|
@ -1,6 +1,8 @@
|
||||||
package info.nightscout.androidaps.utils.extensions
|
package info.nightscout.androidaps.utils.extensions
|
||||||
|
|
||||||
private val HEX_CHARS = "0123456789ABCDEF".toCharArray()
|
import java.util.*
|
||||||
|
|
||||||
|
private val HEX_CHARS = "0123456789abcdef".toCharArray()
|
||||||
|
|
||||||
fun ByteArray.toHex() : String{
|
fun ByteArray.toHex() : String{
|
||||||
val result = StringBuffer()
|
val result = StringBuffer()
|
||||||
|
@ -20,9 +22,10 @@ fun String.hexStringToByteArray() : ByteArray {
|
||||||
|
|
||||||
val result = ByteArray(length / 2)
|
val result = ByteArray(length / 2)
|
||||||
|
|
||||||
|
val lowerCased = this.toLowerCase(Locale.getDefault())
|
||||||
for (i in 0 until length step 2) {
|
for (i in 0 until length step 2) {
|
||||||
val firstIndex = HEX_CHARS.indexOf(this[i]);
|
val firstIndex = HEX_CHARS.indexOf(lowerCased[i]);
|
||||||
val secondIndex = HEX_CHARS.indexOf(this[i + 1]);
|
val secondIndex = HEX_CHARS.indexOf(lowerCased[i + 1]);
|
||||||
|
|
||||||
val octet = firstIndex.shl(4).or(secondIndex)
|
val octet = firstIndex.shl(4).or(secondIndex)
|
||||||
result.set(i.shr(1), octet.toByte())
|
result.set(i.shr(1), octet.toByte())
|
||||||
|
|
Loading…
Reference in a new issue