forked from loafle/openapi-generator-original
		
	Support CommaSeparatedTuples including commas (#14535)
* Test parsing CSV values including commas * Remove commented line
This commit is contained in:
		
							parent
							
								
									0e0cddacac
								
							
						
					
					
						commit
						6095d2df75
					
				@ -52,6 +52,10 @@ public class OptionUtilsTest {
 | 
			
		||||
        doTupleListTest("a=1,=,c=3", asList(Pair.of("a", "1"), Pair.of("c", "3")));
 | 
			
		||||
        doTupleListTest("", emptyPairList());
 | 
			
		||||
        doTupleListTest(null, emptyPairList());
 | 
			
		||||
        doTupleListTest("a=1,b=2,c=\"3,4,5\"",
 | 
			
		||||
                asList(Pair.of("a", "1"), Pair.of("b", "2"),
 | 
			
		||||
                        Pair.of("c", "\"3,4,5\"")));
 | 
			
		||||
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static void doTupleListTest(String input, List<Pair<String, String>> expectedResults) {
 | 
			
		||||
 | 
			
		||||
@ -51,7 +51,8 @@ public class OptionUtils {
 | 
			
		||||
        List<String> results = new ArrayList<String>();
 | 
			
		||||
 | 
			
		||||
        if(input != null && !input.isEmpty()) {
 | 
			
		||||
            for (String value : input.split(",")) {
 | 
			
		||||
            String[] tokens = input.split(",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)", -1);
 | 
			
		||||
            for (String value : tokens) {
 | 
			
		||||
                if(isNotEmpty(value))
 | 
			
		||||
                results.add(value);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user