You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

PythonBaseTests.cs 1.6 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using Microsoft.VisualStudio.TestTools.UnitTesting;
  2. using Tensorflow;
  3. using static Tensorflow.Binding;
  4. namespace TensorFlowNET.UnitTest
  5. {
  6. [TestClass]
  7. public class PythonBaseTests : PythonTest
  8. {
  9. [Ignore]
  10. [TestMethod]
  11. public void weakKeyDictionary_test()
  12. {
  13. var weakKeyDict = new WeakKeyDictionary<int, char>();
  14. for (int i = 0; i < 5; i++)
  15. {
  16. var c = (char)((int)'a' + i);
  17. weakKeyDict[i] = c;
  18. //Assert.AreEqual(weakKeyDict.Count, (int)(i + 1));
  19. var v = (weakKeyDict.Count == i + 1);
  20. Assert.IsTrue(v);
  21. }
  22. //Assert.AreEqual(weakKeyDict.Count, 0);
  23. var b = (weakKeyDict.Count == 0);
  24. Assert.IsTrue(b);
  25. }
  26. [TestMethod]
  27. public void isinstance_test()
  28. {
  29. var s1 = "hi";
  30. var s2 = "hello";
  31. var t1 = (s1, s2);
  32. var t2 = (s1, s2, s1);
  33. var t3 = (s2, s1);
  34. var true1 = isinstance(s1, typeof(string));
  35. var false1 = isinstance(t1, typeof(string));
  36. var true2 = isinstance(t1, t3.GetType());
  37. var false2 = isinstance(t1, t2.GetType());
  38. var true3 = isinstance(t1, (t2.GetType(), t1.GetType(), typeof(string)));
  39. var false3 = isinstance(t3, (t2.GetType(), typeof(string)));
  40. Assert.IsTrue(true1);
  41. Assert.IsTrue(true2);
  42. Assert.IsTrue(true3);
  43. Assert.IsFalse(false1);
  44. Assert.IsFalse(false2);
  45. Assert.IsFalse(false3);
  46. }
  47. }
  48. }