/src/test/java/com/alibaba/json/bvt/TypeUtilstTest.java

https://github.com/flydream/fastjson · Java · 233 lines · 169 code · 48 blank · 16 comment · 0 complexity · f9690fe71dbca7bc81f25af76996711b MD5 · raw file

  1. /*
  2. * Copyright 1999-2101 Alibaba Group.
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.alibaba.json.bvt;
  17. import java.math.BigDecimal;
  18. import java.math.BigInteger;
  19. import java.util.ArrayList;
  20. import java.util.Date;
  21. import java.util.List;
  22. import junit.framework.TestCase;
  23. import com.alibaba.fastjson.JSON;
  24. public class TypeUtilstTest extends TestCase {
  25. public void test_0() throws Exception {
  26. List<Person> personList = new ArrayList<Person>();
  27. {
  28. Person p = new Person();
  29. p.setF1(true);
  30. p.setF2(true);
  31. p.setF3((byte) 3);
  32. p.setF4((byte) 4);
  33. p.setF5((short) 5);
  34. p.setF6((short) 6);
  35. p.setF7(7);
  36. p.setF8(8);
  37. p.setF9(9L);
  38. p.setF10(10L);
  39. p.setF11(new BigInteger("12345678901234567890123456789012345678901234567890"));
  40. p.setF12(new BigDecimal("1234567890123456789012345678901234567890.1234567890"));
  41. p.setF13("F13");
  42. p.setF14(new Date());
  43. p.setF15(15);
  44. p.setF16(16F);
  45. p.setF17(17);
  46. p.setF18(18D);
  47. personList.add(p);
  48. }
  49. {
  50. Person person = new Person();
  51. personList.add(person);
  52. }
  53. String jsonString = JSON.toJSONString(personList);
  54. JSON.parseArray(jsonString, Person.class);
  55. // CGLibExtJSONParser parser = new CGLibExtJSONParser(text);
  56. }
  57. public static class Person {
  58. private boolean f1;
  59. private Boolean f2;
  60. private byte f3;
  61. private Byte f4;
  62. private short f5;
  63. private Short f6;
  64. private int f7;
  65. private Integer f8;
  66. private long f9;
  67. private Long f10;
  68. private BigInteger f11;
  69. private BigDecimal f12;
  70. private String f13;
  71. private Date f14;
  72. private float f15;
  73. private Float f16;
  74. private double f17;
  75. private Double f18;
  76. public boolean isF1() {
  77. return f1;
  78. }
  79. public void setF1(boolean f1) {
  80. this.f1 = f1;
  81. }
  82. public Boolean getF2() {
  83. return f2;
  84. }
  85. public void setF2(Boolean f2) {
  86. this.f2 = f2;
  87. }
  88. public byte getF3() {
  89. return f3;
  90. }
  91. public void setF3(byte f3) {
  92. this.f3 = f3;
  93. }
  94. public Byte getF4() {
  95. return f4;
  96. }
  97. public void setF4(Byte f4) {
  98. this.f4 = f4;
  99. }
  100. public short getF5() {
  101. return f5;
  102. }
  103. public void setF5(short f5) {
  104. this.f5 = f5;
  105. }
  106. public Short getF6() {
  107. return f6;
  108. }
  109. public void setF6(Short f6) {
  110. this.f6 = f6;
  111. }
  112. public int getF7() {
  113. return f7;
  114. }
  115. public void setF7(int f7) {
  116. this.f7 = f7;
  117. }
  118. public Integer getF8() {
  119. return f8;
  120. }
  121. public void setF8(Integer f8) {
  122. this.f8 = f8;
  123. }
  124. public long getF9() {
  125. return f9;
  126. }
  127. public void setF9(long f9) {
  128. this.f9 = f9;
  129. }
  130. public Long getF10() {
  131. return f10;
  132. }
  133. public void setF10(Long f10) {
  134. this.f10 = f10;
  135. }
  136. public BigInteger getF11() {
  137. return f11;
  138. }
  139. public void setF11(BigInteger f11) {
  140. this.f11 = f11;
  141. }
  142. public BigDecimal getF12() {
  143. return f12;
  144. }
  145. public void setF12(BigDecimal f12) {
  146. this.f12 = f12;
  147. }
  148. public String getF13() {
  149. return f13;
  150. }
  151. public void setF13(String f13) {
  152. this.f13 = f13;
  153. }
  154. public Date getF14() {
  155. return f14;
  156. }
  157. public void setF14(Date f14) {
  158. this.f14 = f14;
  159. }
  160. public float getF15() {
  161. return f15;
  162. }
  163. public void setF15(float f15) {
  164. this.f15 = f15;
  165. }
  166. public Float getF16() {
  167. return f16;
  168. }
  169. public void setF16(Float f16) {
  170. this.f16 = f16;
  171. }
  172. public double getF17() {
  173. return f17;
  174. }
  175. public void setF17(double f17) {
  176. this.f17 = f17;
  177. }
  178. public Double getF18() {
  179. return f18;
  180. }
  181. public void setF18(Double f18) {
  182. this.f18 = f18;
  183. }
  184. }
  185. }