gflow-sink-test.vala 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */
  2. /* GFlowTest
  3. *
  4. * Copyright (C) 2015 Daniel Espinosa <esodan@gmail.com>
  5. *
  6. * librescl is free software: you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * librescl is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. * See the GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. using GFlow;
  20. public class GFlowTest.SinkTest
  21. {
  22. public static void add_tests ()
  23. {
  24. Test.add_func ("/gflow/sink",
  25. () => {
  26. Value initial = Value(typeof(int));
  27. initial.set_int (1);
  28. var s = new GFlow.SimpleSink (initial);
  29. assert (s.initial != null);
  30. assert (s.val != null);
  31. assert (s.val.holds (typeof(int)));
  32. assert (s.val.get_int () == 1);
  33. assert (s.val.type () == typeof (int));
  34. assert (!s.valid);
  35. assert (!s.highlight);
  36. assert (!s.active);
  37. assert (s.node == null);
  38. assert (s.source == null);
  39. assert (!s.is_linked ());
  40. });
  41. Test.add_func ("/gflow/sink/source",
  42. () => {
  43. Value initial = Value(typeof(int));
  44. initial.set_int (1);
  45. var s = new GFlow.SimpleSink (initial);
  46. var src = new GFlow.SimpleSource (initial);
  47. assert (s.initial != null);
  48. assert (s.val != null);
  49. assert (s.val.holds (typeof(int)));
  50. assert (s.val.get_int () == 1);
  51. assert (s.val.type () == typeof (int));
  52. assert (!s.valid);
  53. assert (!s.highlight);
  54. assert (!s.active);
  55. assert (s.node == null);
  56. assert (s.source == null);
  57. assert (!s.is_linked ());
  58. try { s.link (src); } catch { assert_not_reached (); }
  59. assert (s.is_linked ());
  60. });
  61. Test.add_func ("/gflow/sink/source/changes",
  62. () => {
  63. Value initial = Value(typeof(int));
  64. initial.set_int (1);
  65. var s = new GFlow.SimpleSink (initial);
  66. var src = new GFlow.SimpleSource (initial);
  67. assert (s.initial != null);
  68. assert (s.val != null);
  69. assert (s.val.holds (typeof(int)));
  70. assert (s.val.get_int () == 1);
  71. assert (s.val.type () == typeof (int));
  72. assert (!s.valid);
  73. assert (!s.highlight);
  74. assert (!s.active);
  75. assert (s.node == null);
  76. assert (s.source == null);
  77. assert (!s.is_linked ());
  78. try { s.link (src); } catch { assert_not_reached (); }
  79. assert (s.is_linked ());
  80. src.val = 10;
  81. assert (((int) src.val) == 10);
  82. assert (s.val != null);
  83. assert (( (int) s.val) == 10);
  84. src.val = "text";
  85. assert (((int) s.val) == 10);
  86. });
  87. }
  88. }