gflow-sink-test.vala 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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.length() == 0);
  31. assert (!s.highlight);
  32. assert (!s.active);
  33. assert (s.node == null);
  34. assert (s.sources == new List<Source>());
  35. assert (!s.is_linked ());
  36. });
  37. Test.add_func ("/gflow/sink/source",
  38. () => {
  39. Value initial = Value(typeof(int));
  40. initial.set_int (1);
  41. var s = new GFlow.SimpleSink (initial);
  42. var src = new GFlow.SimpleSource (initial);
  43. assert (s.initial != null);
  44. assert (s.val.length() == 0);
  45. assert (!s.highlight);
  46. assert (!s.active);
  47. assert (s.node == null);
  48. assert (s.sources == new List<Source>());
  49. assert (!s.is_linked ());
  50. try { s.link (src); } catch { assert_not_reached (); }
  51. assert (s.is_linked ());
  52. });
  53. Test.add_func ("/gflow/sink/source/changes",
  54. () => {
  55. Value initial = Value(typeof(int));
  56. initial.set_int (1);
  57. var s = new GFlow.SimpleSink (initial);
  58. var src = new GFlow.SimpleSource (initial);
  59. assert (s.initial != null);
  60. assert (s.val.length() == 0);
  61. assert (!s.highlight);
  62. assert (!s.active);
  63. assert (s.node == null);
  64. assert (s.sources == new List<Source>());
  65. assert (!s.is_linked ());
  66. try { s.link (src); } catch { assert_not_reached (); }
  67. assert (s.is_linked ());
  68. src.val = 10;
  69. assert (((int) src.val) == 10);
  70. assert (s.val != null);
  71. assert (( (int) s.val.nth_data(0)) == 10);
  72. src.val = "text";
  73. assert (((int) s.val.nth_data(0)) == 10);
  74. });
  75. }
  76. }