svnno****@sourc*****
svnno****@sourc*****
2011年 1月 17日 (月) 20:41:59 JST
Revision: 2307 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2307 Author: dhrname Date: 2011-01-17 20:41:59 +0900 (Mon, 17 Jan 2011) Log Message: ----------- 同値分割をcreateSVGLengthメソッドの調査に適用 Modified Paths: -------------- trunk/Spec/SvgDomSpec.js Modified: trunk/Spec/SvgDomSpec.js =================================================================== --- trunk/Spec/SvgDomSpec.js 2011-01-15 11:39:46 UTC (rev 2306) +++ trunk/Spec/SvgDomSpec.js 2011-01-17 11:41:59 UTC (rev 2307) @@ -74,7 +74,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ -describe("SVG Test", function() { +describe("SVG Spec in JavaScript", function() { var doc, svg; beforeEach(function() { /*前もって実行しておく変数(The variable 'doc' is a document node, and the 'svg' is a root element node.)*/ @@ -99,9 +99,9 @@ expect(s.valueInSpecifiedUnits).toEqual(0); expect(s.unitType).toEqual(1); }); - /*境界条件を調べておく*/ + /*境界条件を調べておく (limit value analysis)*/ it("should be this for the value, when it calls a newValueSpecifiedUnits method", function() { - var t = [Number.MAX_VALUE, Number.MIN_VALUE, 0]; + var t = [Number.MAX_VALUE, Number.MIN_VALUE, 0, Number.MAX_VALUE/2, Number.MIN_VALUE/2]; for (var i=0,tli=t.length;i<tli;++i) { s.newValueSpecifiedUnits(1, t[i]); expect(s.valueInSpecifiedUnits).toEqual(t[i]); @@ -109,6 +109,61 @@ expect(s.valueAsString).toEqual(t[i]+""); expect(s.unitType).toEqual(1); } + t = null; }); + /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/ + it("should be this for the value, when it calls a newValueSpecifiedUnits method", function() { + var t = [Math.PI, 10/3], num = (t[0]+"").length - 1; //無理数を作って、ぎりぎりの有効数字の桁数numをはじき出しておく + for (var i=1;i<num;++i) { + t[t.length] = Math.pow(10, i); + t[t.length] = Math.pow(10, -i); + t[t.length] = Math.pow(10, i); + t[t.length] = Math.pow(10, -i); + } + for (var i=0,tli=t.length;i<tli;++i) { + s.newValueSpecifiedUnits(1, t[i]); + expect(s.valueInSpecifiedUnits).toEqual(t[i]); + expect(s.value).toEqual(t[i]); + expect(s.valueAsString).toEqual(t[i]+""); + expect(s.unitType).toEqual(1); + } + t = null; + }); + /*同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/ + it("should throw a DOMException 'Not Supported Error', when it calls a newValueSpecifiedUnits method", function() { + var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1]; + for (var i=0,tli=t.length;i<tli;++i) { + var ti = t[i], sn = function() { + s.newValueSpecifiedUnits(ti, 0); + }; + expect(sn).toThrow("Not Supported Error"); + ti = sn = null; + } + t = null; + }); + /*同値分割をして、有効同値クラスを調べておく (Equivalence partitioning, the following is the valid partion)*/ + it("should be this for the value, when it calls a convertToSpecifiedUnits method", function() { + var unit = ["", "%", "em", "ex", "px", "cm", "mm", "in", "pt", "pc"]; + for (var i=1,tli=11;i<tli;++i) { + s.convertToSpecifiedUnits(i); + expect(s.valueInSpecifiedUnits).toEqual(0); + expect(s.value).toEqual(0); + expect(s.valueAsString).toEqual("0" + unit[i-1]); + expect(s.unitType).toEqual(i); + } + unit = null; + }); + /*同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/ + it("should throw a DOMException 'Not Supported Error', when it calls a convertToSpecifiedUnits method", function() { + var t = [Number.NEGATIVE_INFINITY, Number.POSITIVE_INFINITY, Number.NaN, {}, [], "", "1", "-1", undefined, null, 0, -1, 11, 1.1, 10.1]; + for (var i=0,tli=t.length;i<tli;++i) { + var ti = t[i], sn = function() { + s.convertToSpecifiedUnits(ti); + }; + expect(sn).toThrow("Not Supported Error"); + ti = sn = null; + } + t = null; + }); }); }); \ No newline at end of file