Skip to content

Commit

Permalink
Merge pull request #1 from felideon/master
Browse files Browse the repository at this point in the history
Upgrade pubspec to Dart 2 stable
  • Loading branch information
pd4d10 authored Aug 23, 2018
2 parents 3392689 + 16838fc commit 8a98b84
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
name: nanoid
version: 0.0.3
version: 0.0.4
author: Rongjian Zhang <pd4d10@gmail.com>
description: A tiny, secure, URL-friendly, unique string ID generator
homepage: https://github.com/pd4d10/nanoid

environment:
sdk: ">=1.24.0 <2.0.0"
sdk: ">=1.24.0 <3.0.0"

dev_dependencies:
test: ^0.12.33
test: ^1.3.0
12 changes: 6 additions & 6 deletions test/generate_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ void main() {
});

test('has flat distribution', () {
var COUNT = 100 * 1000;
var LENGTH = 5;
var ALPHABET = 'abcdefghijklmnopqrstuvwxyz';
var count = 100 * 1000;
var length = 5;
var alphabet = 'abcdefghijklmnopqrstuvwxyz';

var chars = {};
for (var i = 0; i < COUNT; i++) {
var id = generate(ALPHABET, LENGTH);
for (var i = 0; i < count; i++) {
var id = generate(alphabet, length);
for (var j = 0; j < id.length; j++) {
var char = id[j];
if (chars[char] == null) chars[char] = 0;
Expand All @@ -22,7 +22,7 @@ void main() {
}

chars.forEach((k, _) {
var distribution = (chars[k] * ALPHABET.length) / (COUNT * LENGTH);
var distribution = (chars[k] * alphabet.length) / (count * length);
expect(distribution, closeTo(1, 1));
});
});
Expand Down
4 changes: 2 additions & 2 deletions test/nanoid_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ void main() {
});

test('has no collisions', () {
var COUNT = 100 * 1000;
var count = 100 * 1000;
var used = {};
for (var i = 0; i < COUNT; i++) {
for (var i = 0; i < count; i++) {
var id = nanoid();
expect(used[id], equals(null));
used[id] = true;
Expand Down

0 comments on commit 8a98b84

Please sign in to comment.