mirror of
https://github.com/xibyte/jsketcher
synced 2026-01-08 08:45:26 +01:00
Test case for round rect
This commit is contained in:
parent
a538e9c8af
commit
f79527efdc
3 changed files with 29 additions and 9 deletions
|
|
@ -11,10 +11,18 @@ TCAD.test.runSuite = function() {
|
|||
|
||||
function _log(text) {
|
||||
$('#testOutput').append("<div>"+text+"</div>");
|
||||
};
|
||||
}
|
||||
|
||||
_loadFixture = function(name) {
|
||||
THE_APP.loadSketch(TCAD.test.fixtures[name]);
|
||||
APP.loadSketch(TCAD.test.fixtures[name]);
|
||||
};
|
||||
|
||||
_loadFixturesToLocalStorage = function() {
|
||||
for (var p in TCAD.test.fixtures) {
|
||||
var key = "test:" + p;
|
||||
console.log("Storing: " + key);
|
||||
localStorage.setItem("TCAD.projects." + key, JSON.stringify(TCAD.test.fixtures[p]));
|
||||
}
|
||||
};
|
||||
|
||||
_assertEq = function(expected, actual, msg) {
|
||||
|
|
@ -23,3 +31,10 @@ _assertEq = function(expected, actual, msg) {
|
|||
if (!!msg) _log(msg);
|
||||
}
|
||||
};
|
||||
|
||||
_assertEqD = function(expected, actual, precision, msg) {
|
||||
if (Math.abs(expected - actual) > precision) {
|
||||
_log("<b class='err'>*</b> Assertion Error. Expected [" + expected + "] with precision " + precision + " but was [" + actual + "]");
|
||||
if (!!msg) _log(msg);
|
||||
}
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,10 +1,15 @@
|
|||
|
||||
TCAD.test.cases.roundRect = function() {
|
||||
_loadFixture("RoundRect");
|
||||
_assertEq(31, THE_APP.viewer.parametricManager.system.length);
|
||||
// var solver = THE_APP.viewer.parametricManager.prepare([]);
|
||||
// var status = solver.solve(1);
|
||||
// _assertEq(1, status.returnCode);
|
||||
// _assertEq(1, status.evalCount);
|
||||
// _assertEq(1, status.error);
|
||||
_assertEq(31, APP.viewer.parametricManager.system.length);
|
||||
|
||||
var ep = APP.viewer.findById(28);
|
||||
var pm = APP.viewer.parametricManager;
|
||||
_assertEqD(0.00002047865, pm.prepare([]).system.error(), 0.00000000001);
|
||||
ep.x += 30;
|
||||
var solver = pm.prepare([]);
|
||||
_assertEqD(60, solver.system.error(), 0.01);
|
||||
solver.solve();
|
||||
_assertEqD(0.000005, solver.system.error(), 1e-6);
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@
|
|||
|
||||
<script>
|
||||
function start() {
|
||||
THE_APP = new TCAD.App2D();
|
||||
APP = new TCAD.App2D();
|
||||
TCAD.test.runSuite();
|
||||
}
|
||||
window.onload = function() {
|
||||
|
|
|
|||
Loading…
Reference in a new issue