git-svn-id: http://svn.openlayers.org/trunk/openlayers@4059 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
42 lines
1.3 KiB
HTML
42 lines
1.3 KiB
HTML
<html>
|
|
<head>
|
|
<script src="../../lib/OpenLayers.js"></script>
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
function test_Format_JSON_constructor(t) {
|
|
t.plan(4);
|
|
|
|
var options = {'foo': 'bar'};
|
|
var format = new OpenLayers.Format.JSON(options);
|
|
t.ok(format instanceof OpenLayers.Format.JSON,
|
|
"new OpenLayers.Format.JSON returns object" );
|
|
t.eq(format.foo, "bar", "constructor sets options correctly");
|
|
t.eq(typeof format.read, "function", "format has a read function");
|
|
t.eq(typeof format.write, "function", "format has a write function");
|
|
}
|
|
function test_Format_JSON_parser(t) {
|
|
t.plan(2);
|
|
|
|
var format = new OpenLayers.Format.JSON();
|
|
var data = format.read('{"a":["b"], "c":1}');
|
|
var obj = {"a":["b"], "c":1};
|
|
t.eq(obj['a'], data['a'], "element with array parsed correctly.");
|
|
t.eq(obj['c'], data['c'], "element with number parsed correctly.");
|
|
}
|
|
function test_Format_JSON_writer(t) {
|
|
t.plan(1);
|
|
|
|
var format = new OpenLayers.Format.JSON();
|
|
var data = format.write({"a":["b"], "c":1});
|
|
var obj = '{"a":["b"],"c":1}';
|
|
t.eq(data, obj, "writing data to json works.");
|
|
}
|
|
|
|
</script>
|
|
</head>
|
|
<body>
|
|
</body>
|
|
</html>
|