UNPKG

gs-json

Version:

gs-JSON is a domain agnostic unifying 3D file format for geometric and semantic modelling (hence the 'gs').

178 lines (171 loc) 5.97 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.test_Attrib_constructor = test_Attrib_constructor; exports.test_Attrib_getName = test_Attrib_getName; exports.test_Attrib_setName = test_Attrib_setName; exports.test_Attrib_getGeomType = test_Attrib_getGeomType; exports.test_Attrib_getObjDataType = test_Attrib_getObjDataType; exports.test_Attrib_getValues = test_Attrib_getValues; exports.test_Attrib_getLabels = test_Attrib_getLabels; exports.test_Attrib_count = test_Attrib_count; var _gsJson = require("./gs-json"); var gs = _interopRequireWildcard(_gsJson); var _generate = require("./generate/generate"); var gen = _interopRequireWildcard(_generate); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } describe("Tests for Attrib class", function () { it("test_Attrib_constructor", function () { expect(test_Attrib_constructor()).toBe(true); }); it("test_Attrib_getName", function () { expect(test_Attrib_getName()).toBe(true); }); it("test_Attrib_setName", function () { expect(test_Attrib_setName()).toBe(true); }); it("test_Attrib_getGeomType", function () { expect(test_Attrib_getGeomType()).toBe(true); }); it("test_Attrib_getObjDataType", function () { expect(test_Attrib_getObjDataType()).toBe(true); }); it("test_Attrib_getValues", function () { expect(test_Attrib_getValues()).toBe(true); }); it("test_Attrib_getLabels", function () { expect(test_Attrib_getLabels()).toBe(true); }); it("test_Attrib_count", function () { expect(test_Attrib_count()).toBe(true); }); }); function test_Attrib_constructor() { var m = new gs.Model(); var b = m.addEntAttrib("test1", gs.EGeomType.objs, gs.EDataType.type_num); return true; } function test_Attrib_getName() { var m = new gs.Model(); var b = m.addEntAttrib("test1", gs.EGeomType.objs, gs.EDataType.type_num); if (b.getName() !== "test1") { return false; } return true; } function test_Attrib_setName() { var m = new gs.Model(); var a = m.addEntAttrib("test1", gs.EGeomType.objs, gs.EDataType.type_num); a.setName("test2"); if (a.getName() === "test1") { return false; } if (a.getName() !== "test2") { return false; } return true; } function test_Attrib_getGeomType() { var m = new gs.Model(); var b = m.addEntAttrib("test1", gs.EGeomType.objs, gs.EDataType.type_num); if (b.getGeomType() !== gs.EGeomType.objs) { return false; } return true; } function test_Attrib_getObjDataType() { var m = new gs.Model(); var b = m.addEntAttrib("test1", gs.EGeomType.objs, gs.EDataType.type_num); if (b.getDataType() !== gs.EDataType.type_num) { return false; } return true; } function test_Attrib_getValues() { var m = gen.genModelBoxWithAttribs(); var g = m.getGeom(); // get ent attrib values var ent_attribs = m.getAllEntAttribs(); var ent_attrib = ent_attribs[0]; var values1 = ent_attrib.getValues(); if (values1.length !== 8) { return false; } // add points, then get ent attrib values g.addPoints([[1, 2, 3], [2, 3, 4], [3, 4, 5]]); var values2 = ent_attribs[0].getValues(); if (values2.length !== 11) { return false; } if (values2[9] !== null) { return false; } // del points, then get ent attrib values var points = g.getAllPoints(); g.delPoint(points[5]); var values3 = ent_attribs[0].getValues(); if (values3.length !== 10) { return false; } if (values3[8] !== null) { return false; } // test topo attribs var topo_attribs = m.getAllTopoAttribs(); var topo_values1 = topo_attribs[0].getValues(); var topo_values2 = topo_attribs[1].getValues(); var topo_values3 = topo_attribs[2].getValues(); if (topo_values1.length !== 24) { return false; } if (topo_values2.length !== 24) { return false; } if (topo_values3.length !== 6) { return false; } return true; } function test_Attrib_getLabels() { var m = gen.genModelBoxWithAttribs(); var g = m.getGeom(); // test ent attrib var ent_attribs = m.getAllEntAttribs(); var ent_labels = ent_attribs[0].getLabels(); if (ent_labels.length !== 8) { return false; } // test topo attribs var topo_attribs = m.getAllTopoAttribs(); var topo_labels1 = topo_attribs[0].getLabels(); var topo_labels2 = topo_attribs[1].getLabels(); var topo_labels3 = topo_attribs[2].getLabels(); if (topo_labels1.length !== 24) { return false; } if (topo_labels2.length !== 24) { return false; } if (topo_labels3.length !== 6) { return false; } return true; } function test_Attrib_count() { var m = new gs.Model(); var a1 = [Math.floor(Math.random() * 10), Math.floor(Math.random() * 10), Math.floor(Math.random() * 10)]; var a2 = [Math.floor(Math.random() * 10), Math.floor(Math.random() * 10), Math.floor(Math.random() * 10)]; var a3 = [Math.floor(Math.random() * 10), Math.floor(Math.random() * 10), Math.floor(Math.random() * 10)]; var a4 = [Math.floor(Math.random() * 10), Math.floor(Math.random() * 10), Math.floor(Math.random() * 10)]; // add 4 points m.getGeom().addPoint(a1); m.getGeom().addPoint(a2); m.getGeom().addPoint(a3); m.getGeom().addPoint(a4); // create a point attribute, all values should be null var b = m.addEntAttrib("Color of points", gs.EGeomType.points, gs.EDataType.type_str); // if (b.count() !== 4) {return false; } return true; } //# sourceMappingURL=_attrib_tests.js.map