+
Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions boon/src/test/java/org/boon/bugs/Bug372.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
package org.boon.bugs;

import static junit.framework.Assert.fail;

import java.util.Map;

import org.boon.json.JsonException;
import org.boon.json.implementation.JsonFastParser;
import org.junit.Test;

/**
* Created by michele vivoda on 26/3/2017
*/
public class Bug372 {


@Test
public void testJsonNumberError_DotZero()
{
// http://deron.meranda.us/python/comparing_json_modules/numbers#t5-3
assertInvalidNumber(".0");

}
@Test
public void testJsonNumberError_ZeroDot()
{
assertInvalidNumber("0.");

}
@Test
public void testJsonNumberError_PlusZero()
{
assertInvalidNumber("+0");

}
@Test
public void testJsonNumberError_034()
{
assertInvalidNumber("034");
assertInvalidNumber("-034");

}
@Test
public void testJsonNumberError_Minus()
{
// a new one, for line 834 CharScanner
// if (negative) {
// num = (digitChars[ offset ] - '0');
// gives -77 because 77 is '{' - '0'

assertInvalidNumber("-");

}

private void assertInvalidNumber(String numberLexical)
{
try
{
final String json = "{\"a\": " + numberLexical + "}";
Map o = (Map) new JsonFastParser().parse(json);
Object jn = (Object) o.get("a");
if (jn==null) fail("did not fail but return null");
else fail("Did not fail, returned " + jn + " - " + jn.getClass().getName());
}
catch(JsonException e)
{
// ok
}

}

}
点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载