@@ -38,76 +38,136 @@ public void map_put(TagMapType mapType) {
3838 @ ParameterizedTest
3939 @ EnumSource (TagMapType .class )
4040 public void booleanEntry (TagMapType mapType ) {
41+ boolean first = false ;
42+ boolean second = true ;
43+
4144 TagMap map = mapType .create ();
42- map .set ("bool" , false );
45+ map .set ("bool" , first );
4346
44- TagMap .Entry entry = map .getEntry ("bool" );
47+ TagMap .Entry firstEntry = map .getEntry ("bool" );
4548 if (map .isOptimized ()) {
46- assertEquals (TagMap .Entry .BOOLEAN , entry .rawType );
49+ assertEquals (TagMap .Entry .BOOLEAN , firstEntry .rawType );
4750 }
4851
49- assertEquals (false , entry .booleanValue ());
50- assertEquals (false , map .getBoolean ("bool" ));
52+ assertEquals (first , firstEntry .booleanValue ());
53+ assertEquals (first , map .getBoolean ("bool" ));
54+
55+ TagMap .Entry priorEntry = map .getAndSet ("bool" , second );
56+ if (map .isOptimized ()) {
57+ assertSame (priorEntry , firstEntry );
58+ }
59+ assertEquals (first , priorEntry .booleanValue ());
60+
61+ TagMap .Entry newEntry = map .getEntry ("bool" );
62+ assertEquals (second , newEntry .booleanValue ());
5163 }
5264
5365 @ ParameterizedTest
5466 @ EnumSource (TagMapType .class )
5567 public void intEntry (TagMapType mapType ) {
68+ int first = 3142 ;
69+ int second = 2718 ;
70+
5671 TagMap map = mapType .create ();
57- map .set ("int" , 42 );
72+ map .set ("int" , first );
5873
59- TagMap .Entry entry = map .getEntry ("int" );
74+ TagMap .Entry firstEntry = map .getEntry ("int" );
6075 if (map .isOptimized ()) {
61- assertEquals (TagMap .Entry .INT , entry .rawType );
76+ assertEquals (TagMap .Entry .INT , firstEntry .rawType );
6277 }
6378
64- assertEquals (42 , entry .intValue ());
65- assertEquals (42 , map .getInt ("int" ));
79+ assertEquals (first , firstEntry .intValue ());
80+ assertEquals (first , map .getInt ("int" ));
81+
82+ TagMap .Entry priorEntry = map .getAndSet ("int" , second );
83+ if (map .isOptimized ()) {
84+ assertSame (priorEntry , firstEntry );
85+ }
86+ assertEquals (first , priorEntry .intValue ());
87+
88+ TagMap .Entry newEntry = map .getEntry ("int" );
89+ assertEquals (second , newEntry .intValue ());
6690 }
6791
6892 @ ParameterizedTest
6993 @ EnumSource (TagMapType .class )
7094 public void longEntry (TagMapType mapType ) {
95+ long first = 3142L ;
96+ long second = 2718L ;
97+
7198 TagMap map = mapType .create ();
72- map .set ("long" , 42L );
99+ map .set ("long" , first );
73100
74- TagMap .Entry entry = map .getEntry ("long" );
101+ TagMap .Entry firstEntry = map .getEntry ("long" );
75102 if (map .isOptimized ()) {
76- assertEquals (TagMap .Entry .LONG , entry .rawType );
103+ assertEquals (TagMap .Entry .LONG , firstEntry .rawType );
77104 }
78105
79- assertEquals (42L , entry .longValue ());
80- assertEquals (42L , map .getLong ("long" ));
106+ assertEquals (first , firstEntry .longValue ());
107+ assertEquals (first , map .getLong ("long" ));
108+
109+ TagMap .Entry priorEntry = map .getAndSet ("long" , second );
110+ if (map .isOptimized ()) {
111+ assertSame (priorEntry , firstEntry );
112+ }
113+ assertEquals (first , priorEntry .longValue ());
114+
115+ TagMap .Entry newEntry = map .getEntry ("long" );
116+ assertEquals (second , newEntry .longValue ());
81117 }
82118
83119 @ ParameterizedTest
84120 @ EnumSource (TagMapType .class )
85121 public void floatEntry (TagMapType mapType ) {
122+ float first = 3.14F ;
123+ float second = 2.718F ;
124+
86125 TagMap map = mapType .create ();
87- map .set ("float" , 3.14F );
126+ map .set ("float" , first );
127+
128+ TagMap .Entry firstEntry = map .getEntry ("float" );
129+ if (map .isOptimized ()) {
130+ assertEquals (TagMap .Entry .FLOAT , firstEntry .rawType );
131+ }
88132
89- TagMap .Entry entry = map .getEntry ("float" );
133+ assertEquals (first , firstEntry .floatValue ());
134+ assertEquals (first , map .getFloat ("float" ));
135+
136+ TagMap .Entry priorEntry = map .getAndSet ("float" , second );
90137 if (map .isOptimized ()) {
91- assertEquals ( TagMap . Entry . FLOAT , entry . rawType );
138+ assertSame ( priorEntry , firstEntry );
92139 }
140+ assertEquals (first , priorEntry .floatValue ());
93141
94- assertEquals ( 3.14F , entry . floatValue () );
95- assertEquals (3.14F , map . getFloat ( "float" ));
142+ TagMap . Entry newEntry = map . getEntry ( "float" );
143+ assertEquals (second , newEntry . floatValue ( ));
96144 }
97145
98146 @ ParameterizedTest
99147 @ EnumSource (TagMapType .class )
100148 public void doubleEntry (TagMapType mapType ) {
149+ double first = Math .PI ;
150+ double second = Math .E ;
151+
101152 TagMap map = mapType .create ();
102153 map .set ("double" , Math .PI );
103154
104- TagMap .Entry entry = map .getEntry ("double" );
155+ TagMap .Entry firstEntry = map .getEntry ("double" );
156+ if (map .isOptimized ()) {
157+ assertEquals (TagMap .Entry .DOUBLE , firstEntry .rawType );
158+ }
159+
160+ assertEquals (first , firstEntry .doubleValue ());
161+ assertEquals (first , map .getDouble ("double" ));
162+
163+ TagMap .Entry priorEntry = map .getAndSet ("double" , second );
105164 if (map .isOptimized ()) {
106- assertEquals ( TagMap . Entry . DOUBLE , entry . rawType );
165+ assertSame ( priorEntry , firstEntry );
107166 }
167+ assertEquals (first , priorEntry .doubleValue ());
108168
109- assertEquals ( Math . PI , entry . doubleValue () );
110- assertEquals (Math . PI , map . getDouble ( "double" ));
169+ TagMap . Entry newEntry = map . getEntry ( "double" );
170+ assertEquals (second , newEntry . doubleValue ( ));
111171 }
112172
113173 @ ParameterizedTest
0 commit comments