Skip to content

Commit

Permalink
Expand tests for array to Collection/Set/List interface
Browse files Browse the repository at this point in the history
  • Loading branch information
jhoeller committed Jul 5, 2023
1 parent a3907a6 commit d5380b3
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2002-2022 the original author or authors.
* Copyright 2002-2023 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -342,10 +342,20 @@ void characterToNumber() {

@Test
void convertArrayToCollectionInterface() {
Collection<?> result = conversionService.convert(new String[] {"1", "2", "3"}, Collection.class);
assertThat(result).isEqualTo(new LinkedHashSet<>(Arrays.asList("1", "2", "3")));
}

@Test
void convertArrayToSetInterface() {
Collection<?> result = conversionService.convert(new String[] {"1", "2", "3"}, Set.class);
assertThat(result).isEqualTo(new LinkedHashSet<>(Arrays.asList("1", "2", "3")));
}

@Test
void convertArrayToListInterface() {
List<?> result = conversionService.convert(new String[] {"1", "2", "3"}, List.class);
assertThat(result.get(0)).isEqualTo("1");
assertThat(result.get(1)).isEqualTo("2");
assertThat(result.get(2)).isEqualTo("3");
assertThat(result).isEqualTo(Arrays.asList("1", "2", "3"));
}

@Test
Expand Down

0 comments on commit d5380b3

Please sign in to comment.