/src/test/java/com/alibaba/json/bvt/parser/ParserSpecialCharTest.java

https://github.com/alibaba/fastjson · Java · 95 lines · 69 code · 26 blank · 0 comment · 0 complexity · f2cafb925c3d751d759df04058e0a8a9 MD5 · raw file

  1. package com.alibaba.json.bvt.parser;
  2. import junit.framework.TestCase;
  3. import org.junit.Assert;
  4. import com.alibaba.fastjson.JSON;
  5. public class ParserSpecialCharTest extends TestCase {
  6. public void test_0() throws Exception {
  7. Assert.assertEquals("\0", JSON.parseObject("{\"value\":\"\\0\"}", VO.class).getValue());
  8. }
  9. public void test_1() throws Exception {
  10. Assert.assertEquals("\1", JSON.parseObject("{\"value\":\"\\1\"}", VO.class).getValue());
  11. }
  12. public void test_2() throws Exception {
  13. Assert.assertEquals("\2", JSON.parseObject("{\"value\":\"\\2\"}", VO.class).getValue());
  14. }
  15. public void test_3() throws Exception {
  16. Assert.assertEquals("\3", JSON.parseObject("{\"value\":\"\\3\"}", VO.class).getValue());
  17. }
  18. public void test_4() throws Exception {
  19. Assert.assertEquals("\4", JSON.parseObject("{\"value\":\"\\4\"}", VO.class).getValue());
  20. }
  21. public void test_5() throws Exception {
  22. Assert.assertEquals("\5", JSON.parseObject("{\"value\":\"\\5\"}", VO.class).getValue());
  23. }
  24. public void test_6() throws Exception {
  25. Assert.assertEquals("\6", JSON.parseObject("{\"value\":\"\\6\"}", VO.class).getValue());
  26. }
  27. public void test_7() throws Exception {
  28. Assert.assertEquals("\7", JSON.parseObject("{\"value\":\"\\7\"}", VO.class).getValue());
  29. }
  30. public void test_8() throws Exception {
  31. Assert.assertEquals("\b", JSON.parseObject("{\"value\":\"\\b\"}", VO.class).getValue());
  32. }
  33. public void test_9() throws Exception {
  34. Assert.assertEquals("\t", JSON.parseObject("{\"value\":\"\\t\"}", VO.class).getValue());
  35. }
  36. public void test_10() throws Exception {
  37. Assert.assertEquals("\n", JSON.parseObject("{\"value\":\"\\n\"}", VO.class).getValue());
  38. }
  39. public void test_11() throws Exception {
  40. Assert.assertEquals("\u000B", JSON.parseObject("{\"value\":\"\\v\"}", VO.class).getValue());
  41. }
  42. public void test_12() throws Exception {
  43. Assert.assertEquals("\f", JSON.parseObject("{\"value\":\"\\f\"}", VO.class).getValue());
  44. }
  45. public void test_13() throws Exception {
  46. Assert.assertEquals("\r", JSON.parseObject("{\"value\":\"\\r\"}", VO.class).getValue());
  47. }
  48. public void test_34() throws Exception {
  49. Assert.assertEquals("\"", JSON.parseObject("{\"value\":\"\\\"\"}", VO.class).getValue());
  50. }
  51. public void test_39() throws Exception {
  52. Assert.assertEquals("'", JSON.parseObject("{\"value\":\"\\'\"}", VO.class).getValue());
  53. }
  54. public void test_47() throws Exception {
  55. Assert.assertEquals("/", JSON.parseObject("{\"value\":\"\\/\"}", VO.class).getValue());
  56. }
  57. public void test_92() throws Exception {
  58. Assert.assertEquals("\\", JSON.parseObject("{\"value\":\"\\\\\"}", VO.class).getValue());
  59. }
  60. public static class VO {
  61. private String value;
  62. public String getValue() {
  63. return value;
  64. }
  65. public void setValue(String value) {
  66. this.value = value;
  67. }
  68. }
  69. }