Conversation
| return true; | ||
| } | ||
|
|
||
| /*public static boolean isHexadecimal(byte[] bytes) { |
There was a problem hiding this comment.
No es bueno dejar código comentado, quitalo por favor.
| /* fin del metodo */ | ||
| /* metodo 2 */ | ||
|
|
||
| public static void main (String[] args) { |
There was a problem hiding this comment.
esta clase nunca se va a ejecutar por separado, por este motivo, no es bueno que tenga un main independiente.
danicricco
left a comment
There was a problem hiding this comment.
Fijate que en el ticket 505 lo que pide es modificar la función ISOUtil.hex2byte
Esta función tiene la siguiente firma:
byte[] hex2byte (String s)
Es decir, tu misión es controlar que los caracteres que están representados en el String, no contengan valores inválidos.
La función de controlar cada caracter, si es un símbolo válido de hexadecimal, tiene sentido. Sin embargo, esto hay que hacerlo en el contexto de un String (es el input de la función)
|
|
||
|
|
||
| public static boolean isHexadecimal(byte[] bytes) { | ||
| for (byte b : bytes) { |
There was a problem hiding this comment.
porque tenes 2 funciones "isHexadecimal" ?
En todo caso, podes hacer que esta que recibe byte[] le llame a la anterior. De otra manera, estarias teniendo dos implementaciones de lo mismo.
There was a problem hiding this comment.
se me ocurrio hacerlo asi, pero voy a modificarlos sin problemas.
|
|
||
|
|
||
| @Test | ||
| public void TestsHex1() { |
There was a problem hiding this comment.
Los nombres de los tests deberian tener nombres significativos. ejemplo:
TestConvertToHexValidInput
TestConvertToHexInvalidInput
There was a problem hiding this comment.
perfecto, los voy a correjir
| @Test | ||
| public void TestsHex3() { | ||
| String p = null; | ||
| ISOUtil.hex2byte(p); |
There was a problem hiding this comment.
Lo que tenes que probar en un test que falla es justamente que lanza una excepción. Deberias en este caso agarrar la excepcion, y no hacer nada, porque es esperado que falle. Si no hay excepción, tenes que fallar.
Fijate como escribir junit con excepciones:
https://www.baeldung.com/junit-assert-exception
There was a problem hiding this comment.
ok me voy a fijar y lanzar la exceptions
| public void testAsciiToEbcdic1() throws Throwable { | ||
| byte[] a = new byte[1]; | ||
| byte[] result = ISOUtil.asciiToEbcdic(a); | ||
| byte[] result = c.asciiToEbcdic(a); |
There was a problem hiding this comment.
porque tocas esta linea ? Entiend que no deberias
There was a problem hiding this comment.
La verdad que no toque, o derepente se movio mi puntero o algo, pero no toque fue sin querer perdon.
There was a problem hiding this comment.
Tenes que eliminar esto de los cambios.
|
|
||
| if (s.isEmpty() || s.length() % 2 != 0) //verificar si el string es vacio | ||
| { | ||
| throw new IllegalArgumentException("The string is empty or null"); |
There was a problem hiding this comment.
El mensaje tiene que ser más explicativo. El control está bueno, si no tenes un número par, entones tenes un string Hex inválido. Sin embargo, el mensaje no refleja eso.
| @Test | ||
| public void testIsHexadecimal_ValidInput_ThrowsExceptionWithMessage() { | ||
|
|
||
| Exception exception = assertThrows(RuntimeException.class, () -> { |
There was a problem hiding this comment.
Es mejor poner la excepción del tipo que estás esperando. En tu caso entiendo que es un IllegalArgumentException
| public void testIsHexadecimal_ValidInput_ThrowsExceptionWithMessage() { | ||
|
|
||
| Exception exception = assertThrows(RuntimeException.class, () -> { | ||
| ISOUtil.hex2byte("1A2B3C"); |
There was a problem hiding this comment.
En este caso es un input válido, entonces no debería excepcionar, sino que el caso debería de comprobar que efectivamente logró convertir.
There was a problem hiding this comment.
Entonces aca le saco nomas la excepcion o como seria Dani?
No description provided.