@@ -62,11 +62,15 @@ public static Iterable<Object[]> featureSets() {
62
62
.addLine ("public interface DataType {" )
63
63
.addLine (" int propertyA();" )
64
64
.addLine (" boolean propertyB();" )
65
+ .addLine (" String propertyC();" )
66
+ .addLine (" double propertyD();" )
65
67
.addLine ("" )
66
68
.addLine (" class Builder extends DataType_Builder {" )
67
69
.addLine (" public Builder() {" )
68
70
.addLine (" propertyA(0);" )
69
71
.addLine (" propertyB(false);" )
72
+ .addLine (" propertyC(\" default\" );" )
73
+ .addLine (" propertyD(Double.NaN);" )
70
74
.addLine (" }" )
71
75
.addLine (" }" )
72
76
.addLine ("}" )
@@ -82,12 +86,16 @@ public static Iterable<Object[]> featureSets() {
82
86
.addLine ("public interface DataType {" )
83
87
.addLine (" int propertyA();" )
84
88
.addLine (" boolean propertyB();" )
89
+ .addLine (" String propertyC();" )
90
+ .addLine (" double propertyD();" )
85
91
.addLine ("" )
86
92
.addLine (" class Builder extends DataType_Builder {" )
87
93
.addLine (" public Builder() {" )
88
94
.addLine (" if (true) { // Disable optimization in javac" )
89
95
.addLine (" propertyA(0);" )
90
96
.addLine (" propertyB(false);" )
97
+ .addLine (" propertyC(\" default\" );" )
98
+ .addLine (" propertyD(Double.NaN);" )
91
99
.addLine (" }" )
92
100
.addLine (" }" )
93
101
.addLine (" }" )
@@ -108,10 +116,14 @@ public void testMergeFromBuilder_defaultsDoNotOverride() {
108
116
.addLine ("DataType value = new DataType.Builder()" )
109
117
.addLine (" .propertyA(11)" )
110
118
.addLine (" .propertyB(true)" )
119
+ .addLine (" .propertyC(\" hello\" )" )
120
+ .addLine (" .propertyD(3.2)" )
111
121
.addLine (" .mergeFrom(new DataType.Builder())" )
112
122
.addLine (" .build();" )
113
123
.addLine ("assertEquals(11, value.propertyA());" )
114
124
.addLine ("assertTrue(value.propertyB());" )
125
+ .addLine ("assertEquals(\" hello\" , value.propertyC());" )
126
+ .addLine ("assertEquals(3.2, value.propertyD(), 0.0001);" )
115
127
.build ())
116
128
.runTest ();
117
129
}
@@ -125,10 +137,14 @@ public void testMergeFromValue_defaultsDoNotOverride() {
125
137
.addLine ("DataType value = new DataType.Builder()" )
126
138
.addLine (" .propertyA(11)" )
127
139
.addLine (" .propertyB(true)" )
140
+ .addLine (" .propertyC(\" hello\" )" )
141
+ .addLine (" .propertyD(3.2)" )
128
142
.addLine (" .mergeFrom(new DataType.Builder().build())" )
129
143
.addLine (" .build();" )
130
144
.addLine ("assertEquals(11, value.propertyA());" )
131
145
.addLine ("assertTrue(value.propertyB());" )
146
+ .addLine ("assertEquals(\" hello\" , value.propertyC());" )
147
+ .addLine ("assertEquals(3.2, value.propertyD(), 0.0001);" )
132
148
.build ())
133
149
.runTest ();
134
150
}
@@ -143,9 +159,13 @@ public void testMergeFromBuilder_nonDefaultsUsed() {
143
159
.addLine (" .propertyB(true)" )
144
160
.addLine (" .mergeFrom(new DataType.Builder())" )
145
161
.addLine (" .propertyA(13)" )
162
+ .addLine (" .propertyC(\" hello\" )" )
163
+ .addLine (" .propertyD(3.2)" )
146
164
.addLine (" .build();" )
147
165
.addLine ("assertEquals(13, value.propertyA());" )
148
166
.addLine ("assertTrue(value.propertyB());" )
167
+ .addLine ("assertEquals(\" hello\" , value.propertyC());" )
168
+ .addLine ("assertEquals(3.2, value.propertyD(), 0.0001);" )
149
169
.build ())
150
170
.runTest ();
151
171
}
@@ -160,10 +180,14 @@ public void testMergeFromValue_nonDefaultsUsed() {
160
180
.addLine (" .propertyB(true)" )
161
181
.addLine (" .mergeFrom(new DataType.Builder()" )
162
182
.addLine (" .propertyA(13)" )
183
+ .addLine (" .propertyC(\" hello\" )" )
184
+ .addLine (" .propertyD(3.2)" )
163
185
.addLine (" .build())" )
164
186
.addLine (" .build();" )
165
187
.addLine ("assertEquals(13, value.propertyA());" )
166
188
.addLine ("assertTrue(value.propertyB());" )
189
+ .addLine ("assertEquals(\" hello\" , value.propertyC());" )
190
+ .addLine ("assertEquals(3.2, value.propertyD(), 0.0001);" )
167
191
.build ())
168
192
.runTest ();
169
193
}
@@ -177,11 +201,17 @@ public void testMergeFromBuilder_nonDefaultsOverride() {
177
201
.addLine ("DataType value = new DataType.Builder()" )
178
202
.addLine (" .propertyA(11)" )
179
203
.addLine (" .propertyB(true)" )
204
+ .addLine (" .propertyC(\" hello\" )" )
205
+ .addLine (" .propertyD(1.9)" )
180
206
.addLine (" .mergeFrom(new DataType.Builder())" )
181
207
.addLine (" .propertyA(13)" )
208
+ .addLine (" .propertyC(\" goodbye\" )" )
209
+ .addLine (" .propertyD(3.2)" )
182
210
.addLine (" .build();" )
183
211
.addLine ("assertEquals(13, value.propertyA());" )
184
212
.addLine ("assertTrue(value.propertyB());" )
213
+ .addLine ("assertEquals(\" goodbye\" , value.propertyC());" )
214
+ .addLine ("assertEquals(3.2, value.propertyD(), 0.0001);" )
185
215
.build ())
186
216
.runTest ();
187
217
}
@@ -195,12 +225,18 @@ public void testMergeFromValue_nonDefaultsOverride() {
195
225
.addLine ("DataType value = new DataType.Builder()" )
196
226
.addLine (" .propertyA(11)" )
197
227
.addLine (" .propertyB(true)" )
228
+ .addLine (" .propertyC(\" hello\" )" )
229
+ .addLine (" .propertyD(1.9)" )
198
230
.addLine (" .mergeFrom(new DataType.Builder()" )
199
231
.addLine (" .propertyA(13)" )
232
+ .addLine (" .propertyC(\" goodbye\" )" )
233
+ .addLine (" .propertyD(3.2)" )
200
234
.addLine (" .build())" )
201
235
.addLine (" .build();" )
202
236
.addLine ("assertEquals(13, value.propertyA());" )
203
237
.addLine ("assertTrue(value.propertyB());" )
238
+ .addLine ("assertEquals(\" goodbye\" , value.propertyC());" )
239
+ .addLine ("assertEquals(3.2, value.propertyD(), 0.0001);" )
204
240
.build ())
205
241
.runTest ();
206
242
}
@@ -214,10 +250,14 @@ public void testClear() {
214
250
.addLine ("DataType value = new DataType.Builder()" )
215
251
.addLine (" .propertyA(11)" )
216
252
.addLine (" .propertyB(true)" )
253
+ .addLine (" .propertyC(\" hello\" )" )
254
+ .addLine (" .propertyD(1.9)" )
217
255
.addLine (" .clear()" )
218
256
.addLine (" .build();" )
219
257
.addLine ("assertEquals(0, value.propertyA());" )
220
258
.addLine ("assertFalse(value.propertyB());" )
259
+ .addLine ("assertEquals(\" default\" , value.propertyC());" )
260
+ .addLine ("assertEquals(Double.NaN, value.propertyD(), 0.0001);" )
221
261
.build ())
222
262
.runTest ();
223
263
}
0 commit comments