Created
March 27, 2019 09:59
-
-
Save felegy/4f9357de5954d3298f576631b877af91 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using Xunit; | |
public class SidPocTest | |
{ | |
private const int DefaultSize = 8; | |
private const string DefaultAlphabet = "123456789abcdefghijkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"; | |
[Fact] | |
public void TestHasNoCollisions() | |
{ | |
const int count = 10000 * 1000; | |
var dictUsed = new Dictionary<string, bool>(); | |
foreach(var dummy in Enumerable.Range(1, count)) | |
{ | |
var result = Nanoid.Nanoid.Generate(DefaultAlphabet, DefaultSize); | |
Assert.False(dictUsed.TryGetValue(result, out var _)); | |
dictUsed.Add(result, true); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment