{"size": 1969, "ext": "js", "max_stars_repo_path": "test/unit/int-data-type.js", "max_stars_repo_name": "oxygenplug/tedious", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/unit/int-data-type.js", "max_issues_repo_name": "oxygenplug/tedious", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "test/unit/int-data-type.js", "max_forks_repo_name": "oxygenplug/tedious", "max_forks_repo_forks_event_min_datetime": "2021-03-23T20:13:45.000Z", "max_forks_repo_forks_event_max_datetime": "2021-03-23T20:41:24.000Z"}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": 2, "avg_line_length": 30.2923076923, "max_line_length": 93, "alphanum_fraction": 0.562722194}
const { assert } = require('chai');
const { typeByName: { Int, SmallInt, TinyInt } } = require('../../src/data-type');
const WritableTrackingBuffer = require('../../src/tracking-buffer/writable-tracking-buffer');

describe('integer-data-types', function() {
  describe('int data type test', function() {
    const params = [
      { param: { value: 8.9 }, expected: 8 },
      { param: { value: 0.000000000001 }, expected: 0 },
      { param: { value: 8.5 }, expected: 8 }
    ];

    params.forEach(function(item) {
      it('test valid parameter values', function(done) {
        const buffer = new WritableTrackingBuffer(4 + 1);

        Int.writeParameterData(buffer, item.param, {}, () => {
          assert.equal(buffer.buffer.readInt32LE(1), item.expected);

          done();
        });
      });
    });
  });

  describe('small int data type test', function() {
    const params = [
      { param: { value: 8.9 }, expected: 8 },
      { param: { value: 0.000000000001 }, expected: 0 },
      { param: { value: 8.5 }, expected: 8 }
    ];

    params.forEach(function(item) {
      it('test valid parameter values', function(done) {
        const buffer = new WritableTrackingBuffer(4 + 1);

        SmallInt.writeParameterData(buffer, item.param, {}, () => {
          assert.equal(buffer.buffer.readInt32LE(1), item.expected);

          done();
        });
      });
    });
  });

  describe('tiny int data type test', function() {
    const params = [
      { param: { value: 8.9 }, expected: 8 },
      { param: { value: 0.000000000001 }, expected: 0 },
      { param: { value: 8.5 }, expected: 8 }
    ];

    params.forEach(function(item) {
      it('test valid parameter values', function(done) {
        const buffer = new WritableTrackingBuffer(4 + 1);
        TinyInt.writeParameterData(buffer, item.param, {}, () => {
          assert.equal(buffer.buffer.readInt32LE(1), item.expected);

          done();
        });
      });
    });
  });
});
