mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00
Unit Tests
- Added JSON samples to test the parser.
This commit is contained in:
parent
df1920d75c
commit
f669b5f56f
22 changed files with 756 additions and 8 deletions
23
test/json/1.json
Normal file
23
test/json/1.json
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
11
test/json/2.json
Normal file
11
test/json/2.json
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
{"menu": {
|
||||||
|
"id": "file",
|
||||||
|
"value": "File",
|
||||||
|
"popup": {
|
||||||
|
"menuitem": [
|
||||||
|
{"value": "New", "onclick": "CreateNewDoc()"},
|
||||||
|
{"value": "Open", "onclick": "OpenDoc()"},
|
||||||
|
{"value": "Close", "onclick": "CloseDoc()"}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}}
|
26
test/json/3.json
Normal file
26
test/json/3.json
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{"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;"
|
||||||
|
}
|
||||||
|
}}
|
88
test/json/4.json
Normal file
88
test/json/4.json
Normal file
|
@ -0,0 +1,88 @@
|
||||||
|
{"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"}}}
|
27
test/json/5.json
Normal file
27
test/json/5.json
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
{"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..."}
|
||||||
|
]
|
||||||
|
}}
|
2
test/json/6.json
Normal file
2
test/json/6.json
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
[{"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
test/json/e1.json
Normal file
1
test/json/e1.json
Normal file
|
@ -0,0 +1 @@
|
||||||
|
[ 100, 500, 300, 200, 400 ]
|
30
test/json/e2.json
Normal file
30
test/json/e2.json
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
]
|
4
test/json/e3.json
Normal file
4
test/json/e3.json
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
{
|
||||||
|
"color": "red",
|
||||||
|
"value": "#f00"
|
||||||
|
}
|
26
test/json/e4.json
Normal file
26
test/json/e4.json
Normal file
|
@ -0,0 +1,26 @@
|
||||||
|
{
|
||||||
|
"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" }
|
||||||
|
]
|
||||||
|
}
|
70
test/json/e5.json
Normal file
70
test/json/e5.json
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"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" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
17
test/json/e6.json
Normal file
17
test/json/e6.json
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
{
|
||||||
|
"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
|
||||||
|
}
|
||||||
|
}
|
34
test/json/e7.json
Normal file
34
test/json/e7.json
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
{
|
||||||
|
"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" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
36
test/json/e8.json
Normal file
36
test/json/e8.json
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
{
|
||||||
|
"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" }
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
44
test/json/facebook.json
Normal file
44
test/json/facebook.json
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
21
test/json/flikr.json
Normal file
21
test/json/flikr.json
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
41
test/json/interop.json
Normal file
41
test/json/interop.json
Normal file
|
@ -0,0 +1,41 @@
|
||||||
|
{
|
||||||
|
"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
77
test/json/iphone.json
Normal file
77
test/json/iphone.json
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
{
|
||||||
|
"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..."
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
50
test/json/twitter.json
Normal file
50
test/json/twitter.json
Normal file
|
@ -0,0 +1,50 @@
|
||||||
|
{"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"
|
||||||
|
}
|
53
test/json/youtube.json
Normal file
53
test/json/youtube.json
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
{"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"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,6 +26,7 @@
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <File.h>
|
||||||
#include <JSON.h>
|
#include <JSON.h>
|
||||||
#include <Context.h>
|
#include <Context.h>
|
||||||
|
|
||||||
|
@ -36,24 +37,46 @@ int main (int argc, char** argv)
|
||||||
{
|
{
|
||||||
if (argc == 1)
|
if (argc == 1)
|
||||||
{
|
{
|
||||||
std::cout << "\nUsage: json_test '{...}' ...\n\n";
|
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;
|
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)
|
for (int i = 1; i < argc; ++i)
|
||||||
{
|
{
|
||||||
try
|
if (strcmp (argv[i], "-q"))
|
||||||
{
|
{
|
||||||
json::value* root = json::parse (argv[i]);
|
try
|
||||||
if (root)
|
|
||||||
{
|
{
|
||||||
std::cout << root->dump () << "\n";
|
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;
|
delete root;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
catch (const std::string& e) { std::cout << e << "\n"; }
|
catch (const std::string& e) { std::cout << e << "\n"; }
|
||||||
catch (...) { std::cout << "Unknown error\n"; }
|
catch (...) { std::cout << "Unknown error\n"; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
44
test/json_test.t
Executable file
44
test/json_test.t
Executable file
|
@ -0,0 +1,44 @@
|
||||||
|
#! /usr/bin/perl
|
||||||
|
################################################################################
|
||||||
|
## taskwarrior - a command line task list manager.
|
||||||
|
##
|
||||||
|
## Copyright 2006 - 2011, Paul Beckingham, Federico Hernandez.
|
||||||
|
## All rights reserved.
|
||||||
|
##
|
||||||
|
## This program is free software; you can redistribute it and/or modify it under
|
||||||
|
## the terms of the GNU General Public License as published by the Free Software
|
||||||
|
## Foundation; either version 2 of the License, or (at your option) any later
|
||||||
|
## version.
|
||||||
|
##
|
||||||
|
## This program is distributed in the hope that it will be useful, but WITHOUT
|
||||||
|
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
||||||
|
## FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
||||||
|
## details.
|
||||||
|
##
|
||||||
|
## You should have received a copy of the GNU General Public License along with
|
||||||
|
## this program; if not, write to the
|
||||||
|
##
|
||||||
|
## Free Software Foundation, Inc.,
|
||||||
|
## 51 Franklin Street, Fifth Floor,
|
||||||
|
## Boston, MA
|
||||||
|
## 02110-1301
|
||||||
|
## USA
|
||||||
|
##
|
||||||
|
################################################################################
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
use Test::More;
|
||||||
|
|
||||||
|
my @files = glob "./json/*.json";
|
||||||
|
plan tests => scalar @files;
|
||||||
|
|
||||||
|
my $output;
|
||||||
|
for my $file (@files)
|
||||||
|
{
|
||||||
|
$output = qx{./json_test $file};
|
||||||
|
unlike ($output, qr/^Error/, "json_test $file");
|
||||||
|
}
|
||||||
|
|
||||||
|
exit 0;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue