* Bug #10415 fixed - Remove a session line in history causes the removal
[scilab.git] / scilab / modules / history_manager / tests / unit_tests / removelinehistory.dia.ref
1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2009 - DIGITEO
4 //
5 //  This file is distributed under the same license as the Scilab package.
6 // =============================================================================
7 function [] = check_history(expected)
8   actual = gethistory();
9   // ignore first line of history which indicates the current session
10   actual(1,1) = []
11   assert_checkequal(actual, expected);
12 endfunction
13 // checking removing simple lines
14 resethistory()
15 // warning: a session line will be added at the front of this history
16 addhistory("lineA");
17 addhistory("lineB");
18 addhistory("lineC");
19 addhistory("lineD");
20 removelinehistory(1);
21 check_history(['lineB';'lineC';'lineD']);
22 removelinehistory(2);
23 h = gethistory();
24 check_history(['lineB';'lineD']);
25 removelinehistory(2);
26 h = gethistory();
27 check_history(['lineB']);
28 removelinehistory(1);
29 check_history([]);
30 // check removing of session lines
31 resethistory()
32 // warning: a session line will be added at the front of this history
33 expected_history = ["// -- 26/02/2013 10:00:00 -- //";
34                     "lineA";
35                     "lineB";
36                     "// -- 26/02/2013 11:00:00 -- //";
37                     "lineC";
38                     "// -- 26/02/2013 12:00:00 -- //";
39                     "// -- 26/02/2013 13:00:00 -- //"];
40 addhistory(expected_history);
41 removelinehistory(1);
42 expected_history(1:3,1) = [];
43 check_history(expected_history);
44 removelinehistory(3);
45 expected_history(3,1) = [];
46 check_history(expected_history);
47 removelinehistory(3);
48 expected_history(3,1) = [];
49 check_history(expected_history);
50 removelinehistory(1);
51 expected_history(1:2,1) = [];
52 check_history(expected_history);
53 // check error messages
54 resethistory()
55 ierr = execstr("removelinehistory(10)", "errcatch");
56 assert_checkequal(ierr, 999);
57