graph_editor.plt 1.79 KB
Newer Older
Thierry Martinez's avatar
Thierry Martinez committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
:- use_module(library(plunit)).


:- begin_tests(graph_editor).


test('new_graph', [true(Graphs == [new_graph])]) :-
  clear_model,
  new_graph,
  all_items([kind: graph], Graphs).

test('delete_graph', [true(Graphs == [])]) :-
  clear_model,
  new_graph,
  delete_graph(new_graph),
  all_items([kind: graph], Graphs).

test('set_graph_name', [true(Graphs == [my_graph])]) :-
  clear_model,
  new_graph,
  set_graph_name(my_graph),
  all_items([kind: graph], Graphs).

test('list_graphs', [true(Atom == '[0] new_graph\n')]) :-
  clear_model,
  new_graph,
  with_output_to(atom(Atom), list_graphs).

test('select_graph', [true(Item == graphA)]) :-
  clear_model,
  new_graph,
  set_graph_name(graphA),
  new_graph,
  set_graph_name(graphB),
  select_graph(graphA),
  get_current_graph(Id),
  find_item([id: Id, item: Item]).

%    draw_graph/0,
%    export_graph/1,

test('add_vertex', [true(Vertices == ['A'])]) :-
  clear_model,
  new_graph,
  add_vertex('A'),
  get_current_graph(Id),
  all_items([kind: vertex], Vertices).

test('delete_vertex', [true(Vertices == [])]) :-
  clear_model,
  new_graph,
  add_vertex('A'),
  delete_vertex('A'),
  get_current_graph(Id),
  all_items([kind: vertex], Vertices).

test('add_attribute', [true(Attributes == ['object'])]) :-
  clear_model,
  new_graph,
  add_vertex('A'),
  add_attribute('A', object),
  get_current_graph(GraphId),
  find_item([parent: GraphId, kind: vertex, key: 'A', id: VertexId]),
  all_items([parent: VertexId, kind: attribute], Attributes).

test('delete_vertex', [true(Vertices == [])]) :-
  clear_model,
  new_graph,
  add_vertex('A'),
  delete_vertex('A'),
  get_current_graph(Id),
  all_items([kind: vertex], Vertices).

%    add_attribute/2,
%    delete_attribute/2,
%    edge/1,
%    add_edge/1,
%    delete_edge/1,
%    list_edges/0

:- end_tests(graph_editor).