Sun calculation js library which is fully based on formula from http://aa.quae.nl/en/reken/zonpositie.html
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
1.3 KiB
26 lines
1.3 KiB
var assert = require('assert')
|
|
var safeRegex = require('safe-regex')
|
|
|
|
var validator = require('./')
|
|
|
|
var invalid4 = require('./fixtures/invalid-ipv4-addresses')
|
|
var invalid6 = require('./fixtures/invalid-ipv6-addresses')
|
|
var valid4 = require('./fixtures/valid-ipv4-addresses')
|
|
var valid6 = require('./fixtures/valid-ipv6-addresses')
|
|
|
|
var validate = validator()
|
|
var validate4 = validator({ version: 4 })
|
|
var validate6 = validator({ version: 6 })
|
|
|
|
var i
|
|
|
|
for (i = 0; i < validator.__all_regexes__.length; i++) assert.ok(safeRegex(validator.__all_regexes__[i]), validator.__all_regexes__[i] + ' should be safe regex')
|
|
|
|
for (i = 0; i < invalid4.length; i++) assert.strictEqual(validate4(invalid4[i]), false, invalid4[i] + ' should be invalid IPv4')
|
|
for (i = 0; i < invalid6.length; i++) assert.strictEqual(validate6(invalid6[i]), false, invalid6[i] + ' should be invalid IPv6')
|
|
|
|
for (i = 0; i < valid4.length; i++) assert.strictEqual(validate(valid4[i]), true, valid4[i] + ' should be valid IP')
|
|
for (i = 0; i < valid4.length; i++) assert.strictEqual(validate4(valid4[i]), true, valid4[i] + ' should be valid IPv4')
|
|
|
|
for (i = 0; i < valid6.length; i++) assert.strictEqual(validate(valid6[i]), true, valid6[i] + ' should be valid IP')
|
|
for (i = 0; i < valid6.length; i++) assert.strictEqual(validate6(valid6[i]), true, valid6[i] + ' should be valid IPv6')
|
|
|