diff options
author | Alexei Rousskikh <ext-alexei.rousskikh@nokia.com> | 2012-02-16 13:39:08 -0500 |
---|---|---|
committer | Andrew Christian <andrew.christian@nokia.com> | 2012-02-16 21:16:40 +0100 |
commit | 7073c61891b6b0bb92aea512692a7686568656f4 (patch) | |
tree | 50c3cf13ff95b56da62911a6188536594a8504e8 /tests | |
parent | a870d6db7ecd32516ec5029cbde06e4f89805e97 (diff) |
initial default schema property implementation
Change-Id: I7a876291cbea19a00bb692cdf9000bcb7a586904
Reviewed-by: Andrew Christian <andrew.christian@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/jsonschema/tst_jsonschema.cpp | 10 | ||||
-rw-r--r-- | tests/auto/jsonstream/schemas/PaintEvent.json | 3 | ||||
-rw-r--r-- | tests/auto/jsonstream/schemas/PaintTextEvent.json | 13 |
3 files changed, 23 insertions, 3 deletions
diff --git a/tests/auto/jsonschema/tst_jsonschema.cpp b/tests/auto/jsonschema/tst_jsonschema.cpp index 487d2e8..fc493f8 100644 --- a/tests/auto/jsonschema/tst_jsonschema.cpp +++ b/tests/auto/jsonschema/tst_jsonschema.cpp @@ -77,6 +77,7 @@ private slots: // 5.19 void testEnumValidation(); // TODO: 5.20 default + void testDefaultValidation(); // 5.21 void testTitleValidation(); // 5.22 @@ -334,6 +335,15 @@ void tst_JsonSchema::testEnumValidation() //FIX QVERIFY(!validate({}, "{ \"properties\" : { \"a\" : { \"enum\" : [\"a\"], \"optional\" : false, \"required\" : true } } }")); } + +// 5.20 +void tst_JsonSchema::testDefaultValidation() +{ +// QVERIFY(validate("{ \"b\" : true }", "{ \"type\":\"object\", \"properties\" : { \"a\" : { \"type\":\"string\", \"default\": \"hoi\"} } }")); + QVERIFY(validate("{ \"b\" : true }", "{ \"type\":\"object\", \"properties\" : { \"a\" : { \"type\":\"string\", \"default\": \"hoi\"}, \"c\" : { \"type\":\"array\", \"default\":[\"a\",\"b\",\"c\"]} } }")); +} + + // 5.21 void tst_JsonSchema::testTitleValidation() { diff --git a/tests/auto/jsonstream/schemas/PaintEvent.json b/tests/auto/jsonstream/schemas/PaintEvent.json index 60e263a..8b65415 100644 --- a/tests/auto/jsonstream/schemas/PaintEvent.json +++ b/tests/auto/jsonstream/schemas/PaintEvent.json @@ -5,6 +5,7 @@ "properties": { "event": {"type":"string", "pattern":"Paint\\w*Event", "required":true }, "x": {"type":"number", "minimum": 0, "maximum": 1024, "required":true }, - "y": {"type":"number", "minimum": 0, "maximum": 768, "required":true } + "y": {"type":"number", "minimum": 0, "maximum": 768, "required":true }, + "owner" : {"type":"string", "default": "painter" } } } diff --git a/tests/auto/jsonstream/schemas/PaintTextEvent.json b/tests/auto/jsonstream/schemas/PaintTextEvent.json index 6c90882..b8da0c7 100644 --- a/tests/auto/jsonstream/schemas/PaintTextEvent.json +++ b/tests/auto/jsonstream/schemas/PaintTextEvent.json @@ -1,5 +1,5 @@ { - "title": "PaintLineEvent schema", + "title": "PaintTextEvent schema", "extends": { "$ref": "PaintEvent" }, "description": "Inform the application to paint a text", "type": "object", @@ -7,6 +7,15 @@ "event": {"type":"string", "pattern":"PaintTextEvent", "required":true }, "text": {"type":"string", "required":true }, "font-size": {"type":"number", "minimum": 0 }, - "bold": {"type":"boolean"} + "bold": {"type":"boolean"}, + "font-name": {"type":"string", "default": "times"}, + "settings": { + "type": "object", + "properties": { + "border-color": { "type": "string", "default": "red" }, + "border-width": { "type": "number", "default": 5 }, + "border": {"type":"boolean", "default": true} + } + } } } |