public static CBORObject RandomCBORTaggedObject(
RandomGenerator rand,
int depth)
{
var tag = 0;
if (rand.UniformInt(2) == 0)
{
int[] tagselection = { 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 30, 30,
30, 0, 1, 25, 26, 27 };
tag = tagselection[rand.UniformInt(tagselection.Length)];
}
else
{
tag = rand.UniformInt(0x1000000);
}
if (tag == 25)
{
tag = 0;
}
if (tag == 30)
{
return(CBORObject.FromObject(RandomObjects.RandomByteString(rand)));
}
for (var i = 0; i < 15; ++i)
{
CBORObject o;
// Console.WriteLine("tag "+tag+" "+i);
if (tag == 0 || tag == 1 || tag == 28 || tag == 29)
{
tag = 999;
}
if (tag == 2 || tag == 3)
{
o = CBORObject.FromObject(RandomObjects.RandomByteStringShort(rand));
}
else if (tag == 4 || tag == 5)
{
o = CBORObject.NewArray();
o.Add(CBORObject.FromObject(RandomObjects.RandomSmallIntegral(rand)));
o.Add(CBORObject.FromObject(RandomObjects.RandomEInteger(rand)));
}
else if (tag == 30)
{
o = CBORObject.NewArray();
o.Add(CBORObject.FromObject(RandomObjects.RandomSmallIntegral(rand)));
o.Add(CBORObject.FromObject(RandomObjects.RandomEInteger(rand)));
}
else
{
o = RandomCBORObject(rand, depth + 1);
}
try {
o = CBORObject.FromObjectAndTag(o, tag);
// Console.WriteLine("done");
return(o);
} catch (Exception) {
continue;
}
}
// Console.WriteLine("Failed "+tag);
return(CBORObject.Null);
}