svnno****@sourc*****
svnno****@sourc*****
2011年 4月 8日 (金) 21:23:05 JST
Revision: 2574
http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=2574
Author: dhrname
Date: 2011-04-08 21:23:05 +0900 (Fri, 08 Apr 2011)
Log Message:
-----------
SVGUnit :: SVGAngleに関する同値分割テストと境界条件テストを追加
Modified Paths:
--------------
trunk/Spec/spec/SvgDomSpec.js
Modified: trunk/Spec/spec/SvgDomSpec.js
===================================================================
--- trunk/Spec/spec/SvgDomSpec.js 2011-04-08 12:10:09 UTC (rev 2573)
+++ trunk/Spec/spec/SvgDomSpec.js 2011-04-08 12:23:05 UTC (rev 2574)
@@ -923,9 +923,87 @@
s = svg.createSVGAngle();
});
/*デフォルト値かどうかをチェックしていく(Checking the default value of a SVGNumber interface.)*/
- it("for the default value on the property of SVGNumber", function() {
+ it("for the default value on the property of SVGAngle", function() {
expect(s.value).toEqual(0);
+ 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 (limit value analysis)", function() {
+ var t = [Number.MAX_VALUE, Number.MIN_VALUE, 0, Number.MAX_VALUE/2, -Number.MIN_VALUE];
+ 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 valid partion)*/
+ it("should be this for the value, when it calls a newValueSpecifiedUnits method (the valid partion)", 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 (the invalid partion)", 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();
+ 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 (the valid partion)", function() {
+ var unit = ["", "deg", "rad", "grad"];
+ for (var i=1,tli=4;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);
+ }
+ /*2gradにまず設定しておいて、その後、convertToSpecifiedUnitsメソッドで"deg"単位に変換する。
+ * (The 's' value set to "2cm", and convert from "cm" to "mm" unit in convertToSpecifiedUnits method.
+ */
+ s.newValueSpecifiedUnits(4, 2);
+ var sv = s.value;
+ s.convertToSpecifiedUnits(2);
+ expect(s.valueInSpecifiedUnits).toEqual(1.8);
+ expect(s.value).toEqual(sv);
+ expect(s.valueAsString).toEqual("1.8deg");
+ expect(s.unitType).toEqual(2);
+ unit = sv = null;
+ });
+ /*同値分割をして、無効同値クラスを調べておく (equivalence partitioning, the following is the invalid partion)*/
+ it("should throw a DOMException 'Not Supported Error', when it calls a convertToSpecifiedUnits method (the invalid partion)", 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();
+ ti = sn = null;
+ }
+ t = null;
+ });
});
});
\ No newline at end of file