package org.codefx.demo.junit5.parameterized;

import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.CsvSource;
import org.junit.jupiter.params.provider.ValueSource;

import java.time.LocalDateTime;
import java.time.Year;

import static org.junit.jupiter.api.Assertions.assertNotNull;

public class ArgumentConverterTest {

	@ParameterizedTest
	@ValueSource(strings = { "x" })
	void testSimpleCharConversion(char c) {
		assertNotNull(c);
	}

	@ParameterizedTest
	@ValueSource(strings = { "☺️" })
	void testUtfCharConversion_errors(char c) {
		assertNotNull(c);
	}

	@ParameterizedTest
	@CsvSource({ "true, 3.14159265359, JUNE, 2017, 2017-06-21T22:00:00" })
	void testDefaultConverters(
			boolean b, double d, Summer s, Year y, LocalDateTime dt) {
	}

	enum Summer {
		JUNE, JULY, AUGUST, SEPTEMBER;
	}

}

@@ -40,16 +40,95 @@
 rized;%0A%0A
+import org.codefx.demo.junit5.parameterized.CustomArgumentConverterTest.Point;%0A
 import o
@@ -170,16 +170,16 @@
 edTest;%0A
-
 import o
@@ -333,16 +333,77 @@
 .Year;%0A%0A
+import static org.junit.jupiter.api.Assertions.assertEquals;%0A
 import s
@@ -938,16 +938,16 @@
 ummer %7B%0A
-
 %09%09JUNE, 
@@ -975,10 +975,1097 @@
 ER;%0A%09%7D%0A%0A
+%09@ParameterizedTest%0A%09@ValueSource(strings = %7B %22x%EF%B8%8F%22 %7D)%0A%09void testTypeWithOneFactory(TypeWithOneFactory o) %7B%0A%09%09assertNotNull(o);%0A%09%7D%0A%0A%09static class TypeWithOneFactory %7B%0A%0A%09%09static TypeWithOneFactory of(String s) %7B%0A%09%09%09return new TypeWithOneFactory();%0A%09%09%7D%0A%0A%09%7D%0A%0A%09@ParameterizedTest%0A%09@ValueSource(strings = %7B %22x%EF%B8%8F%22 %7D)%0A%09void testTypeWithTwoFactories_constructorCalled(TypeWithTwoFactories o) %7B%0A%09%09assertNotNull(o);%0A%09%7D%0A%0A%09static class TypeWithTwoFactories %7B%0A%0A%09%09TypeWithTwoFactories(String s) %7B%0A%09%09%09System.out.println(%22Constructor called with %22 + s);%0A%09%09%7D%0A%0A%09%09static TypeWithTwoFactories of(String s) %7B%0A%09%09%09System.out.println(%22Factory %60of%60 called with %22 + s);%0A%09%09%09return new TypeWithTwoFactories(s);%0A%09%09%7D%0A%0A%09%09static TypeWithTwoFactories from(String s) %7B%0A%09%09%09System.out.println(%22Factory %60from%60 called with %22 + s);%0A%09%09%09return new TypeWithTwoFactories(s);%0A%09%09%7D%0A%0A%09%7D%0A%0A%09@ParameterizedTest%0A%09@CsvSource(%7B %22(0/0), 0%22, %22(0/1), 1%22, %22(1/0), 1%22, %22(1/1), 1.414%22, %22(2/1), 2.236%22 %7D)%0A%09// works because Point::from is suitable factory%0A%09void testPointNorm(Point point, double norm) %7B%0A%09%09assertEquals(norm, point.norm(), 0.01);%0A%09%7D%0A%0A
 %7D%0A

Use default factories for argument conversion