mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Tests: Removed JSON tests
This commit is contained in:
parent
3cf4f337e7
commit
dbb22f506d
25 changed files with 2 additions and 1043 deletions
1
test/.gitignore
vendored
1
test/.gitignore
vendored
|
@ -13,7 +13,6 @@ fs.t
|
|||
i18n.t
|
||||
iso8601d.t
|
||||
iso8601p.t
|
||||
json.t
|
||||
lexer.t
|
||||
list.t
|
||||
msg.t
|
||||
|
|
|
@ -14,9 +14,9 @@ include_directories (${CMAKE_SOURCE_DIR}
|
|||
${CMAKE_SOURCE_DIR}/test
|
||||
${TASK_INCLUDE_DIRS})
|
||||
|
||||
set (test_SRCS autocomplete.t col.t color.t config.t fs.t i18n.t json.t list.t
|
||||
set (test_SRCS autocomplete.t col.t color.t config.t fs.t i18n.t list.t
|
||||
msg.t nibbler.t t.t tdb2.t text.t utf8.t util.t view.t
|
||||
json_test lexer.t iso8601d.t iso8601p.t eval.t dates.t
|
||||
lexer.t iso8601d.t iso8601p.t eval.t dates.t
|
||||
variant_add.t variant_and.t variant_cast.t variant_divide.t
|
||||
variant_equal.t variant_exp.t variant_gt.t variant_gte.t
|
||||
variant_inequal.t variant_lt.t variant_lte.t variant_match.t
|
||||
|
|
189
test/json.t.cpp
189
test/json.t.cpp
|
@ -1,189 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2006 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <JSON.h>
|
||||
#include <test.h>
|
||||
#include <Context.h>
|
||||
|
||||
Context context;
|
||||
|
||||
const char *positive_tests[] =
|
||||
{
|
||||
"{}",
|
||||
|
||||
" { } ",
|
||||
|
||||
"[]",
|
||||
|
||||
"{\"one\":1}",
|
||||
|
||||
"{\n\"one\"\n:\n1\n}\n",
|
||||
|
||||
" { \"one\" : 1 } ",
|
||||
|
||||
"{\"name\":123, \"array\":[1,2,3.4], \"object\":{\"m1\":\"v1\", \"m2\":\"v2\"}}",
|
||||
|
||||
"{\"name\":\"value\",\"array\":[\"one\",\"two\"],\"object\":{\"name2\":123,\"literal\":false}}",
|
||||
|
||||
"{\n"
|
||||
"\"ticket\": { \"type\":\"add\", \"client\":\"taskwarrior 2.x\"},\n"
|
||||
"\"auth\": { \"user\":\"paul\", \"org\":\"gbf\", \"key\":\".........\",\n"
|
||||
" \"locale\":\"en-US\" },\n"
|
||||
"\n"
|
||||
"\"add\": { \"description\":\"Wash the dog\",\n"
|
||||
" \"project\":\"home\",\n"
|
||||
" \"due\":\"20101101T000000Z\" }\n"
|
||||
"}",
|
||||
|
||||
"{"
|
||||
"\"ticket\":{"
|
||||
"\"type\":\"synch\","
|
||||
"\"client\":\"taskd-test-suite 1.0\""
|
||||
"},"
|
||||
"\"synch\":{"
|
||||
"\"user\":{"
|
||||
"\"data\":["
|
||||
"{"
|
||||
"\"uuid\":\"11111111-1111-1111-1111-111111111111\","
|
||||
"\"status\":\"pending\","
|
||||
"\"description\":\"This is a test\","
|
||||
"\"entry\":\"20110111T124000Z\""
|
||||
"}"
|
||||
"],"
|
||||
"\"synch\":\"key\""
|
||||
"}"
|
||||
"},"
|
||||
"\"auth\":{"
|
||||
"\"org\":\"gbf\","
|
||||
"\"user\":\"Paul Beckingham\","
|
||||
"\"key\":\"K\","
|
||||
"\"locale\":\"en-US\""
|
||||
"}"
|
||||
"}"
|
||||
};
|
||||
|
||||
#define NUM_POSITIVE_TESTS (sizeof (positive_tests) / sizeof (positive_tests[0]))
|
||||
|
||||
const char *negative_tests[] =
|
||||
{
|
||||
"",
|
||||
"{",
|
||||
"}",
|
||||
"[",
|
||||
"]",
|
||||
"foo",
|
||||
"[?]"
|
||||
};
|
||||
|
||||
#define NUM_NEGATIVE_TESTS (sizeof (negative_tests) / sizeof (negative_tests[0]))
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int, char**)
|
||||
{
|
||||
UnitTest t (NUM_POSITIVE_TESTS + NUM_NEGATIVE_TESTS + 22);
|
||||
|
||||
// Ensure environment has no influence.
|
||||
unsetenv ("TASKDATA");
|
||||
unsetenv ("TASKRC");
|
||||
|
||||
// Positive tests.
|
||||
for (unsigned int i = 0; i < NUM_POSITIVE_TESTS; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
json::value* root = json::parse (positive_tests[i]);
|
||||
t.ok (root, std::string ("positive: ") + positive_tests[i]);
|
||||
if (root)
|
||||
{
|
||||
t.diag (root->dump ());
|
||||
delete root;
|
||||
}
|
||||
}
|
||||
|
||||
catch (const std::string& e) { t.diag (e); }
|
||||
catch (...) { t.diag ("Unknown error"); }
|
||||
}
|
||||
|
||||
// Negative tests.
|
||||
for (unsigned int i = 0; i < NUM_NEGATIVE_TESTS; ++i)
|
||||
{
|
||||
try
|
||||
{
|
||||
json::value* root = json::parse (negative_tests[i]);
|
||||
t.is ((const char*) root, (const char*) NULL,
|
||||
std::string ("negative: ") + negative_tests[i]);
|
||||
}
|
||||
|
||||
catch (const std::string& e) { t.pass (e); }
|
||||
catch (...) { t.fail ("Unknown error"); }
|
||||
}
|
||||
|
||||
// Other tests.
|
||||
try
|
||||
{
|
||||
// Regular unit tests.
|
||||
t.is (json::encode ("1\b2"), "1\\b2", "json::encode slashslashb -> slashslashslashslashb");
|
||||
t.is (json::decode ("1\\b2"), "1\b2", "json::decode slashslashslashslashb -> slashslashb");
|
||||
|
||||
t.is (json::encode ("1\n2"), "1\\n2", "json::encode slashslashn -> slashslashslashslashn");
|
||||
t.is (json::decode ("1\\n2"), "1\n2", "json::decode slashslashslashslashn -> slashslashn");
|
||||
|
||||
t.is (json::encode ("1\r2"), "1\\r2", "json::encode slashslashr -> slashslashslashslashr");
|
||||
t.is (json::decode ("1\\r2"), "1\r2", "json::decode slashslashslashslashr -> slashslashr");
|
||||
|
||||
t.is (json::encode ("1\t2"), "1\\t2", "json::encode slashslasht -> slashslashslashslasht");
|
||||
t.is (json::decode ("1\\t2"), "1\t2", "json::decode slashslashslashslasht -> slashslasht");
|
||||
|
||||
t.is (json::encode ("1\\2"), "1\\\\2", "json::encode slashslash -> slashslashslashslash");
|
||||
t.is (json::decode ("1\\\\2"), "1\\2", "json::decode slashslashslashslash -> slashslash");
|
||||
|
||||
t.is (json::encode ("1\x2"), "1\x2", "json::encode slashslashx -> slashslashx(NOP)");
|
||||
t.is (json::decode ("1\x2"), "1\x2", "json::decode slashslashx -> slashslashx(NOP)");
|
||||
|
||||
t.is (json::encode ("1€2"), "1€2", "json::encode € -> €");
|
||||
t.is (json::decode ("1\\u20ac2"), "1€2", "json::decode slashslashu20ac -> €");
|
||||
|
||||
std::string encoded = json::encode ("one\\");
|
||||
t.is (encoded, "one\\\\", "json::encode oneslashslashslashslash -> oneslashslashslashslashslashslashslashslash");
|
||||
t.is ((int)encoded.length (), 5, "json::encode oneslashslashslashslash -> length 5");
|
||||
t.is (encoded[0], 'o', "json::encode oneslashslashslashslash[0] -> o");
|
||||
t.is (encoded[1], 'n', "json::encode oneslashslashslashslash[1] -> n");
|
||||
t.is (encoded[2], 'e', "json::encode oneslashslashslashslash[2] -> e");
|
||||
t.is (encoded[3], '\\', "json::encode oneslashslashslashslash[3] -> slashslash");
|
||||
t.is (encoded[4], '\\', "json::encode oneslashslashslashslash[4] -> slashslash");
|
||||
|
||||
t.is (json::decode (encoded), "one\\", "json::decode oneslashslashslashslashslashslashslashslash -> oneslashslashslashslash");
|
||||
}
|
||||
|
||||
catch (const std::string& e) {t.diag (e);}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -1,23 +0,0 @@
|
|||
{
|
||||
"glossary": {
|
||||
"title": "example glossary",
|
||||
"GlossDiv": {
|
||||
"title": "S",
|
||||
"GlossList": {
|
||||
"GlossEntry": {
|
||||
"ID": "SGML",
|
||||
"SortAs": "SGML",
|
||||
"GlossTerm": "Standard Generalized Markup Language",
|
||||
"Acronym": "SGML",
|
||||
"Abbrev": "ISO 8879:1986",
|
||||
"GlossDef": {
|
||||
"para": "A meta-markup language, used to create markup languages such as DocBook.",
|
||||
"GlossSeeAlso": ["GML", "XML"]
|
||||
},
|
||||
"GlossSee": "markup"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1,11 +0,0 @@
|
|||
{"menu": {
|
||||
"id": "file",
|
||||
"value": "File",
|
||||
"popup": {
|
||||
"menuitem": [
|
||||
{"value": "New", "onclick": "CreateNewDoc()"},
|
||||
{"value": "Open", "onclick": "OpenDoc()"},
|
||||
{"value": "Close", "onclick": "CloseDoc()"}
|
||||
]
|
||||
}
|
||||
}}
|
|
@ -1,26 +0,0 @@
|
|||
{"widget": {
|
||||
"debug": "on",
|
||||
"window": {
|
||||
"title": "Sample Konfabulator Widget",
|
||||
"name": "main_window",
|
||||
"width": 500,
|
||||
"height": 500
|
||||
},
|
||||
"image": {
|
||||
"src": "Images/Sun.png",
|
||||
"name": "sun1",
|
||||
"hOffset": 250,
|
||||
"vOffset": 250,
|
||||
"alignment": "center"
|
||||
},
|
||||
"text": {
|
||||
"data": "Click Here",
|
||||
"size": 36,
|
||||
"style": "bold",
|
||||
"name": "text1",
|
||||
"hOffset": 250,
|
||||
"vOffset": 100,
|
||||
"alignment": "center",
|
||||
"onMouseUp": "sun1.opacity = (sun1.opacity / 100) * 90;"
|
||||
}
|
||||
}}
|
|
@ -1,88 +0,0 @@
|
|||
{"web-app": {
|
||||
"servlet": [
|
||||
{
|
||||
"servlet-name": "cofaxCDS",
|
||||
"servlet-class": "org.cofax.cds.CDSServlet",
|
||||
"init-param": {
|
||||
"configGlossary:installationAt": "Philadelphia, PA",
|
||||
"configGlossary:adminEmail": "ksm@pobox.com",
|
||||
"configGlossary:poweredBy": "Cofax",
|
||||
"configGlossary:poweredByIcon": "/images/cofax.gif",
|
||||
"configGlossary:staticPath": "/content/static",
|
||||
"templateProcessorClass": "org.cofax.WysiwygTemplate",
|
||||
"templateLoaderClass": "org.cofax.FilesTemplateLoader",
|
||||
"templatePath": "templates",
|
||||
"templateOverridePath": "",
|
||||
"defaultListTemplate": "listTemplate.htm",
|
||||
"defaultFileTemplate": "articleTemplate.htm",
|
||||
"useJSP": false,
|
||||
"jspListTemplate": "listTemplate.jsp",
|
||||
"jspFileTemplate": "articleTemplate.jsp",
|
||||
"cachePackageTagsTrack": 200,
|
||||
"cachePackageTagsStore": 200,
|
||||
"cachePackageTagsRefresh": 60,
|
||||
"cacheTemplatesTrack": 100,
|
||||
"cacheTemplatesStore": 50,
|
||||
"cacheTemplatesRefresh": 15,
|
||||
"cachePagesTrack": 200,
|
||||
"cachePagesStore": 100,
|
||||
"cachePagesRefresh": 10,
|
||||
"cachePagesDirtyRead": 10,
|
||||
"searchEngineListTemplate": "forSearchEnginesList.htm",
|
||||
"searchEngineFileTemplate": "forSearchEngines.htm",
|
||||
"searchEngineRobotsDb": "WEB-INF/robots.db",
|
||||
"useDataStore": true,
|
||||
"dataStoreClass": "org.cofax.SqlDataStore",
|
||||
"redirectionClass": "org.cofax.SqlRedirection",
|
||||
"dataStoreName": "cofax",
|
||||
"dataStoreDriver": "com.microsoft.jdbc.sqlserver.SQLServerDriver",
|
||||
"dataStoreUrl": "jdbc:microsoft:sqlserver://LOCALHOST:1433;DatabaseName=goon",
|
||||
"dataStoreUser": "sa",
|
||||
"dataStorePassword": "dataStoreTestQuery",
|
||||
"dataStoreTestQuery": "SET NOCOUNT ON;select test='test';",
|
||||
"dataStoreLogFile": "/usr/local/tomcat/logs/datastore.log",
|
||||
"dataStoreInitConns": 10,
|
||||
"dataStoreMaxConns": 100,
|
||||
"dataStoreConnUsageLimit": 100,
|
||||
"dataStoreLogLevel": "debug",
|
||||
"maxUrlLength": 500}},
|
||||
{
|
||||
"servlet-name": "cofaxEmail",
|
||||
"servlet-class": "org.cofax.cds.EmailServlet",
|
||||
"init-param": {
|
||||
"mailHost": "mail1",
|
||||
"mailHostOverride": "mail2"}},
|
||||
{
|
||||
"servlet-name": "cofaxAdmin",
|
||||
"servlet-class": "org.cofax.cds.AdminServlet"},
|
||||
|
||||
{
|
||||
"servlet-name": "fileServlet",
|
||||
"servlet-class": "org.cofax.cds.FileServlet"},
|
||||
{
|
||||
"servlet-name": "cofaxTools",
|
||||
"servlet-class": "org.cofax.cms.CofaxToolsServlet",
|
||||
"init-param": {
|
||||
"templatePath": "toolstemplates/",
|
||||
"log": 1,
|
||||
"logLocation": "/usr/local/tomcat/logs/CofaxTools.log",
|
||||
"logMaxSize": "",
|
||||
"dataLog": 1,
|
||||
"dataLogLocation": "/usr/local/tomcat/logs/dataLog.log",
|
||||
"dataLogMaxSize": "",
|
||||
"removePageCache": "/content/admin/remove?cache=pages&id=",
|
||||
"removeTemplateCache": "/content/admin/remove?cache=templates&id=",
|
||||
"fileTransferFolder": "/usr/local/tomcat/webapps/content/fileTransferFolder",
|
||||
"lookInContext": 1,
|
||||
"adminGroupID": 4,
|
||||
"betaServer": true}}],
|
||||
"servlet-mapping": {
|
||||
"cofaxCDS": "/",
|
||||
"cofaxEmail": "/cofaxutil/aemail/*",
|
||||
"cofaxAdmin": "/admin/*",
|
||||
"fileServlet": "/static/*",
|
||||
"cofaxTools": "/tools/*"},
|
||||
|
||||
"taglib": {
|
||||
"taglib-uri": "cofax.tld",
|
||||
"taglib-location": "/WEB-INF/tlds/cofax.tld"}}}
|
|
@ -1,27 +0,0 @@
|
|||
{"menu": {
|
||||
"header": "SVG Viewer",
|
||||
"items": [
|
||||
{"id": "Open"},
|
||||
{"id": "OpenNew", "label": "Open New"},
|
||||
null,
|
||||
{"id": "ZoomIn", "label": "Zoom In"},
|
||||
{"id": "ZoomOut", "label": "Zoom Out"},
|
||||
{"id": "OriginalView", "label": "Original View"},
|
||||
null,
|
||||
{"id": "Quality"},
|
||||
{"id": "Pause"},
|
||||
{"id": "Mute"},
|
||||
null,
|
||||
{"id": "Find", "label": "Find..."},
|
||||
{"id": "FindAgain", "label": "Find Again"},
|
||||
{"id": "Copy"},
|
||||
{"id": "CopyAgain", "label": "Copy Again"},
|
||||
{"id": "CopySVG", "label": "Copy SVG"},
|
||||
{"id": "ViewSVG", "label": "View SVG"},
|
||||
{"id": "ViewSource", "label": "View Source"},
|
||||
{"id": "SaveAs", "label": "Save As"},
|
||||
null,
|
||||
{"id": "Help"},
|
||||
{"id": "About", "label": "About Adobe CVG Viewer..."}
|
||||
]
|
||||
}}
|
|
@ -1,2 +0,0 @@
|
|||
[{"styleFocus":"GROWTH","creationTime":"2008-01-21","preferences":{"kfe.elite-rankings":"hide","guitarPromoClosed":"1","kfe.last_viewed_feature":"1"},"nickName":"Pascal-Louis Perez","showFlag":true,"firstName":"Pascal-Louis","points":0,"id":8,"industryFocus":"TECHNOLOGY","externalIds":[{"platform":"FACEBOOK","id":219948}],"useRealName":true,"shard":8,"concentrationFocus":"LESS_THAN_10","passwordSalt":3567830610840546163,"validatedEmails":["pascal.louis.perez@gmail.com","pascal@kaching.com","pascal@cs.stanford.edu"],"city":"Geneve","rankLevel":"BASIC","experiences":["KACHING","DEVELOPMENT","LOGIN_SYSTEM","ADMIN","RESEARCH","RANKINGS"],"marketCapFocus":"LARGE","picture":"sqr8.jpg","interests":{"MY_WALL":["EMAIL"]},"nonValidatedEmails":["pascal.loui-s.perez@gmail.com"],"showPicture":true,"lastName":"Perez","tradingFrequencyFocus":"BUY_AND_HOLD","validatedPrimaryEmail":"pascal.louis.perez@gmail.com","country":"CH","sessions":[{"d":"p","parameters":{"facebookSessionKey":"a9f133eed207196a563b0ca7-219948","facebookUserId":"219948"},"k":"qOtXSepsfrc=","platform":"FACEBOOK"},{"d":"s","k":"O7p3i91IXa8="},{"d":"s","k":"fexhG/MSXr0="},{"d":"s","k":"YUkWZMK4ors="},{"d":"s","k":"ETfFsm0svdg="}],"primaryEmail":"pascal.louis.perez@gmail.com","investmentStrategy":"Hire people who can manage my assets for me. I'm lousy.","lastLogin":"2008-12-17 12:45:25.000","portfolioId":219948}]
|
||||
|
|
@ -1 +0,0 @@
|
|||
[ 100, 500, 300, 200, 400 ]
|
|
@ -1,30 +0,0 @@
|
|||
[
|
||||
{
|
||||
"color": "red",
|
||||
"value": "#f00"
|
||||
},
|
||||
{
|
||||
"color": "green",
|
||||
"value": "#0f0"
|
||||
},
|
||||
{
|
||||
"color": "blue",
|
||||
"value": "#00f"
|
||||
},
|
||||
{
|
||||
"color": "cyan",
|
||||
"value": "#0ff"
|
||||
},
|
||||
{
|
||||
"color": "magenta",
|
||||
"value": "#f0f"
|
||||
},
|
||||
{
|
||||
"color": "yellow",
|
||||
"value": "#ff0"
|
||||
},
|
||||
{
|
||||
"color": "black",
|
||||
"value": "#000"
|
||||
}
|
||||
]
|
|
@ -1,4 +0,0 @@
|
|||
{
|
||||
"color": "red",
|
||||
"value": "#f00"
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
{
|
||||
"id": "0001",
|
||||
"type": "donut",
|
||||
"name": "Cake",
|
||||
"ppu": 0.55,
|
||||
"batters":
|
||||
{
|
||||
"batter":
|
||||
[
|
||||
{ "id": "1001", "type": "Regular" },
|
||||
{ "id": "1002", "type": "Chocolate" },
|
||||
{ "id": "1003", "type": "Blueberry" },
|
||||
{ "id": "1004", "type": "Devil's Food" }
|
||||
]
|
||||
},
|
||||
"topping":
|
||||
[
|
||||
{ "id": "5001", "type": "None" },
|
||||
{ "id": "5002", "type": "Glazed" },
|
||||
{ "id": "5005", "type": "Sugar" },
|
||||
{ "id": "5007", "type": "Powdered Sugar" },
|
||||
{ "id": "5006", "type": "Chocolate with Sprinkles" },
|
||||
{ "id": "5003", "type": "Chocolate" },
|
||||
{ "id": "5004", "type": "Maple" }
|
||||
]
|
||||
}
|
|
@ -1,70 +0,0 @@
|
|||
[
|
||||
{
|
||||
"id": "0001",
|
||||
"type": "donut",
|
||||
"name": "Cake",
|
||||
"ppu": 0.55,
|
||||
"batters":
|
||||
{
|
||||
"batter":
|
||||
[
|
||||
{ "id": "1001", "type": "Regular" },
|
||||
{ "id": "1002", "type": "Chocolate" },
|
||||
{ "id": "1003", "type": "Blueberry" },
|
||||
{ "id": "1004", "type": "Devil's Food" }
|
||||
]
|
||||
},
|
||||
"topping":
|
||||
[
|
||||
{ "id": "5001", "type": "None" },
|
||||
{ "id": "5002", "type": "Glazed" },
|
||||
{ "id": "5005", "type": "Sugar" },
|
||||
{ "id": "5007", "type": "Powdered Sugar" },
|
||||
{ "id": "5006", "type": "Chocolate with Sprinkles" },
|
||||
{ "id": "5003", "type": "Chocolate" },
|
||||
{ "id": "5004", "type": "Maple" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "0002",
|
||||
"type": "donut",
|
||||
"name": "Raised",
|
||||
"ppu": 0.55,
|
||||
"batters":
|
||||
{
|
||||
"batter":
|
||||
[
|
||||
{ "id": "1001", "type": "Regular" }
|
||||
]
|
||||
},
|
||||
"topping":
|
||||
[
|
||||
{ "id": "5001", "type": "None" },
|
||||
{ "id": "5002", "type": "Glazed" },
|
||||
{ "id": "5005", "type": "Sugar" },
|
||||
{ "id": "5003", "type": "Chocolate" },
|
||||
{ "id": "5004", "type": "Maple" }
|
||||
]
|
||||
},
|
||||
{
|
||||
"id": "0003",
|
||||
"type": "donut",
|
||||
"name": "Old Fashioned",
|
||||
"ppu": 0.55,
|
||||
"batters":
|
||||
{
|
||||
"batter":
|
||||
[
|
||||
{ "id": "1001", "type": "Regular" },
|
||||
{ "id": "1002", "type": "Chocolate" }
|
||||
]
|
||||
},
|
||||
"topping":
|
||||
[
|
||||
{ "id": "5001", "type": "None" },
|
||||
{ "id": "5002", "type": "Glazed" },
|
||||
{ "id": "5003", "type": "Chocolate" },
|
||||
{ "id": "5004", "type": "Maple" }
|
||||
]
|
||||
}
|
||||
]
|
|
@ -1,17 +0,0 @@
|
|||
{
|
||||
"id": "0001",
|
||||
"type": "donut",
|
||||
"name": "Cake",
|
||||
"image":
|
||||
{
|
||||
"url": "images/0001.jpg",
|
||||
"width": 200,
|
||||
"height": 200
|
||||
},
|
||||
"thumbnail":
|
||||
{
|
||||
"url": "images/thumbnails/0001.jpg",
|
||||
"width": 32,
|
||||
"height": 32
|
||||
}
|
||||
}
|
|
@ -1,34 +0,0 @@
|
|||
{
|
||||
"items":
|
||||
{
|
||||
"item":
|
||||
[
|
||||
{
|
||||
"id": "0001",
|
||||
"type": "donut",
|
||||
"name": "Cake",
|
||||
"ppu": 0.55,
|
||||
"batters":
|
||||
{
|
||||
"batter":
|
||||
[
|
||||
{ "id": "1001", "type": "Regular" },
|
||||
{ "id": "1002", "type": "Chocolate" },
|
||||
{ "id": "1003", "type": "Blueberry" },
|
||||
{ "id": "1004", "type": "Devil's Food" }
|
||||
]
|
||||
},
|
||||
"topping":
|
||||
[
|
||||
{ "id": "5001", "type": "None" },
|
||||
{ "id": "5002", "type": "Glazed" },
|
||||
{ "id": "5005", "type": "Sugar" },
|
||||
{ "id": "5007", "type": "Powdered Sugar" },
|
||||
{ "id": "5006", "type": "Chocolate with Sprinkles" },
|
||||
{ "id": "5003", "type": "Chocolate" },
|
||||
{ "id": "5004", "type": "Maple" }
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,36 +0,0 @@
|
|||
{
|
||||
"items":
|
||||
{
|
||||
"item":
|
||||
[
|
||||
{
|
||||
"id": "0001",
|
||||
"type": "donut",
|
||||
"name": "Cake",
|
||||
"ppu": 0.55,
|
||||
"batters":
|
||||
{
|
||||
"batter":
|
||||
[
|
||||
{ "id": "1001", "type": "Regular" },
|
||||
{ "id": "1002", "type": "Chocolate" },
|
||||
{ "id": "1003", "type": "Blueberry" },
|
||||
{ "id": "1004", "type": "Devil's Food" }
|
||||
]
|
||||
},
|
||||
"topping":
|
||||
[
|
||||
{ "id": "5001", "type": "None" },
|
||||
{ "id": "5002", "type": "Glazed" },
|
||||
{ "id": "5005", "type": "Sugar" },
|
||||
{ "id": "5007", "type": "Powdered Sugar" },
|
||||
{ "id": "5006", "type": "Chocolate with Sprinkles" },
|
||||
{ "id": "5003", "type": "Chocolate" },
|
||||
{ "id": "5004", "type": "Maple" }
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,44 +0,0 @@
|
|||
{
|
||||
"data": [
|
||||
{
|
||||
"id": "X999_Y999",
|
||||
"from": {
|
||||
"name": "Tom Brady", "id": "X12"
|
||||
},
|
||||
"message": "Looking forward to 2010!",
|
||||
"actions": [
|
||||
{
|
||||
"name": "Comment",
|
||||
"link": "http://www.facebook.com/X999/posts/Y999"
|
||||
},
|
||||
{
|
||||
"name": "Like",
|
||||
"link": "http://www.facebook.com/X999/posts/Y999"
|
||||
}
|
||||
],
|
||||
"type": "status",
|
||||
"created_time": "2010-08-02T21:27:44+0000",
|
||||
"updated_time": "2010-08-02T21:27:44+0000"
|
||||
},
|
||||
{
|
||||
"id": "X998_Y998",
|
||||
"from": {
|
||||
"name": "Peyton Manning", "id": "X18"
|
||||
},
|
||||
"message": "Where's my contract?",
|
||||
"actions": [
|
||||
{
|
||||
"name": "Comment",
|
||||
"link": "http://www.facebook.com/X998/posts/Y998"
|
||||
},
|
||||
{
|
||||
"name": "Like",
|
||||
"link": "http://www.facebook.com/X998/posts/Y998"
|
||||
}
|
||||
],
|
||||
"type": "status",
|
||||
"created_time": "2010-08-02T21:27:44+0000",
|
||||
"updated_time": "2010-08-02T21:27:44+0000"
|
||||
}
|
||||
]
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
"title": "Talk On Travel Pool",
|
||||
"link": "http://www.flickr.com/groups/talkontravel/pool/",
|
||||
"description": "Travel and vacation photos from around the world.",
|
||||
"modified": "2009-02-02T11:10:27Z",
|
||||
"generator": "http://www.flickr.com/",
|
||||
"items": [
|
||||
{
|
||||
"title": "View from the hotel",
|
||||
"link": "http://www.flickr.com/photos/33112458@N08/3081564649/in/pool-998875@N22",
|
||||
"media": {"m":"http://farm4.static.flickr.com/3037/3081564649_4a6569750c_m.jpg"},
|
||||
"date_taken": "2008-12-04T04:43:03-08:00",
|
||||
"description": "<p><a href=\"http://www.flickr.com/people/33112458@N08/\"> Talk On Travel<\/a> has added a photo to the pool:<\/p> <p><a href=\"http:// www.flickr.com/photos/33112458@N08/3081564649/\" title=\"View from the hotel\"> <img src=\"http://farm4.static.flickr.com/3037/3081564649_4a6569750c_m.jpg\" width=\"240\" height=\"180\" alt=\"View from the hotel\" /><\/a><\/p> ",
|
||||
"published": "2008-12-04T12:43:03Z",
|
||||
"author": "nobody@flickr.com (Talk On Travel)",
|
||||
"author_id": "33112458@N08",
|
||||
"tags": "spain dolphins tenerife canaries lagomera aqualand playadelasamericas junglepark losgigantos loscristines talkontravel"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
{
|
||||
"ResultSet": {
|
||||
"totalResultsAvailable": "1827221",
|
||||
"totalResultsReturned": 2,
|
||||
"firstResultPosition": 1,
|
||||
"Result": [
|
||||
{
|
||||
"Title": "potato jpg",
|
||||
"Summary": "Kentang Si bungsu dari keluarga Solanum tuberosum L ini ternyata memiliki khasiat untuk mengurangi kerutan jerawat bintik hitam dan kemerahan pada kulit Gunakan seminggu sekali sebagai",
|
||||
"Url": "http:\/\/www.mediaindonesia.com\/spaw\/uploads\/images\/potato.jpg",
|
||||
"ClickUrl": "http:\/\/www.mediaindonesia.com\/spaw\/uploads\/images\/potato.jpg",
|
||||
"RefererUrl": "http:\/\/www.mediaindonesia.com\/mediaperempuan\/index.php?ar_id=Nzkw",
|
||||
"FileSize": 22630,
|
||||
"FileFormat": "jpeg",
|
||||
"Height": "362",
|
||||
"Width": "532",
|
||||
"Thumbnail": {
|
||||
"Url": "http:\/\/thm-a01.yimg.com\/nimage\/557094559c18f16a",
|
||||
"Height": "98",
|
||||
"Width": "145"
|
||||
}
|
||||
},
|
||||
{
|
||||
"Title": "potato jpg",
|
||||
"Summary": "Introduction of puneri aloo This is a traditional potato preparation flavoured with curry leaves and peanuts and can be eaten on fasting day Preparation time 10 min",
|
||||
"Url": "http:\/\/www.infovisual.info\/01\/photo\/potato.jpg",
|
||||
"ClickUrl": "http:\/\/www.infovisual.info\/01\/photo\/potato.jpg",
|
||||
"RefererUrl": "http:\/\/sundayfood.com\/puneri-aloo-indian-%20recipe",
|
||||
"FileSize": 119398,
|
||||
"FileFormat": "jpeg",
|
||||
"Height": "685",
|
||||
"Width": "1024",
|
||||
"Thumbnail": {
|
||||
"Url": "http:\/\/thm-a01.yimg.com\/nimage\/7fa23212efe84b64",
|
||||
"Height": "107",
|
||||
"Width": "160"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
{
|
||||
"menu": {
|
||||
"header": "xProgress SVG Viewer",
|
||||
"items": [
|
||||
{
|
||||
"id": "Open"
|
||||
},
|
||||
{
|
||||
"id": "OpenNew",
|
||||
"label": "Open New"
|
||||
},
|
||||
null,
|
||||
{
|
||||
"id": "ZoomIn",
|
||||
"label": "Zoom In"
|
||||
},
|
||||
{
|
||||
"id": "ZoomOut",
|
||||
"label": "Zoom Out"
|
||||
},
|
||||
{
|
||||
"id": "OriginalView",
|
||||
"label": "Original View"
|
||||
},
|
||||
null,
|
||||
{
|
||||
"id": "Quality"
|
||||
},
|
||||
{
|
||||
"id": "Pause"
|
||||
},
|
||||
{
|
||||
"id": "Mute"
|
||||
},
|
||||
null,
|
||||
{
|
||||
"id": "Find",
|
||||
"label": "Find..."
|
||||
},
|
||||
{
|
||||
"id": "FindAgain",
|
||||
"label": "Find Again"
|
||||
},
|
||||
{
|
||||
"id": "Copy"
|
||||
},
|
||||
{
|
||||
"id": "CopyAgain",
|
||||
"label": "Copy Again"
|
||||
},
|
||||
{
|
||||
"id": "CopySVG",
|
||||
"label": "Copy SVG"
|
||||
},
|
||||
{
|
||||
"id": "ViewSVG",
|
||||
"label": "View SVG"
|
||||
},
|
||||
{
|
||||
"id": "ViewSource",
|
||||
"label": "View Source"
|
||||
},
|
||||
{
|
||||
"id": "SaveAs",
|
||||
"label": "Save As"
|
||||
},
|
||||
null,
|
||||
{
|
||||
"id": "Help"
|
||||
},
|
||||
{
|
||||
"id": "About",
|
||||
"label": "About xProgress CVG Viewer..."
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,50 +0,0 @@
|
|||
{"results":[
|
||||
|
||||
{"text":"@twitterapi http:\/\/tinyurl.com\/ctrefg",
|
||||
|
||||
"to_user_id":396524,
|
||||
|
||||
"to_user":"TwitterAPI",
|
||||
|
||||
"from_user":"jkoum",
|
||||
|
||||
"metadata":
|
||||
|
||||
{
|
||||
|
||||
"result_type":"popular",
|
||||
|
||||
"recent_retweets": 109
|
||||
|
||||
},
|
||||
|
||||
"id":1478555574,
|
||||
|
||||
"from_user_id":1833773,
|
||||
|
||||
"iso_language_code":"nl",
|
||||
|
||||
"source":"<a href=\"http:\/\/twitter.com\/\">twitter<\/a>",
|
||||
|
||||
"profile_image_url":"http:\/\/s3.amazonaws.com\/twitter_production\/profile_images\/118412707\/2522215727_a5f07da155_b_normal.jpg",
|
||||
|
||||
"created_at":"Wed, 08 Apr 2009 19:22:10 +0000"}
|
||||
|
||||
],
|
||||
|
||||
"since_id":0,
|
||||
|
||||
"max_id":1480307926,
|
||||
|
||||
"refresh_url":"?since_id=1480307926&q=%40twitterapi",
|
||||
|
||||
"results_per_page":15,
|
||||
|
||||
"next_page":"?page=2&max_id=1480307926&q=%40twitterapi",
|
||||
|
||||
"completed_in":0.031704,
|
||||
|
||||
"page":1,
|
||||
|
||||
"query":"%40twitterapi"
|
||||
}
|
|
@ -1,53 +0,0 @@
|
|||
{"apiVersion":"2.0",
|
||||
"data":{
|
||||
"updated":"2010-01-07T19:58:42.949Z",
|
||||
"totalItems":800,
|
||||
"startIndex":1,
|
||||
"itemsPerPage":1,
|
||||
"items":[
|
||||
{"id":"hYB0mn5zh2c",
|
||||
"uploaded":"2007-06-05T22:07:03.000Z",
|
||||
"updated":"2010-01-07T13:26:50.000Z",
|
||||
"uploader":"GoogleDeveloperDay",
|
||||
"category":"News",
|
||||
"title":"Google Developers Day US - Maps API Introduction",
|
||||
"description":"Google Maps API Introduction ...",
|
||||
"tags":[
|
||||
"GDD07","GDD07US","Maps"
|
||||
],
|
||||
"thumbnail":{
|
||||
"default":"http://i.ytimg.com/vi/hYB0mn5zh2c/default.jpg",
|
||||
"hqDefault":"http://i.ytimg.com/vi/hYB0mn5zh2c/hqdefault.jpg"
|
||||
},
|
||||
"player":{
|
||||
"default":"http://www.youtube.com/watch?v\u003dhYB0mn5zh2c"
|
||||
},
|
||||
"content":{
|
||||
"1":"rtsp://v5.cache3.c.youtube.com/CiILENy.../0/0/0/video.3gp",
|
||||
"5":"http://www.youtube.com/v/hYB0mn5zh2c?f...",
|
||||
"6":"rtsp://v1.cache1.c.youtube.com/CiILENy.../0/0/0/video.3gp"
|
||||
},
|
||||
"duration":2840,
|
||||
"aspectRatio":"widescreen",
|
||||
"rating":4.63,
|
||||
"ratingCount":68,
|
||||
"viewCount":220101,
|
||||
"favoriteCount":201,
|
||||
"commentCount":22,
|
||||
"status":{
|
||||
"value":"restricted",
|
||||
"reason":"limitedSyndication"
|
||||
},
|
||||
"accessControl":{
|
||||
"syndicate":"allowed",
|
||||
"commentVote":"allowed",
|
||||
"rate":"allowed",
|
||||
"list":"allowed",
|
||||
"comment":"allowed",
|
||||
"embed":"allowed",
|
||||
"videoRespond":"moderated"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
|
@ -1,87 +0,0 @@
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright 2006 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
// of this software and associated documentation files (the "Software"), to deal
|
||||
// in the Software without restriction, including without limitation the rights
|
||||
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
// copies of the Software, and to permit persons to whom the Software is
|
||||
// furnished to do so, subject to the following conditions:
|
||||
//
|
||||
// The above copyright notice and this permission notice shall be included
|
||||
// in all copies or substantial portions of the Software.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
// SOFTWARE.
|
||||
//
|
||||
// http://www.opensource.org/licenses/mit-license.php
|
||||
//
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <cmake.h>
|
||||
#include <iostream>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <FS.h>
|
||||
#include <JSON.h>
|
||||
#include <Context.h>
|
||||
|
||||
Context context;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
int main (int argc, char** argv)
|
||||
{
|
||||
if (argc == 1)
|
||||
{
|
||||
std::cout << "\nUsage: json_test [-q] <file | JSON> ...\n"
|
||||
<< "\n"
|
||||
<< " -q quiet, no JSON dump\n"
|
||||
<< " <file> file containing JSON\n"
|
||||
<< " <JSON> JSON string, may need to be quoted\n"
|
||||
<< "\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool quiet = false;
|
||||
for (int i = 1; i < argc; ++i)
|
||||
if (!strcmp (argv[i], "-q"))
|
||||
quiet = true;
|
||||
|
||||
for (int i = 1; i < argc; ++i)
|
||||
{
|
||||
if (strcmp (argv[i], "-q"))
|
||||
{
|
||||
try
|
||||
{
|
||||
json::value* root;
|
||||
File file (argv[i]);
|
||||
if (file.exists ())
|
||||
{
|
||||
std::string contents;
|
||||
file.read (contents);
|
||||
root = json::parse (contents);
|
||||
}
|
||||
else
|
||||
root = json::parse (argv[i]);
|
||||
|
||||
if (root && !quiet)
|
||||
std::cout << root->dump () << "\n";
|
||||
|
||||
delete root;
|
||||
}
|
||||
|
||||
catch (const std::string& e) { std::cout << e << "\n"; }
|
||||
catch (...) { std::cout << "Unknown error\n"; }
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////
|
|
@ -1,83 +0,0 @@
|
|||
#!/usr/bin/env python2.7
|
||||
# -*- coding: utf-8 -*-
|
||||
###############################################################################
|
||||
#
|
||||
# Copyright 2006 - 2016, Paul Beckingham, Federico Hernandez.
|
||||
#
|
||||
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
# of this software and associated documentation files (the "Software"), to deal
|
||||
# in the Software without restriction, including without limitation the rights
|
||||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
# copies of the Software, and to permit persons to whom the Software is
|
||||
# furnished to do so, subject to the following conditions:
|
||||
#
|
||||
# The above copyright notice and this permission notice shall be included
|
||||
# in all copies or substantial portions of the Software.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
# OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
||||
# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
# SOFTWARE.
|
||||
#
|
||||
# http://www.opensource.org/licenses/mit-license.php
|
||||
#
|
||||
###############################################################################
|
||||
|
||||
import sys
|
||||
import os
|
||||
import unittest
|
||||
from glob import glob
|
||||
# Ensure python finds the local simpletap module
|
||||
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
from basetest import TestCase
|
||||
from basetest.utils import CURRENT_DIR, run_cmd_wait_nofail
|
||||
from basetest.meta import MetaTest
|
||||
|
||||
|
||||
class MetaTestJson(MetaTest):
|
||||
"""Helper metaclass to simplify test logic below (TestJson)
|
||||
|
||||
Creates test_methods in the TestCase class dynamically named after the
|
||||
arguments used.
|
||||
"""
|
||||
@staticmethod
|
||||
def make_function(classname, *args, **kwargs):
|
||||
filepath = args[0]
|
||||
TEST_BIN = kwargs.get("TEST_BIN")
|
||||
|
||||
def test(self):
|
||||
# ### Body of the usual test_testcase ### #
|
||||
cmd = (TEST_BIN, filepath)
|
||||
code, out, err = run_cmd_wait_nofail(cmd)
|
||||
|
||||
self.assertNotIn("Error", out)
|
||||
|
||||
filename = os.path.basename(filepath)
|
||||
|
||||
# Title of test in report
|
||||
test.__doc__ = "{0} {1}".format(classname, filename)
|
||||
|
||||
return test
|
||||
|
||||
|
||||
class TestJsonParsing(TestCase):
|
||||
__metaclass__ = MetaTestJson
|
||||
|
||||
EXTRA = {}
|
||||
EXTRA["TEST_DIR"] = os.path.abspath(os.path.join(CURRENT_DIR, ".."))
|
||||
EXTRA["TEST_BIN"] = os.path.join(EXTRA["TEST_DIR"], "json_test")
|
||||
|
||||
TESTS = (
|
||||
zip(glob(os.path.join(EXTRA["TEST_DIR"], "json/*.json")))
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
from simpletap import TAPTestRunner
|
||||
unittest.main(testRunner=TAPTestRunner())
|
||||
|
||||
# vim: ai sts=4 et sw=4 ft=python
|
Loading…
Add table
Add a link
Reference in a new issue