This repository has been archived by the owner on Oct 23, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
int/long/float/double field support empty string, bug fixed for issue #…
- Loading branch information
Showing
3 changed files
with
110 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
90 changes: 90 additions & 0 deletions
90
src/test/java/com/alibaba/json/bvt/bug/Bug_for_issue_479.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
package com.alibaba.json.bvt.bug; | ||
|
||
import org.junit.Assert; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
|
||
import junit.framework.TestCase; | ||
|
||
public class Bug_for_issue_479 extends TestCase { | ||
|
||
public void test_for_issue_blankinput() throws Exception { | ||
VO vo = JSON.parseObject("", VO.class); | ||
Assert.assertNull(vo); | ||
} | ||
|
||
public void test_for_issue() throws Exception { | ||
VO vo = JSON.parseObject("{\"doubleParam\":\"\",\"floatParam\":\"\",\"intParam\":\"\",\"longParam\":\"\"}", | ||
VO.class); | ||
Assert.assertTrue(vo.doubleParam == 0); | ||
Assert.assertTrue(vo.floatParam == 0); | ||
Assert.assertTrue(vo.intParam == 0); | ||
Assert.assertTrue(vo.longParam == 0); | ||
} | ||
|
||
public void test_for_issue_private() throws Exception { | ||
V1 vo = JSON.parseObject("{\"doubleParam\":\"\",\"floatParam\":\"\",\"intParam\":\"\",\"longParam\":\"\"}", | ||
V1.class); | ||
Assert.assertTrue(vo.doubleParam == 0); | ||
Assert.assertTrue(vo.floatParam == 0); | ||
Assert.assertTrue(vo.intParam == 0); | ||
Assert.assertTrue(vo.longParam == 0); | ||
} | ||
|
||
public static class VO { | ||
|
||
public long doubleParam; | ||
public float floatParam; | ||
public int intParam; | ||
public long longParam; | ||
} | ||
|
||
private static class V1 { | ||
|
||
public long doubleParam; | ||
public float floatParam; | ||
public int intParam; | ||
public long longParam; | ||
} | ||
|
||
public static class V2 { | ||
|
||
private long doubleParam; | ||
private float floatParam; | ||
private int intParam; | ||
private long longParam; | ||
|
||
public long getDoubleParam() { | ||
return doubleParam; | ||
} | ||
|
||
public void setDoubleParam(long doubleParam) { | ||
this.doubleParam = doubleParam; | ||
} | ||
|
||
public float getFloatParam() { | ||
return floatParam; | ||
} | ||
|
||
public void setFloatParam(float floatParam) { | ||
this.floatParam = floatParam; | ||
} | ||
|
||
public int getIntParam() { | ||
return intParam; | ||
} | ||
|
||
public void setIntParam(int intParam) { | ||
this.intParam = intParam; | ||
} | ||
|
||
public long getLongParam() { | ||
return longParam; | ||
} | ||
|
||
public void setLongParam(long longParam) { | ||
this.longParam = longParam; | ||
} | ||
|
||
} | ||
} |