add a test case for an enum implementing JSONString

This commit is contained in:
Simulant
2024-02-25 09:45:57 +01:00
parent 77c899d325
commit d17bbbd417

View File

@@ -319,6 +319,22 @@ public class JSONStringTest {
} }
} }
@Test
public void testEnumJSONString() {
JSONObject jsonObject = new JSONObject();
jsonObject.put("key", MyEnum.MY_ENUM);
assertEquals("{\"key\":\"myJsonString\"}", jsonObject.toString());
}
private enum MyEnum implements JSONString {
MY_ENUM;
@Override
public String toJSONString() {
return "\"myJsonString\"";
}
}
/** /**
* A JSONString that returns a valid JSON string value. * A JSONString that returns a valid JSON string value.
*/ */