本文整理汇总了C#中GenStrings.IntlStrings.GetRandomString方法的典型用法代码示例。如果您正苦于以下问题:C# IntlStrings.GetRandomString方法的具体用法?C# IntlStrings.GetRandomString怎么用?C# IntlStrings.GetRandomString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GenStrings.IntlStrings
的用法示例。
在下文中一共展示了IntlStrings.GetRandomString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Test01
public void Test01()
{
IntlStrings intl;
StringCollection sc;
// simple string values
string[] values =
{
"",
" ",
"a",
"aa",
"text",
" spaces",
"1",
"$%^#",
"2222222222222222222222222",
System.DateTime.Today.ToString(),
Int32.MaxValue.ToString()
};
int cnt = 0; // Count
// initialize IntStrings
intl = new IntlStrings();
// [] StringCollection is constructed as expected
//-----------------------------------------------------------------
sc = new StringCollection();
// [] for empty collection
//
for (int i = 0; i < values.Length; i++)
{
if (sc.IndexOf(values[i]) != -1)
{
Assert.False(true, string.Format("Error, returned {1} for empty collection", i, sc.IndexOf(values[i])));
}
}
//
// [] add simple strings and verify IndexOf()
cnt = sc.Count;
sc.AddRange(values);
if (sc.Count != values.Length)
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", sc.Count, values.Length));
}
for (int i = 0; i < values.Length; i++)
{
// verify that collection contains all added items
//
if (sc.IndexOf(values[i]) != i)
{
Assert.False(true, string.Format("Error, IndexOf returned {1} instead of {0}", i, sc.IndexOf(values[i])));
}
}
//
// Intl strings
// [] add Intl strings and verify IndexOf()
//
string[] intlValues = new string[values.Length];
// fill array with unique strings
//
for (int i = 0; i < values.Length; i++)
{
string val = intl.GetRandomString(MAX_LEN);
while (Array.IndexOf(intlValues, val) != -1)
val = intl.GetRandomString(MAX_LEN);
intlValues[i] = val;
}
int len = values.Length;
Boolean caseInsensitive = false;
for (int i = 0; i < len; i++)
{
if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper())
caseInsensitive = true;
}
cnt = sc.Count;
sc.AddRange(intlValues);
if (sc.Count != (cnt + intlValues.Length))
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", sc.Count, cnt + intlValues.Length));
}
for (int i = 0; i < intlValues.Length; i++)
{
// verify that collection contains all added items
//
if (sc.IndexOf(intlValues[i]) != values.Length + i)
{
//.........这里部分代码省略.........
示例2: Test01
public void Test01()
{
IntlStrings intl;
StringCollection sc;
// simple string values
string[] values =
{
"",
" ",
"a",
"aa",
"text",
" spaces",
"1",
"$%^#",
"2222222222222222222222222",
System.DateTime.Today.ToString(),
Int32.MaxValue.ToString()
};
int cnt = 0; // Count
// initialize IntStrings
intl = new IntlStrings();
// [] StringCollection is constructed as expected
//-----------------------------------------------------------------
sc = new StringCollection();
// [] on empty collection
//
for (int i = 0; i < values.Length; i++)
{
if (sc.Contains(values[i]))
{
Assert.False(true, string.Format("Error, returned true for empty collection", i));
}
}
// [] add simple strings and verify Contains()
//
cnt = sc.Count;
sc.AddRange(values);
if (sc.Count != values.Length)
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", sc.Count, values.Length));
}
for (int i = 0; i < values.Length; i++)
{
// verify that collection contains all added items
//
if (!sc.Contains(values[i]))
{
Assert.False(true, string.Format("Error, collection doesn't contain item \"{1}\"", i, values[i]));
}
}
//
// Intl strings
// [] add Intl strings and verify Contains()
//
string[] intlValues = new string[values.Length];
// fill array with unique strings
//
for (int i = 0; i < values.Length; i++)
{
string val = intl.GetRandomString(MAX_LEN);
while (Array.IndexOf(intlValues, val) != -1)
val = intl.GetRandomString(MAX_LEN);
intlValues[i] = val;
}
int len = values.Length;
Boolean caseInsensitive = false;
for (int i = 0; i < len; i++)
{
if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper())
caseInsensitive = true;
}
cnt = sc.Count;
sc.AddRange(intlValues);
if (sc.Count != (cnt + intlValues.Length))
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", sc.Count, cnt + intlValues.Length));
}
for (int i = 0; i < intlValues.Length; i++)
{
// verify that collection contains all added items
//
if (!sc.Contains(intlValues[i]))
//.........这里部分代码省略.........
示例3: Test01
public void Test01()
{
IntlStrings intl;
NameValueCollection nvc;
// simple string values
string[] values =
{
"",
" ",
"a",
"aA",
"text",
" SPaces",
"1",
"$%^#",
"2222222222222222222222222",
System.DateTime.Today.ToString(),
Int32.MaxValue.ToString()
};
// keys for simple string values
string[] keys =
{
"zero",
"oNe",
" ",
"",
"aa",
"1",
System.DateTime.Today.ToString(),
"$%^#",
Int32.MaxValue.ToString(),
" spaces",
"2222222222222222222222222"
};
int cnt = 0; // Count
// initialize IntStrings
intl = new IntlStrings();
// [] NameValueCollection is constructed as expected
//-----------------------------------------------------------------
nvc = new NameValueCollection();
// [] add simple strings
//
for (int i = 0; i < values.Length; i++)
{
cnt = nvc.Count;
nvc.Add(keys[i], values[i]);
if (nvc.Count != cnt + 1)
{
Assert.False(true, string.Format("Error, count is {1} instead of {2}", i, nvc.Count, cnt + 1));
}
// verify that collection contains newly added item
//
if (Array.IndexOf(nvc.AllKeys, keys[i]) < 0)
{
Assert.False(true, string.Format("Error, collection doesn't contain key of new item", i));
}
// access the item
//
if (String.Compare(nvc[keys[i]], values[i]) != 0)
{
Assert.False(true, string.Format("Error, returned item \"{1}\" instead of \"{2}\"", i, nvc[keys[i]], values[i]));
}
}
//
// Intl strings
// [] add Intl strings
//
int len = values.Length;
string[] intlValues = new string[len * 2];
// fill array with unique strings
//
for (int i = 0; i < len * 2; i++)
{
string val = intl.GetRandomString(MAX_LEN);
while (Array.IndexOf(intlValues, val) != -1)
val = intl.GetRandomString(MAX_LEN);
intlValues[i] = val;
}
Boolean caseInsensitive = false;
for (int i = 0; i < len * 2; i++)
{
if (intlValues[i].Length != 0 && intlValues[i].ToLowerInvariant() == intlValues[i].ToUpperInvariant())
caseInsensitive = true;
}
//
//.........这里部分代码省略.........
示例4: Test01
//.........这里部分代码省略.........
if (nvc.Count != len)
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", nvc.Count, values.Length));
}
//
for (int i = 0; i < len; i++)
{
cnt = nvc.Count;
nvc.Remove(keys[i]);
if (nvc.Count != cnt - 1)
{
Assert.False(true, string.Format("Error, returned: failed to remove item", i));
}
ks = nvc.AllKeys;
if (Array.IndexOf(ks, keys[i]) > -1)
{
Assert.False(true, string.Format("Error, removed wrong item", i));
}
}
//
// Intl strings
// [] Remove() on collection filled with Intl strings
//
string[] intlValues = new string[len * 2];
// fill array with unique strings
//
for (int i = 0; i < len * 2; i++)
{
string val = intl.GetRandomString(MAX_LEN);
while (Array.IndexOf(intlValues, val) != -1)
val = intl.GetRandomString(MAX_LEN);
intlValues[i] = val;
}
cnt = nvc.Count;
for (int i = 0; i < len; i++)
{
nvc.Add(intlValues[i + len], intlValues[i]);
}
if (nvc.Count != (cnt + len))
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", nvc.Count, cnt + len));
}
for (int i = 0; i < len; i++)
{
//
cnt = nvc.Count;
nvc.Remove(intlValues[i + len]);
if (nvc.Count != cnt - 1)
{
Assert.False(true, string.Format("Error, returned: failed to remove item", i));
}
ks = nvc.AllKeys;
if (Array.IndexOf(ks, intlValues[i + len]) > -1)
{
Assert.False(true, string.Format("Error, removed wrong item", i));
}
}
示例5: Test01
//.........这里部分代码省略.........
}
if (hd.Count != len + cnt)
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", hd.Count, len + cnt));
}
// verify new keys
for (int i = 0; i < len; i++)
{
if (!hd.Contains(keysLong[i]))
{
Assert.False(true, string.Format("Error, doesn't contain \"{1}\"", i, keysLong[i]));
}
}
// verify old keys
for (int i = 0; i < valuesShort.Length; i++)
{
if (!hd.Contains(keysShort[i]))
{
Assert.False(true, string.Format("Error, doesn't contain \"{1}\"", i, keysShort[i]));
}
}
//
// [] Intl strings and Contains()
//
string[] intlValues = new string[len * 2];
// fill array with unique strings
//
for (int i = 0; i < len * 2; i++)
{
string val = intl.GetRandomString(MAX_LEN);
while (Array.IndexOf(intlValues, val) != -1)
val = intl.GetRandomString(MAX_LEN);
intlValues[i] = val;
}
hd.Clear();
for (int i = 0; i < len; i++)
{
hd.Add(intlValues[i + len], intlValues[i]);
}
if (hd.Count != (len))
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", hd.Count, len));
}
for (int i = 0; i < len; i++)
{
//
if (!hd.Contains(intlValues[i + len]))
{
Assert.False(true, string.Format("Error, doesn't contain \"{1}\"", i, intlValues[i + len]));
}
}
//
// [] Case sensitivity
// by default HybridDictionary is case-sensitive
//
示例6: Test01
//.........这里部分代码省略.........
for (int i = 0; i < len; i++)
{
cnt = hd.Count;
hd.Remove(keysLong[i]);
if (hd.Count != cnt - 1)
{
Assert.False(true, string.Format("Error, failed to remove item", i));
}
if (hd.Contains(keysLong[i]))
{
Assert.False(true, string.Format("Error, removed wrong item", i));
}
// remove second time
hd.Remove(keysLong[i]);
if (hd.Count != cnt - 1)
{
Assert.False(true, string.Format("Error, failed when Remove() second time", i));
}
}
//
// [] Remove() on long dictionary with Intl strings
// Intl strings
//
len = valuesLong.Length;
string[] intlValues = new string[len * 2];
// fill array with unique strings
//
for (int i = 0; i < len * 2; i++)
{
string val = intl.GetRandomString(MAX_LEN);
while (Array.IndexOf(intlValues, val) != -1)
val = intl.GetRandomString(MAX_LEN);
intlValues[i] = val;
}
cnt = hd.Count;
for (int i = 0; i < len; i++)
{
hd.Add(intlValues[i + len], intlValues[i]);
}
if (hd.Count != (cnt + len))
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", hd.Count, cnt + len));
}
for (int i = 0; i < len; i++)
{
//
cnt = hd.Count;
hd.Remove(intlValues[i + len]);
if (hd.Count != cnt - 1)
{
Assert.False(true, string.Format("Error, failed to remove item", i));
}
if (hd.Contains(intlValues[i + len]))
{
Assert.False(true, string.Format("Error, removed wrong item", i));
}
}
// [] Remove() on short dictionary with Intl strings
示例7: Test01
public void Test01()
{
IntlStrings intl;
NameValueCollection nvc;
string[] vls; // values collection
// simple string values
string[] values =
{
"",
" ",
"a",
"aA",
"text",
" SPaces",
"1",
"$%^#",
"2222222222222222222222222",
System.DateTime.Today.ToString(),
Int32.MaxValue.ToString()
};
// keys for simple string values
string[] keys =
{
"zero",
"oNe",
" ",
"",
"aa",
"1",
System.DateTime.Today.ToString(),
"$%^#",
Int32.MaxValue.ToString(),
" spaces",
"2222222222222222222222222"
};
int cnt = 0; // Count
// [] initialize IntStrings
intl = new IntlStrings();
// [] NameValueCollection is constructed as expected
//-----------------------------------------------------------------
nvc = new NameValueCollection();
// [] GetValues() on empty collection
//
if (nvc.GetValues(null) != null)
{
Assert.False(true, "Error, returned non-null");
}
if (nvc.GetValues("some_string") != null)
{
Assert.False(true, "Error, returned non-null");
}
// [] GetValues() on collection filled with simple strings
//
cnt = nvc.Count;
int len = values.Length;
for (int i = 0; i < len; i++)
{
nvc.Add(keys[i], values[i]);
}
if (nvc.Count != len)
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", nvc.Count, values.Length));
}
//
for (int i = 0; i < len; i++)
{
vls = nvc.GetValues(keys[i]);
if (vls.Length != 1)
{
Assert.False(true, string.Format("Error, returned number of strings {1} instead of 1", i, vls.Length));
}
if (String.Compare(vls[0], values[i]) != 0)
{
Assert.False(true, string.Format("Error, returned: \"{1}\", expected \"{2}\"", i, vls[0], values[i]));
}
}
//
// Intl strings
// [] GetValues() on collection filled with Intl strings
//
string[] intlValues = new string[len * 2];
// fill array with unique strings
//
for (int i = 0; i < len * 2; i++)
{
string val = intl.GetRandomString(MAX_LEN);
while (Array.IndexOf(intlValues, val) != -1)
//.........这里部分代码省略.........
示例8: Test01
//.........这里部分代码省略.........
sc.Clear();
cnt = sc.Count;
sc.AddRange(values);
if (sc.Count != values.Length)
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", sc.Count, values.Length));
}
destination = new string[values.Length * 2];
sc.CopyTo(destination, values.Length);
for (int i = 0; i < values.Length; i++)
{
// verify that collection is copied correctly
//
if (String.Compare(sc[i], destination[i + values.Length]) != 0)
{
Assert.False(true, string.Format("Error, copied \"{1}\" instead of \"{2}\"", i, destination[i + values.Length], sc[i]));
}
}
//
// Intl strings
// [] add intl strings and CopyTo([], 0)
//
string[] intlValues = new string[values.Length];
// fill array with unique strings
//
for (int i = 0; i < values.Length; i++)
{
string val = intl.GetRandomString(MAX_LEN);
while (Array.IndexOf(intlValues, val) != -1)
val = intl.GetRandomString(MAX_LEN);
intlValues[i] = val;
}
sc.Clear();
sc.AddRange(intlValues);
if (sc.Count != (intlValues.Length))
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", sc.Count, intlValues.Length));
}
destination = new string[intlValues.Length];
sc.CopyTo(destination, 0);
for (int i = 0; i < intlValues.Length; i++)
{
// verify that collection is copied correctly
//
if (String.Compare(sc[i], destination[i]) != 0)
{
Assert.False(true, string.Format("Error, copied \"{1}\" instead of \"{2}\"", i, destination[i], sc[i]));
}
}
//
// Intl strings
// [] add intl strings and CopyTo([], middle_index)
//
sc.Clear();
示例9: Test01
public void Test01()
{
IntlStrings intl;
HybridDictionary hd;
const int BIG_LENGTH = 100;
// simple string values
string[] valuesShort =
{
"",
" ",
"$%^#",
System.DateTime.Today.ToString(),
Int32.MaxValue.ToString()
};
// keys for simple string values
string[] keysShort =
{
Int32.MaxValue.ToString(),
" ",
System.DateTime.Today.ToString(),
"",
"$%^#"
};
string[] valuesLong = new string[BIG_LENGTH];
string[] keysLong = new string[BIG_LENGTH];
int cnt = 0; // Count
// initialize IntStrings
intl = new IntlStrings();
for (int i = 0; i < BIG_LENGTH; i++)
{
valuesLong[i] = "Item" + i;
keysLong[i] = "keY" + i;
}
// [] HybridDictionary is constructed as expected
//-----------------------------------------------------------------
// [] simple strings
hd = new HybridDictionary();
for (int i = 0; i < valuesShort.Length; i++)
{
cnt = hd.Count;
hd.Add(keysShort[i], valuesShort[i]);
if (hd.Count != cnt + 1)
{
Assert.False(true, string.Format("Error, count is {1} instead of {2}", i, hd.Count, cnt + 1));
}
// access the item
//
if (String.Compare(hd[keysShort[i]].ToString(), valuesShort[i]) != 0)
{
Assert.False(true, string.Format("Error, returned item \"{1}\" instead of \"{2}\"", i, hd[keysShort[i]], valuesShort[i]));
}
}
// increase the number of items
for (int i = 0; i < valuesLong.Length; i++)
{
cnt = hd.Count;
hd.Add(keysLong[i], valuesLong[i]);
if (hd.Count != cnt + 1)
{
Assert.False(true, string.Format("Error, count is {1} instead of {2}", i, hd.Count, cnt + 1));
}
// access the item
//
if (String.Compare(hd[keysLong[i]].ToString(), valuesLong[i]) != 0)
{
Assert.False(true, string.Format("Error, returned item \"{1}\" instead of \"{2}\"", i, hd[keysLong[i]], valuesLong[i]));
}
}
//
// [] Intl strings
//
int len = valuesShort.Length;
hd.Clear();
string[] intlValues = new string[len * 2];
// fill array with unique strings
//
for (int i = 0; i < len * 2; i++)
{
string val = intl.GetRandomString(MAX_LEN);
while (Array.IndexOf(intlValues, val) != -1)
val = intl.GetRandomString(MAX_LEN);
intlValues[i] = val;
}
//.........这里部分代码省略.........
示例10: Test01
public void Test01()
{
IntlStrings intl;
StringDictionary sd;
// simple string values
string[] values =
{
"",
" ",
"a",
"aa",
"text",
" spaces",
"1",
"$%^#",
"2222222222222222222222222",
System.DateTime.Today.ToString(),
Int32.MaxValue.ToString()
};
// keys for simple string values
string[] keys =
{
"zero",
"one",
" ",
"",
"aa",
"1",
System.DateTime.Today.ToString(),
"$%^#",
Int32.MaxValue.ToString(),
" spaces",
"2222222222222222222222222"
};
int cnt = 0; // Count
string ind; // key
// initialize IntStrings
intl = new IntlStrings();
// [] StringDictionary is constructed as expected
//-----------------------------------------------------------------
sd = new StringDictionary();
// [] Add() simple strings
//
for (int i = 0; i < values.Length; i++)
{
cnt = sd.Count;
sd.Add(keys[i], values[i]);
if (sd.Count != cnt + 1)
{
Assert.False(true, string.Format("Error, count is {1} instead of {2}", i, sd.Count, cnt + 1));
}
// verify that collection contains newly added item
//
if (!sd.ContainsValue(values[i]))
{
Assert.False(true, string.Format("Error, collection doesn't contain value of new item", i));
}
if (!sd.ContainsKey(keys[i]))
{
Assert.False(true, string.Format("Error, collection doesn't contain key of new item", i));
}
// access the item
//
if (String.Compare(sd[keys[i]], values[i]) != 0)
{
Assert.False(true, string.Format("Error, returned item \"{1}\" instead of \"{2}\"", i, sd[keys[i]], values[i]));
}
}
//
// Intl strings
// [] Add() Intl strings
//
int len = values.Length;
string[] intlValues = new string[len * 2];
// fill array with unique strings
//
for (int i = 0; i < len * 2; i++)
{
string val = intl.GetRandomString(MAX_LEN);
while (Array.IndexOf(intlValues, val) != -1)
val = intl.GetRandomString(MAX_LEN);
intlValues[i] = val;
}
Boolean caseInsensitive = false;
for (int i = 0; i < len * 2; i++)
{
if (intlValues[i].Length != 0 && intlValues[i].ToLowerInvariant() == intlValues[i].ToUpperInvariant())
caseInsensitive = true;
//.........这里部分代码省略.........
示例11: Test01
//.........这里部分代码省略.........
{
ld.Add(keys[i], values[i]);
}
if (ld.Count != len)
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, len));
}
ks = ld.Keys;
if (ks.Count != len)
{
Assert.False(true, string.Format("Error, returned Keys.Count = {0}", ks.Count));
}
arr = Array.CreateInstance(typeof(Object), len);
ks.CopyTo(arr, 0);
for (int i = 0; i < len; i++)
{
ind = Array.IndexOf(arr, keys[i]);
if (ind < 0)
{
Assert.False(true, string.Format("Error, Keys doesn't contain \"{1}\" key. Search result: {2}", i, keys[i], ind));
}
}
//
// get Keys on dictionary with identical values
//
// [] get Keys for filled dictionary with identical value
//
ld.Clear();
string intlStr = intl.GetRandomString(MAX_LEN);
ld.Add("keykey", intlStr); // 1st key
for (int i = 0; i < len; i++)
{
ld.Add(keys[i], values[i]);
}
ld.Add("keyKey", intlStr); // 2nd key
if (ld.Count != len + 2)
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", ld.Count, len + 2));
}
// get Keys
//
ks = ld.Keys;
if (ks.Count != ld.Count)
{
Assert.False(true, string.Format("Error, returned Keys.Count = {0}", ks.Count));
}
arr = Array.CreateInstance(typeof(Object), len + 2);
ks.CopyTo(arr, 0);
for (int i = 0; i < len; i++)
{
ind = Array.IndexOf(arr, keys[i]);
if (ind < 0)
{
Assert.False(true, string.Format("Error, Keys doesn't contain \"{1}\" key", i, keys[i]));
}
}
ind = Array.IndexOf(arr, "keykey");
if (ind < 0)
示例12: Test01
public void Test01()
{
IntlStrings intl;
NameValueCollection nvc;
// simple string values
string[] values =
{
"",
" ",
"a",
"aA",
"text",
" SPaces",
"1",
"$%^#",
"2222222222222222222222222",
System.DateTime.Today.ToString(),
Int32.MaxValue.ToString()
};
// keys for simple string values
string[] keys =
{
"zero",
"oNe",
" ",
"",
"aa",
"1",
System.DateTime.Today.ToString(),
"$%^#",
Int32.MaxValue.ToString(),
" spaces",
"2222222222222222222222222"
};
int cnt = 0; // Count
string[] ks; // keys array
// initialize IntStrings
intl = new IntlStrings();
// [] NameValueCollection is constructed as expected
//-----------------------------------------------------------------
nvc = new NameValueCollection();
// [] AllKeys on empty collection
//
if (nvc.Count > 0)
nvc.Clear();
ks = nvc.AllKeys;
if (ks.Length != 0)
{
Assert.False(true, string.Format("Error, number of keys is {0} instead of 0", ks.Length));
}
// [] AllKeys on collection filled with simple strings
//
for (int i = 0; i < values.Length; i++)
{
cnt = nvc.Count;
nvc.Add(keys[i], values[i]);
if (nvc.Count != cnt + 1)
{
Assert.False(true, string.Format("Error, count is {1} instead of {2}", i, nvc.Count, cnt + 1));
}
// verify that collection contains newly added item
//
if (nvc.AllKeys.Length != cnt + 1)
{
Assert.False(true, string.Format("Error, incorrect Keys array", i));
}
if (Array.IndexOf(nvc.AllKeys, keys[i]) < 0)
{
Assert.False(true, string.Format("Error, collection doesn't contain key of new item", i));
}
}
//
// Intl strings
// [] AllKeys on collection filled with Intl strings
//
int len = values.Length;
string[] intlValues = new string[len * 2];
// fill array with unique strings
//
for (int i = 0; i < len * 2; i++)
{
string val = intl.GetRandomString(MAX_LEN);
while (Array.IndexOf(intlValues, val) != -1)
val = intl.GetRandomString(MAX_LEN);
intlValues[i] = val;
}
//.........这里部分代码省略.........
示例13: Test01
//.........这里部分代码省略.........
hd.CopyTo(destination, len);
//
//
en = hd.GetEnumerator();
en.MoveNext();
for (int i = 0; i < len; i++)
{
// verify that dictionary is copied correctly
//
Object k = en.Key;
if (String.Compare(hd[k].ToString(), ((DictionaryEntry)destination.GetValue(i + len)).Value.ToString()) != 0)
{
Assert.False(true, string.Format("Error, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i + len)).Value, hd[k]));
}
// verify keysShort
if (String.Compare(k.ToString(), ((DictionaryEntry)destination.GetValue(i + len)).Key.ToString()) != 0)
{
Assert.False(true, string.Format("Error, copied \"{1}\" instead of \"{2}\"", i, ((DictionaryEntry)destination.GetValue(i + len)).Key, k));
}
en.MoveNext();
}
//
// [] many Intl strings and CopyTo(Array, 0)
//
string[] intlValues = new string[len * 2];
// fill array with unique strings
//
for (int i = 0; i < len * 2; i++)
{
string val = intl.GetRandomString(MAX_LEN);
while (Array.IndexOf(intlValues, val) != -1)
val = intl.GetRandomString(MAX_LEN);
intlValues[i] = val;
}
Boolean caseInsensitive = false;
for (int i = 0; i < len * 2; i++)
{
if (intlValues[i].Length != 0 && intlValues[i].ToLower() == intlValues[i].ToUpper())
caseInsensitive = true;
}
hd.Clear();
for (int i = 0; i < len; i++)
{
hd.Add(intlValues[i + len], intlValues[i]);
}
if (hd.Count != (len))
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", hd.Count, len));
}
destination = Array.CreateInstance(typeof(Object), len);
hd.CopyTo(destination, 0);
//
//
en = hd.GetEnumerator();
en.MoveNext();
for (int i = 0; i < len; i++)
{
// verify that dictionary is copied correctly
//
示例14: Test01
//.........这里部分代码省略.........
}
cnt = nvc1.Count;
nvc1.Add(nvc);
if (nvc1.Count != cnt + nvc.Count)
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", nvc1.Count, cnt + nvc.Count));
}
//
for (int i = 0; i < len; i++)
{
if (String.Compare(nvc1[keys[i]], values[i]) != 0)
{
Assert.False(true, string.Format("Error, returned: \"{1}\", expected \"{2}\"", i, nvc[keys[i]], values[i]));
}
if (String.Compare(nvc1["k" + i], "v" + i) != 0)
{
Assert.False(true, string.Format("Error, returned: \"{1}\", expected \"{2}\"", i, nvc["k" + i], "v" + i));
}
}
//
// Intl strings
// [] Add(intl_strings_coll) to empty collection
//
string[] intlValues = new string[len * 2];
// fill array with unique strings
//
for (int i = 0; i < len * 2; i++)
{
string val = intl.GetRandomString(MAX_LEN);
while (Array.IndexOf(intlValues, val) != -1)
val = intl.GetRandomString(MAX_LEN);
intlValues[i] = val;
}
Boolean caseInsensitive = false;
for (int i = 0; i < len * 2; i++)
{
if (intlValues[i].Length != 0 && intlValues[i].ToLowerInvariant() == intlValues[i].ToUpperInvariant())
caseInsensitive = true;
}
// fill init collection with intl strings
nvc.Clear();
for (int i = 0; i < len; i++)
{
nvc.Add(intlValues[i + len], intlValues[i]);
}
if (nvc.Count != (len))
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", nvc.Count, len));
}
// add filled collection to tested empty collection
nvc1.Clear();
nvc1.Add(nvc);
for (int i = 0; i < len; i++)
{
//
if (String.Compare(nvc1[intlValues[i + len]], intlValues[i]) != 0)
示例15: Test01
//.........这里部分代码省略.........
}
if (nvc.Count != len)
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", nvc.Count, values.Length));
}
destination = new string[len * 2];
nvc.CopyTo(destination, len);
//
// order of items is the same as they wer in collection
//
for (int i = 0; i < len; i++)
{
// verify that collection is copied correctly
//
if (String.Compare(nvc[i], destination[i + len]) != 0)
{
Assert.False(true, string.Format("Error, copied \"{1}\" instead of \"{2}\"", i, destination[i + len], nvc[i]));
}
}
//
// Intl strings
// [] CopyTo(array, 0) collection with Intl strings
//
string[] intlValues = new string[len * 2];
// fill array with unique strings
//
for (int i = 0; i < len * 2; i++)
{
string val = intl.GetRandomString(MAX_LEN);
while (Array.IndexOf(intlValues, val) != -1)
val = intl.GetRandomString(MAX_LEN);
intlValues[i] = val;
}
Boolean caseInsensitive = false;
for (int i = 0; i < len * 2; i++)
{
if (intlValues[i].Length != 0 && intlValues[i].ToLowerInvariant() == intlValues[i].ToUpperInvariant())
caseInsensitive = true;
}
nvc.Clear();
for (int i = 0; i < len; i++)
{
nvc.Add(intlValues[i + len], intlValues[i]);
}
if (nvc.Count != (len))
{
Assert.False(true, string.Format("Error, count is {0} instead of {1}", nvc.Count, len));
}
destination = new string[len];
nvc.CopyTo(destination, 0);
//
// order of items is the same as they wer in collection
//
for (int i = 0; i < len; i++)
{
// verify that collection is copied correctly
//