Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

parameterized tests #93

Merged
merged 1 commit into from
Feb 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading