File tree Expand file tree Collapse file tree
java-examples/java-core/src/test/java/com/hellokoding/java/collections Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11package com .hellokoding .java .collections ;
22
3+ import org .junit .Test ;
4+
35import java .util .Arrays ;
46import java .util .HashSet ;
57import java .util .List ;
68import java .util .Set ;
79
810import static org .assertj .core .api .Assertions .assertThat ;
911
10- public class HashSetInitializeExample {
11- void initializeInMultipleLines () {
12+ public class HashSetInitializeTest {
13+ @ Test
14+ public void initializeInMultipleLines () {
1215 // Create a new HashSet
1316 Set <Integer > set = new HashSet <>();
1417
@@ -28,7 +31,8 @@ void initializeInMultipleLines() {
2831 System .out .println (set );
2932 }
3033
31- void initializeInOneLine () {
34+ @ Test
35+ public void initializeInOneLine () {
3236 // Create a new HashSet
3337 Set <Integer > set = new HashSet <>(){{
3438 add (3 );
@@ -42,7 +46,8 @@ void initializeInOneLine() {
4246 System .out .println (set );
4347 }
4448
45- void initializeByAddAll () {
49+ @ Test
50+ public void initializeByAddAll () {
4651 // Create a new HashSet
4752 Set <Integer > set = new HashSet <>();
4853
@@ -58,7 +63,8 @@ void initializeByAddAll() {
5863 System .out .println (set );
5964 }
6065
61- void initializeFromAnotherCollectionWhenCreating () {
66+ @ Test
67+ public void initializeFromAnotherCollectionWhenCreating () {
6268 // create and initialize a HashSet from Java 9+ List.of
6369 Set <Integer > set1 = new HashSet <>(List .of (3 , 1 , 2 ));
6470 assertThat (set1 ).hasSize (3 );
You can’t perform that action at this time.
0 commit comments