<commit_before>var assert = require("assert");
var Help   = require("../help");

describe("Read Holding Registers", function () {
	it("should be [ address, quantity ] => [ buffer block, buffer block, .. ]", function () {
		for (var i = 0; i < Help.trials; i++) {
			var address  = Math.round(Math.random() * 100);
			var blocks = Help.randomBlockList(10 + Math.round(Math.random() * 500), 2);

			assert.deepEqual(
				{ address : address, quantity : blocks.length },
				Help.modbus.ReadHoldingRegisters.Request.parse(
					Help.modbus.ReadHoldingRegisters.Request.build(address, blocks.length)
				)
			);

			if (blocks.length > 127) {
				assert.throws(
					function () {
						Help.modbus.ReadHoldingRegisters.Response.build(blocks)
					},
					/out of bounds/
				);
			} else {
				assert.deepEqual(
					blocks,
					Help.modbus.ReadHoldingRegisters.Response.parse(
						Help.modbus.ReadHoldingRegisters.Response.build(blocks)
					)
				);
			}
		}
	});
});<commit_msg>adds a new test<commit_after>var assert = require("assert");
var Help   = require("../help");

describe("Read Holding Registers", function () {
	it("should be [ address, quantity ] => [ buffer block, buffer block, .. ]", function () {
		for (var i = 0; i < Help.trials; i++) {
			var address  = Math.round(Math.random() * 100);
			var blocks = Help.randomBlockList(10 + Math.round(Math.random() * 500), 2);

			assert.deepEqual(
				{ address : address, quantity : blocks.length },
				Help.modbus.ReadHoldingRegisters.Request.parse(
					Help.modbus.ReadHoldingRegisters.Request.build(address, blocks.length)
				)
			);

			if (blocks.length > 127) {
				assert.throws(
					function () {
						Help.modbus.ReadHoldingRegisters.Response.build(blocks)
					},
					/out of bounds/
				);
			} else {
				assert.deepEqual(
					blocks,
					Help.modbus.ReadHoldingRegisters.Response.parse(
						Help.modbus.ReadHoldingRegisters.Response.build(blocks)
					)
				);
			}
		}
	});

	it("should be [ address, quantity ] => buffer", function () {
		for (var i = 0; i < Help.trials; i++) {
			var address = Math.round(Math.random() * 100);
			var blocks  = Help.randomBlock(7);

			assert.deepEqual(
				{ address : address, quantity : blocks.length },
				Help.modbus.ReadHoldingRegisters.Request.parse(
					Help.modbus.ReadHoldingRegisters.Request.build(address, blocks.length)
				)
			);
		}
	});
});
{'fraction_non_alphanumeric': 0.15323257766582704, 'fraction_numerical': 0.013014273719563391, 'mean_word_length': 3.0253378378378377, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '358575', 'n_tokens_mistral': 981, 'n_tokens_neox': 769, 'n_words': 147}