Skip to content

Commit

Permalink
parameterized tests
Browse files Browse the repository at this point in the history
  • Loading branch information
kpartlow committed Feb 9, 2024
1 parent 887c491 commit 65e515a
Show file tree
Hide file tree
Showing 3 changed files with 248 additions and 189 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<groupId>com.cedarsoftware</groupId>
<artifactId>java-util</artifactId>
<packaging>jar</packaging>
<version>2.4.1</version>
<version>2.5.0-SNAPSHOT</version>
<description>Java Utilities</description>
<url>https://github.com/jdereg/java-util</url>

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.cedarsoftware.util.convert;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.NullSource;

import static org.assertj.core.api.Assertions.assertThat;

class CharacterConversionsTests {

private Converter converter;

@BeforeEach
void beforeEach() {
this.converter = new Converter(new DefaultConverterOptions());
}

@ParameterizedTest
@NullSource
void toByteObject_whenCharacterIsNull_returnsNull(Character ch) {
assertThat(this.converter.convert(ch, Byte.class))
.isNull();
}

@ParameterizedTest
@NullSource
void toByte_whenCharacterIsNull_returnsCommonValuesZero(Character ch) {
assertThat(this.converter.convert(ch, byte.class))
.isSameAs(CommonValues.BYTE_ZERO);
}

@ParameterizedTest
@NullSource
void toIntObject_whenCharacterIsNull_returnsNull(Character ch) {
assertThat(this.converter.convert(ch, Integer.class))
.isNull();
}

@ParameterizedTest
@NullSource
void toInteger_whenCharacterIsNull_returnsCommonValuesZero(Character ch) {
assertThat(this.converter.convert(ch, int.class))
.isSameAs(CommonValues.INTEGER_ZERO);
}
}
Loading

0 comments on commit 65e515a

Please sign in to comment.