<commit_before>var BaseNNumberMapper = require("../lib/mappers/BaseNNumberMapper");

describe("A Base-N Number Mapper", function() {

	it("has toDecimal and fromDecimal methods", function() {
		var bnnm = new BaseNNumberMapper();

		expect(typeof bnnm.toDecimal).toBe("function");
		expect(typeof bnnm.fromDecimal).toBe("function");
	});

	it("should throw a RangeError when given a negative number", function() {
		var bnnm = new BaseNNumberMapper();

		expect(function() {
			bnnm.fromDecimal(-5);
		}).toThrowError(RangeError);

		expect(function() {
			bnnm.toDecimal(-5);
		}).toThrowError(RangeError);

		expect(function() {
			bnnm.fromDecimal("-10011010");
		}).toThrowError(RangeError);
	});

	it("should throw a RangeError when given a base outside of an acceptable range", function() {
		expect(function() {
			new BaseNNumberMapper(1);
		}).toThrowError(RangeError);

		expect(function() {
			new BaseNNumberMapper(37);
		}).toThrowError(RangeError);

		expect(function() {
			new BaseNNumberMapper(-8);
		}).toThrowError(RangeError);
	});

	it("can convert binary numbers to decimal", function() {
		var baseNNumberMapper = new BaseNNumberMapper(2);

		expect(baseNNumberMapper.toDecimal(0)).toBe(0);
		expect(baseNNumberMapper.toDecimal(1)).toBe(1);
		expect(baseNNumberMapper.toDecimal(10)).toBe(2);
		expect(baseNNumberMapper.toDecimal(101010)).toBe(42);
		expect(baseNNumberMapper.toDecimal(11111111)).toBe(255);
	});

	it("can accept numbers of type string or number", function() {
		var baseNNumberMapper = new BaseNNumberMapper(2);

		expect(baseNNumberMapper.toDecimal(111)).toBe(7);
		expect(baseNNumberMapper.toDecimal("111")).toBe(7);
		expect(baseNNumberMapper.toDecimal(10101010)).toBe(170);
		expect(baseNNumberMapper.toDecimal("10101010")).toBe(170);
	});

});
<commit_msg>Add tests for BaseNNumberMapper with various bases<commit_after>var BaseNNumberMapper = require("../lib/mappers/BaseNNumberMapper");

describe("A Base-N Number Mapper", function() {

	it("has toDecimal and fromDecimal methods", function() {
		var bnnm = new BaseNNumberMapper();

		expect(typeof bnnm.toDecimal).toBe("function");
		expect(typeof bnnm.fromDecimal).toBe("function");
	});

	it("should throw a RangeError when given a negative number", function() {
		var bnnm = new BaseNNumberMapper();

		expect(function() {
			bnnm.fromDecimal(-5);
		}).toThrowError(RangeError);

		expect(function() {
			bnnm.toDecimal(-5);
		}).toThrowError(RangeError);

		expect(function() {
			bnnm.fromDecimal("-10011010");
		}).toThrowError(RangeError);
	});

	it("should throw a RangeError when given a base outside of an acceptable range", function() {
		expect(function() {
			new BaseNNumberMapper(1);
		}).toThrowError(RangeError);

		expect(function() {
			new BaseNNumberMapper(37);
		}).toThrowError(RangeError);

		expect(function() {
			new BaseNNumberMapper(-8);
		}).toThrowError(RangeError);
	});

	it("can convert binary numbers to decimal", function() {
		var baseNNumberMapper = new BaseNNumberMapper(2);

		expect(baseNNumberMapper.toDecimal(0)).toBe(0);
		expect(baseNNumberMapper.toDecimal(1)).toBe(1);
		expect(baseNNumberMapper.toDecimal(10)).toBe(2);
		expect(baseNNumberMapper.toDecimal(101010)).toBe(42);
		expect(baseNNumberMapper.toDecimal(11111111)).toBe(255);
	});

	it("can convert octal numbers to decimal", function() {
		var baseNNumberMapper = new BaseNNumberMapper(8);

		expect(baseNNumberMapper.toDecimal(0)).toBe(0);
		expect(baseNNumberMapper.toDecimal(7)).toBe(7);
		expect(baseNNumberMapper.toDecimal(123)).toBe(83);
		expect(baseNNumberMapper.toDecimal(765)).toBe(501);
		expect(baseNNumberMapper.toDecimal(1750)).toBe(1000);
		expect(baseNNumberMapper.toDecimal(23420)).toBe(10000);
	});

	it("can convert hexadecimal numbers to decimal", function() {
		var baseNNumberMapper = new BaseNNumberMapper(16);

		expect(baseNNumberMapper.toDecimal(0)).toBe(0);
		expect(baseNNumberMapper.toDecimal("F")).toBe(15);
		expect(baseNNumberMapper.toDecimal("BEEF")).toBe(48879);
		expect(baseNNumberMapper.toDecimal("ABCDEF")).toBe(11259375);
		expect(baseNNumberMapper.toDecimal("FABF00D")).toBe(262926349);
		expect(baseNNumberMapper.toDecimal(123456789)).toBe(4886718345);
	});

	it("can convert base-36 numbers to decimal", function() {
		var baseNNumberMapper = new BaseNNumberMapper(36);

		expect(baseNNumberMapper.toDecimal(0)).toBe(0);
		expect(baseNNumberMapper.toDecimal("Z")).toBe(35);
		expect(baseNNumberMapper.toDecimal("00000Z")).toBe(35);
		expect(baseNNumberMapper.toDecimal("AZ")).toBe(395);
		expect(baseNNumberMapper.toDecimal("Z00")).toBe(45360);
	});

	it("can accept numbers of type string or number", function() {
		var baseNNumberMapper = new BaseNNumberMapper(2);

		expect(baseNNumberMapper.toDecimal(111)).toBe(7);
		expect(baseNNumberMapper.toDecimal("111")).toBe(7);
		expect(baseNNumberMapper.toDecimal(10101010)).toBe(170);
		expect(baseNNumberMapper.toDecimal("10101010")).toBe(170);
	});

});

{'fraction_non_alphanumeric': 0.15633205413047868, 'fraction_numerical': 0.0508988083215512, 'mean_word_length': 6.2503660322108345, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, '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': '98151', 'n_tokens_mistral': 1869, 'n_tokens_neox': 1596, 'n_words': 264}