File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
main/java/com/fasterxml/jackson/core/format
test/java/com/fasterxml/jackson/core/format Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -91,7 +91,7 @@ public MatchStrength getMatchStrength() {
9191 *</pre>
9292 */
9393 public String getMatchedFormatName () {
94- return _match .getFormatName ();
94+ return hasMatch () ? getMatch () .getFormatName () : null ;
9595 }
9696
9797 /*
Original file line number Diff line number Diff line change @@ -35,4 +35,24 @@ public void testCreatesDataFormatMatcherTwo() throws IOException {
3535 verifyException (e , "Illegal start/length" );
3636 }
3737 }
38+
39+ public void testGetMatchedFormatNameReturnsNameWhenMatches () {
40+ DataFormatMatcher dataFormatMatcher = new DataFormatMatcher (null ,
41+ new byte [2 ],
42+ 1 ,
43+ 0 ,
44+ new JsonFactory (),
45+ MatchStrength .SOLID_MATCH );
46+ assertEquals (JsonFactory .FORMAT_NAME_JSON , dataFormatMatcher .getMatchedFormatName ());
47+ }
48+
49+ public void testGetMatchedFormatNameReturnsNullWhenNoMatch () {
50+ DataFormatMatcher dataFormatMatcher = new DataFormatMatcher (null ,
51+ new byte [2 ],
52+ 1 ,
53+ 0 ,
54+ null ,
55+ MatchStrength .NO_MATCH );
56+ assertNull (dataFormatMatcher .getMatchedFormatName ());
57+ }
3858}
You can’t perform that action at this time.
0 commit comments