File tree Expand file tree Collapse file tree 1 file changed +43
-5
lines changed
firebase-ai/src/test/java/com/google/firebase/ai Expand file tree Collapse file tree 1 file changed +43
-5
lines changed Original file line number Diff line number Diff line change @@ -220,9 +220,15 @@ internal class SchemaTests {
220
220
}
221
221
222
222
enum class TestEnum {
223
- BASIC ,
224
- INTERMEDIATE ,
225
- ADVANCED
223
+ RED ,
224
+ GREEN ,
225
+ BLUE
226
+ }
227
+
228
+ enum class TestEnumWithValues (val someValue : String ) {
229
+ RED (" FF0000" ),
230
+ GREEN (" 00FF00" ),
231
+ BLUE (" 0000FF" )
226
232
}
227
233
228
234
@Test
@@ -233,7 +239,7 @@ internal class SchemaTests {
233
239
{
234
240
"type": "STRING",
235
241
"format": "enum",
236
- "enum": ["BASIC ", "INTERMEDIATE ", "ADVANCED "]
242
+ "enum": ["RED ", "GREEN ", "BLUE "]
237
243
}
238
244
"""
239
245
.trimIndent()
@@ -249,7 +255,39 @@ internal class SchemaTests {
249
255
{
250
256
"type": "STRING",
251
257
"format": "enum",
252
- "enum": ["BASIC", "INTERMEDIATE", "ADVANCED"]
258
+ "enum": ["RED", "GREEN", "BLUE"]
259
+ }
260
+ """
261
+ .trimIndent()
262
+
263
+ Json .encodeToString(schema.toInternal()).shouldEqualJson(expectedJson)
264
+ }
265
+
266
+ @Test
267
+ fun `Kotlin enum with values` () {
268
+ val schema = Schema .fromEnum<TestEnumWithValues >()
269
+ val expectedJson =
270
+ """
271
+ {
272
+ "type": "STRING",
273
+ "format": "enum",
274
+ "enum": ["RED", "GREEN", "BLUE"]
275
+ }
276
+ """
277
+ .trimIndent()
278
+
279
+ Json .encodeToString(schema.toInternal()).shouldEqualJson(expectedJson)
280
+ }
281
+
282
+ @Test
283
+ fun `Java enum with values` () {
284
+ val schema = Schema .fromEnum(TestEnumWithValues ::class .java)
285
+ val expectedJson =
286
+ """
287
+ {
288
+ "type": "STRING",
289
+ "format": "enum",
290
+ "enum": ["RED", "GREEN", "BLUE"]
253
291
}
254
292
"""
255
293
.trimIndent()
You can’t perform that action at this time.
0 commit comments