Permalink
Browse files

Removed duplicated function. Added test for trailing whitespaces/non-…

…whitespaces.
  • Loading branch information...
1 parent 8bda5ad commit 33d4bce0529f7d2c6c9ad94f202f7a74235d4ff5 @Xorcerer Xorcerer committed Oct 17, 2012
Showing with 16 additions and 9 deletions.
  1. +1 −7 lib/ultrajsondec.c
  2. +15 −2 tests/tests.py
View
@@ -830,12 +830,6 @@ FASTCALL_ATTR JSOBJ FASTCALL_MSVC decode_any(struct DecoderState *ds)
}
}
-static void skip_whitespace_and_carriage_return(struct DecoderState *ds)
-{
- while (ds->start != ds->end && (*ds->start == '\n' || *ds->start == ' '))
- ds->start ++;
-}
-
JSOBJ JSON_DecodeObject(JSONObjectDecoder *dec, const char *buffer, size_t cbBuffer)
{
@@ -864,7 +858,7 @@ JSOBJ JSON_DecodeObject(JSONObjectDecoder *dec, const char *buffer, size_t cbBuf
dec->free(ds.escStart);
}
- skip_whitespace_and_carriage_return(&ds);
+ SkipWhitespace(&ds);
if (ds.start != ds.end && ret)
{
View
@@ -788,7 +788,20 @@ def test_decodeVeryTooSmallValue(self):
pass
else:
assert False, "expected ValueError"
-
+
+ def test_decodeWithTrailingWhitespaces(self):
+ input = "{}\n\t "
+ ujson.decode(input)
+
+ def test_decodeWithTrailingNonWhitespaces(self):
+ try:
+ input = "{}\n\t a"
+ ujson.decode(input)
+ except ValueError:
+ pass
+ else:
+ assert False, "expected ValueError"
+
"""
def test_decodeNumericIntFrcOverflow(self):
input = "X.Y"
@@ -828,4 +841,4 @@ def test_decodeStringUTF8(self):
pass
heap = hp.heapu()
print heap
-"""
+"""

0 comments on commit 33d4bce

Please sign in to comment.