gflow-sink-test.vala 2.3 KB

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