mirror of https://gitee.com/bigwinds/arangodb
Merge branch 'devel' of ssh://github.com/triAGENS/ArangoDB into devel
This commit is contained in:
commit
e0c85832a5
|
@ -284,6 +284,85 @@ BOOST_AUTO_TEST_CASE (tst_json_string_reference) {
|
||||||
FREE_JSON
|
FREE_JSON
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
/// @brief test string reference value
|
||||||
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
BOOST_AUTO_TEST_CASE (tst_json_string_reference2) {
|
||||||
|
INIT_BUFFER
|
||||||
|
|
||||||
|
const char* data1 = "The first Brown Fox";
|
||||||
|
const char* data2 = "The second Brown Fox";
|
||||||
|
char copy1[64];
|
||||||
|
char copy2[64];
|
||||||
|
TRI_json_t* json;
|
||||||
|
size_t len1 = strlen(data1);
|
||||||
|
size_t len2 = strlen(data2);
|
||||||
|
|
||||||
|
memset(copy1, 0, sizeof(copy1));
|
||||||
|
memcpy(copy1, data1, len1);
|
||||||
|
|
||||||
|
memset(copy2, 0, sizeof(copy2));
|
||||||
|
memcpy(copy2, data2, len2);
|
||||||
|
|
||||||
|
json = TRI_CreateArrayJson(TRI_UNKNOWN_MEM_ZONE);
|
||||||
|
|
||||||
|
TRI_Insert3ArrayJson(TRI_UNKNOWN_MEM_ZONE, json, "first",
|
||||||
|
TRI_CreateStringReferenceJson(TRI_UNKNOWN_MEM_ZONE, copy1));
|
||||||
|
|
||||||
|
TRI_Insert3ArrayJson(TRI_UNKNOWN_MEM_ZONE, json, "second",
|
||||||
|
TRI_CreateStringReference2Json(TRI_UNKNOWN_MEM_ZONE, copy2, len2));
|
||||||
|
|
||||||
|
BOOST_CHECK_EQUAL(true, TRI_IsArrayJson(json));
|
||||||
|
|
||||||
|
STRINGIFY
|
||||||
|
BOOST_CHECK_EQUAL("{\"first\":\"The first Brown Fox\",\"second\":\"The second Brown Fox\"}", STRING_VALUE);
|
||||||
|
FREE_BUFFER
|
||||||
|
|
||||||
|
FREE_JSON
|
||||||
|
|
||||||
|
// freeing JSON should not affect our string
|
||||||
|
BOOST_CHECK_EQUAL("The first Brown Fox", copy1);
|
||||||
|
BOOST_CHECK_EQUAL("The second Brown Fox", copy2);
|
||||||
|
|
||||||
|
json = TRI_CreateArrayJson(TRI_UNKNOWN_MEM_ZONE);
|
||||||
|
|
||||||
|
TRI_Insert3ArrayJson(TRI_UNKNOWN_MEM_ZONE, json, "first",
|
||||||
|
TRI_CreateStringReferenceJson(TRI_UNKNOWN_MEM_ZONE, copy1));
|
||||||
|
|
||||||
|
TRI_Insert3ArrayJson(TRI_UNKNOWN_MEM_ZONE, json, "second",
|
||||||
|
TRI_CreateStringReference2Json(TRI_UNKNOWN_MEM_ZONE, copy2, len2));
|
||||||
|
|
||||||
|
BOOST_CHECK_EQUAL(true, TRI_IsArrayJson(json));
|
||||||
|
|
||||||
|
// modify the string we're referring to
|
||||||
|
copy1[0] = '*';
|
||||||
|
copy1[1] = '/';
|
||||||
|
copy1[2] = '+';
|
||||||
|
copy1[len1 - 1] = '!';
|
||||||
|
|
||||||
|
copy2[0] = '*';
|
||||||
|
copy2[1] = '/';
|
||||||
|
copy2[2] = '+';
|
||||||
|
copy2[len2 - 1] = '!';
|
||||||
|
|
||||||
|
BOOST_CHECK_EQUAL("*/+ first Brown Fo!", copy1);
|
||||||
|
BOOST_CHECK_EQUAL("*/+ second Brown Fo!", copy2);
|
||||||
|
|
||||||
|
sb = TRI_CreateStringBuffer(TRI_UNKNOWN_MEM_ZONE);
|
||||||
|
STRINGIFY
|
||||||
|
BOOST_CHECK_EQUAL("{\"first\":\"*/+ first Brown Fo!\",\"second\":\"*/+ second Brown Fo!\"}", STRING_VALUE);
|
||||||
|
|
||||||
|
FREE_BUFFER
|
||||||
|
|
||||||
|
// freeing JSON should not affect our string
|
||||||
|
BOOST_CHECK_EQUAL("*/+ first Brown Fo!", copy1);
|
||||||
|
BOOST_CHECK_EQUAL("*/+ second Brown Fo!", copy2);
|
||||||
|
|
||||||
|
FREE_JSON
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief test string value (escaped)
|
/// @brief test string value (escaped)
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -664,7 +664,7 @@ int deleteDocumentOnCoordinator (
|
||||||
if (0 == json) {
|
if (0 == json) {
|
||||||
return TRI_ERROR_OUT_OF_MEMORY;
|
return TRI_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
TRI_Insert2ArrayJson(TRI_UNKNOWN_MEM_ZONE, json, "_key",
|
TRI_Insert3ArrayJson(TRI_UNKNOWN_MEM_ZONE, json, "_key",
|
||||||
TRI_CreateStringReference2Json(TRI_UNKNOWN_MEM_ZONE,
|
TRI_CreateStringReference2Json(TRI_UNKNOWN_MEM_ZONE,
|
||||||
key.c_str(), key.size()));
|
key.c_str(), key.size()));
|
||||||
bool usesDefaultShardingAttributes;
|
bool usesDefaultShardingAttributes;
|
||||||
|
@ -855,7 +855,7 @@ int getDocumentOnCoordinator (
|
||||||
if (0 == json) {
|
if (0 == json) {
|
||||||
return TRI_ERROR_OUT_OF_MEMORY;
|
return TRI_ERROR_OUT_OF_MEMORY;
|
||||||
}
|
}
|
||||||
TRI_Insert2ArrayJson(TRI_UNKNOWN_MEM_ZONE, json, "_key",
|
TRI_Insert3ArrayJson(TRI_UNKNOWN_MEM_ZONE, json, "_key",
|
||||||
TRI_CreateStringReference2Json(TRI_UNKNOWN_MEM_ZONE,
|
TRI_CreateStringReference2Json(TRI_UNKNOWN_MEM_ZONE,
|
||||||
key.c_str(), key.size()));
|
key.c_str(), key.size()));
|
||||||
bool usesDefaultShardingAttributes;
|
bool usesDefaultShardingAttributes;
|
||||||
|
@ -1244,7 +1244,7 @@ int createEdgeOnCoordinator (
|
||||||
TRI_json_t* subjson = TRI_LookupArrayJson(json, "_key");
|
TRI_json_t* subjson = TRI_LookupArrayJson(json, "_key");
|
||||||
bool userSpecifiedKey = false;
|
bool userSpecifiedKey = false;
|
||||||
string _key;
|
string _key;
|
||||||
if (0 == subjson) {
|
if (subjson == nullptr) {
|
||||||
// The user did not specify a key, let's create one:
|
// The user did not specify a key, let's create one:
|
||||||
uint64_t uid = ci->uniqid();
|
uint64_t uid = ci->uniqid();
|
||||||
_key = triagens::basics::StringUtils::itoa(uid);
|
_key = triagens::basics::StringUtils::itoa(uid);
|
||||||
|
|
|
@ -74,6 +74,7 @@ JAVASCRIPT_JSLINT = \
|
||||||
`find @srcdir@/js/apps/system/aardvark/test/specs -name "*.js"` \
|
`find @srcdir@/js/apps/system/aardvark/test/specs -name "*.js"` \
|
||||||
`find @srcdir@/js/apps/system/aardvark/test/clusterSpecs -name "*.js"` \
|
`find @srcdir@/js/apps/system/aardvark/test/clusterSpecs -name "*.js"` \
|
||||||
\
|
\
|
||||||
|
@srcdir@/js/common/modules/jsunity.js \
|
||||||
@srcdir@/js/client/client.js \
|
@srcdir@/js/client/client.js \
|
||||||
@srcdir@/js/server/server.js \
|
@srcdir@/js/server/server.js \
|
||||||
@srcdir@/js/server/upgrade-database.js \
|
@srcdir@/js/server/upgrade-database.js \
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
/*jshint strict: false */
|
||||||
|
/*global require, exports */
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief JSUnity wrapper
|
/// @brief JSUnity wrapper
|
||||||
///
|
///
|
||||||
|
@ -25,10 +27,21 @@
|
||||||
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
|
/// @author Copyright 2012, triAGENS GmbH, Cologne, Germany
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
|
||||||
|
var _ = require("underscore");
|
||||||
var internal = require("internal");
|
var internal = require("internal");
|
||||||
|
var print = internal.print;
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var console = require("console");
|
var console = require("console");
|
||||||
|
|
||||||
|
var COMPLETE={
|
||||||
|
"TOTAL": 0,
|
||||||
|
"PASSED": 0,
|
||||||
|
"FAILED": 0,
|
||||||
|
"DURATION": 0,
|
||||||
|
"RESULTS": {}
|
||||||
|
};
|
||||||
|
|
||||||
var TOTAL = 0;
|
var TOTAL = 0;
|
||||||
var PASSED = 0;
|
var PASSED = 0;
|
||||||
var FAILED = 0;
|
var FAILED = 0;
|
||||||
|
@ -71,7 +84,10 @@ jsUnity.results.fail = function (index, testName, message) {
|
||||||
|
|
||||||
jsUnity.results.end = function (passed, failed, duration) {
|
jsUnity.results.end = function (passed, failed, duration) {
|
||||||
print(" " + passed + " test(s) passed");
|
print(" " + passed + " test(s) passed");
|
||||||
print(" " + ((failed > 0) ? internal.COLORS.COLOR_RED : internal.COLORS.COLOR_RESET) + failed + " test(s) failed" + internal.COLORS.COLOR_RESET);
|
print(" " + ((failed > 0) ?
|
||||||
|
internal.COLORS.COLOR_RED :
|
||||||
|
internal.COLORS.COLOR_RESET) +
|
||||||
|
failed + " test(s) failed" + internal.COLORS.COLOR_RESET);
|
||||||
print(" " + duration + " millisecond(s) elapsed");
|
print(" " + duration + " millisecond(s) elapsed");
|
||||||
print();
|
print();
|
||||||
};
|
};
|
||||||
|
@ -89,13 +105,13 @@ jsUnity.results.end = function (passed, failed, duration) {
|
||||||
/// @brief runs a test with context
|
/// @brief runs a test with context
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
function Run (tests) {
|
function Run (testsuite) {
|
||||||
var suite = jsUnity.compile(tests);
|
var suite = jsUnity.compile(testsuite);
|
||||||
var definition = tests();
|
var definition = testsuite();
|
||||||
|
|
||||||
var tests = [];
|
var tests = [];
|
||||||
var setUp = undefined;
|
var setUp;
|
||||||
var tearDown = undefined;
|
var tearDown;
|
||||||
|
|
||||||
if (definition.hasOwnProperty("setUp")) {
|
if (definition.hasOwnProperty("setUp")) {
|
||||||
setUp = definition.setUp;
|
setUp = definition.setUp;
|
||||||
|
@ -110,12 +126,12 @@ function Run (tests) {
|
||||||
scope.tearDown = tearDown;
|
scope.tearDown = tearDown;
|
||||||
|
|
||||||
for (var key in definition) {
|
for (var key in definition) {
|
||||||
if (key.indexOf("test") == 0) {
|
if (key.indexOf("test") === 0) {
|
||||||
var test = { name : key, fn : definition[key] };
|
var test = { name : key, fn : definition[key] };
|
||||||
|
|
||||||
tests.push(test);
|
tests.push(test);
|
||||||
}
|
}
|
||||||
else if (key != "tearDown" && key != "setUp") {
|
else if (key !== "tearDown" && key !== "setUp") {
|
||||||
console.error("unknown function: %s", key);
|
console.error("unknown function: %s", key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -131,6 +147,13 @@ function Run (tests) {
|
||||||
PASSED += result.passed;
|
PASSED += result.passed;
|
||||||
FAILED += result.failed;
|
FAILED += result.failed;
|
||||||
DURATION += result.duration;
|
DURATION += result.duration;
|
||||||
|
|
||||||
|
COMPLETE.TOTAL += result.total;
|
||||||
|
COMPLETE.PASSED += result.passed;
|
||||||
|
COMPLETE.FAILED += result.failed;
|
||||||
|
COMPLETE.DURATION += result.duration;
|
||||||
|
_.defaults(COMPLETE.RESULTS, RESULTS);
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,7 +166,7 @@ function Done (suiteName) {
|
||||||
internal.printf("%d total, %d passed, %d failed, %d ms", TOTAL, PASSED, FAILED, DURATION);
|
internal.printf("%d total, %d passed, %d failed, %d ms", TOTAL, PASSED, FAILED, DURATION);
|
||||||
print();
|
print();
|
||||||
|
|
||||||
var ok = FAILED == 0;
|
var ok = FAILED === 0;
|
||||||
|
|
||||||
RESULTS.duration = DURATION;
|
RESULTS.duration = DURATION;
|
||||||
RESULTS.status = ok;
|
RESULTS.status = ok;
|
||||||
|
@ -156,7 +179,7 @@ function Done (suiteName) {
|
||||||
FAILED = 0;
|
FAILED = 0;
|
||||||
DURATION = 0;
|
DURATION = 0;
|
||||||
|
|
||||||
return RESULTS;
|
return COMPLETE.RESULTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -172,7 +195,7 @@ function RunTest (path) {
|
||||||
content = "(function(){require('jsunity').jsUnity.attachAssertions();" + content + "})";
|
content = "(function(){require('jsunity').jsUnity.attachAssertions();" + content + "})";
|
||||||
f = internal.executeScript(content, undefined, path);
|
f = internal.executeScript(content, undefined, path);
|
||||||
|
|
||||||
if (f == undefined) {
|
if (f === undefined) {
|
||||||
throw "cannot create context function";
|
throw "cannot create context function";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,6 @@
|
||||||
var db = require("org/arangodb").db;
|
var db = require("org/arangodb").db;
|
||||||
var jsunity = require("jsunity");
|
var jsunity = require("jsunity");
|
||||||
var helper = require("org/arangodb/aql-helper");
|
var helper = require("org/arangodb/aql-helper");
|
||||||
var removeAlwaysOnClusterRules = helper.removeAlwaysOnClusterRules;
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
/// @brief test suite
|
/// @brief test suite
|
||||||
|
|
Loading…
Reference in New Issue