dee

Merge lp:~mhr3/dee/more-tests into lp:dee

Proposed by Michal Hruby
Status: Merged
Approved by: Paweł Stołowski
Approved revision: 407
Merged at revision: 427
Proposed branch: lp:~mhr3/dee/more-tests
Merge into: lp:dee
Prerequisite: lp:~mhr3/dee/fix-insert-sorted
Diff against target: 207 lines (+114/-12)
3 files modified
src/dee-marshal.list (+0/-9)
tests/test-filter-model.c (+65/-3)
tests/test-transaction.c (+49/-0)
To merge this branch: bzr merge lp:~mhr3/dee/more-tests
Reviewer Review Type Date Requested Status
Paweł Stołowski Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+152482@code.launchpad.net

This proposal supersedes a proposal from 2013-03-08.

Commit message

Increase the test coverage

Description of the change

Increase the test coverage

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Paweł Stołowski (stolowski) wrote :

54 + /* Let's also test dee_model_prev at least once */
55 + g_assert (dee_model_get_first_iter (m) == dee_model_prev (m, iter));

Can you add a couple more checks for _prev? E.g. prev originating from dee_model_last_iter and dee_model_prev (m, dee_model_get_first_iter (m))?

163 + dee_model_append (fix->txn, TRUE, 27, 27, 27,
164 + G_GINT64_CONSTANT (27), G_GUINT64_CONSTANT (27),
165 + 27.0, "TwentySeven");

I think it would be better to use different value for every column.

review: Needs Fixing
lp:~mhr3/dee/more-tests updated
406. By Michal Hruby

Merge trunk

407. By Michal Hruby

Act on review comments

Revision history for this message
Michal Hruby (mhr3) wrote :

> Can you add a couple more checks for _prev? E.g. prev originating from
> dee_model_last_iter and dee_model_prev (m, dee_model_get_first_iter (m))?

Added except prev(first) as that is an invalid operation in dee terms.

> I think it would be better to use different value for every column.

Right, fixed.

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Paweł Stołowski (stolowski) wrote :

+1

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/dee-marshal.list'
2--- src/dee-marshal.list 2012-01-05 19:27:06 +0000
3+++ src/dee-marshal.list 2013-05-31 12:41:39 +0000
4@@ -1,12 +1,3 @@
5-# DeeSharedModel::RowsAdded, DbusSharedModel::RowsChanged
6-VOID:BOXED,BOXED,BOXED
7-
8-# DeeSharedModel::RowsRemoved
9-VOID:BOXED,BOXED
10-
11 # DeeSharedModel
12 VOID:UINT64,UINT64
13
14-# DeePeer::bye
15-VOID:STRING,STRING
16-
17
18=== modified file 'tests/test-filter-model.c'
19--- tests/test-filter-model.c 2013-01-04 17:53:43 +0000
20+++ tests/test-filter-model.c 2013-05-31 12:41:39 +0000
21@@ -39,6 +39,8 @@
22 gconstpointer data);
23 static void test_discard_all_append_notify (FilterFixture *fix,
24 gconstpointer data);
25+static void test_change_backend (FilterFixture *fix,
26+ gconstpointer data);
27 static void test_collator_asc (FilterFixture *fix,
28 gconstpointer data);
29 static void test_collator_desc (FilterFixture *fix,
30@@ -64,6 +66,8 @@
31 setup, test_discard_all, teardown);
32 g_test_add (DOMAIN"/DiscardAllAppendNotify", FilterFixture, 0,
33 setup, test_discard_all_append_notify, teardown);
34+ g_test_add (DOMAIN"/ChangeBackend", FilterFixture, 0,
35+ setup, test_change_backend, teardown);
36 g_test_add (DOMAIN"/CollatorAscending", FilterFixture, 0,
37 setup, test_collator_asc, teardown);
38 g_test_add (DOMAIN"/CollatorDescending", FilterFixture, 0,
39@@ -71,7 +75,7 @@
40 g_test_add (DOMAIN"/Key", FilterFixture, 0,
41 setup, test_key, teardown);
42 g_test_add (DOMAIN"/Any", FilterFixture, 0,
43- setup, test_any, teardown);
44+ setup, test_any, teardown);
45 g_test_add (DOMAIN"/Regex", FilterFixture, 0,
46 setup, test_regex, teardown);
47 }
48@@ -201,13 +205,15 @@
49 g_assert (!dee_model_is_last (m, iter));
50 g_assert_cmpint (1, ==, dee_model_get_int32 (m, iter, 0));
51 g_assert_cmpstr ("One", ==, dee_model_get_string (m, iter, 1));
52-
53+ g_assert (dee_model_get_first_iter (m) == dee_model_prev (m, iter));
54+
55 iter = dee_model_next (m, iter);
56 g_assert (!dee_model_is_first (m, iter));
57 g_assert (!dee_model_is_last (m, iter));
58 g_assert_cmpint (2, ==, dee_model_get_int32 (m, iter, 0));
59 g_assert_cmpstr ("Two", ==, dee_model_get_string (m, iter, 1));
60-
61+ g_assert (iter == dee_model_prev (m, dee_model_get_last_iter (m)));
62+
63 iter = dee_model_next (m, iter);
64 g_assert (!dee_model_is_first (m, iter));
65 g_assert (dee_model_is_last (m, iter));
66@@ -335,6 +341,62 @@
67 g_object_unref (m);
68 }
69
70+static void
71+test_change_backend (FilterFixture *fix, gconstpointer data)
72+{
73+ DeeFilter filter;
74+
75+ dee_filter_new (append_all_model_map,
76+ append_all_model_notify,
77+ fix,
78+ NULL,
79+ &filter);
80+
81+ DeeModel *m = dee_filter_model_new (fix->model, &filter);
82+ g_assert_cmpint (3, ==, dee_model_get_n_rows (fix->model));
83+
84+ DeeModelIter *iter = dee_model_get_first_iter (m);
85+ g_assert (dee_model_is_first (m, iter));
86+ g_assert (!dee_model_is_last (m, iter));
87+ g_assert_cmpint (0, ==, dee_model_get_int32 (m, iter, 0));
88+ g_assert_cmpstr ("Zero", ==, dee_model_get_string (m, iter, 1));
89+ g_assert_cmpuint (0, ==, dee_model_get_position (m, iter));
90+
91+ iter = dee_model_get_first_iter (fix->model);
92+ dee_model_remove (fix->model, iter);
93+
94+ g_assert_cmpint (2, ==, dee_model_get_n_rows (fix->model));
95+ g_assert_cmpint (2, ==, dee_model_get_n_rows (m));
96+
97+ iter = dee_model_get_first_iter (fix->model);
98+ dee_model_remove (fix->model, iter);
99+
100+ g_assert_cmpint (1, ==, dee_model_get_n_rows (fix->model));
101+ g_assert_cmpint (1, ==, dee_model_get_n_rows (m));
102+
103+ iter = dee_model_get_first_iter (m);
104+ g_assert (dee_model_is_first (m, iter));
105+ g_assert (!dee_model_is_last (m, iter));
106+ g_assert_cmpint (2, ==, dee_model_get_int32 (m, iter, 0));
107+ g_assert_cmpstr ("Two", ==, dee_model_get_string (m, iter, 1));
108+
109+ iter = dee_model_get_first_iter (fix->model);
110+ dee_model_set (fix->model, iter, -1, "Minus one");
111+
112+ iter = dee_model_get_first_iter (m);
113+ g_assert (dee_model_is_first (m, iter));
114+ g_assert (!dee_model_is_last (m, iter));
115+ g_assert_cmpint (-1, ==, dee_model_get_int32 (m, iter, 0));
116+ g_assert_cmpstr ("Minus one", ==, dee_model_get_string (m, iter, 1));
117+ g_assert_cmpuint (0, ==, dee_model_get_position (m, iter));
118+
119+ /* and finally remove the last row via the filter model */
120+ dee_model_remove (m, iter);
121+
122+ g_assert_cmpint (0, ==, dee_model_get_n_rows (m));
123+ g_assert_cmpint (0, ==, dee_model_get_n_rows (fix->model));
124+}
125+
126 /* Test dee_filter_new_collator() ascending */
127 static void
128 test_collator_asc (FilterFixture *fix, gconstpointer data)
129
130=== modified file 'tests/test-transaction.c'
131--- tests/test-transaction.c 2012-02-03 13:24:05 +0000
132+++ tests/test-transaction.c 2013-05-31 12:41:39 +0000
133@@ -45,6 +45,16 @@
134 }
135
136 static void
137+setup_basic_types (Fixture *fix, gconstpointer data)
138+{
139+ fix->model = dee_sequence_model_new ();
140+ dee_model_set_schema (fix->model, "b", "y", "i", "u", "x", "t", "d", "s", NULL);
141+
142+ /* The txn must be created during the tests because we need to verify how
143+ * it works when constructed on top of various states of the fix->model */
144+}
145+
146+static void
147 setup_proxy (Fixture *fix, gconstpointer data)
148 {
149 DeeModel *backend = dee_sequence_model_new ();
150@@ -85,6 +95,8 @@
151 g_assert_cmpint (dee_model_get_n_columns (fix->txn), == , 2);
152 g_assert_cmpstr (dee_model_get_column_schema (fix->txn, 0), ==, "s");
153 g_assert_cmpstr (dee_model_get_column_schema (fix->txn, 1), ==, "i");
154+
155+ g_assert (dee_transaction_get_target (DEE_TRANSACTION (fix->txn)) == fix->model);
156 }
157
158 static void
159@@ -1140,6 +1152,40 @@
160 g_assert_cmpint (dee_model_get_n_rows (fix->model), ==, 1);
161 }
162
163+static void
164+test_basic_types (Fixture *fix, gconstpointer data)
165+{
166+ GError *error;
167+ fix->txn = dee_transaction_new (fix->model);
168+
169+ dee_model_append (fix->txn, TRUE, 27, 28, 29,
170+ G_GINT64_CONSTANT (30), G_GUINT64_CONSTANT (31),
171+ 32.0, "ThirtyThree");
172+
173+ DeeModelIter *iter = dee_model_get_first_iter (fix->txn);
174+ g_assert (dee_model_get_bool (fix->txn, iter, 0) == TRUE);
175+ g_assert (dee_model_get_uchar (fix->txn, iter, 1) == 27);
176+ g_assert (dee_model_get_int32 (fix->txn, iter, 2) == 28);
177+ g_assert (dee_model_get_uint32 (fix->txn, iter, 3) == 29);
178+ g_assert (dee_model_get_int64 (fix->txn, iter, 4) == 30);
179+ g_assert (dee_model_get_uint64 (fix->txn, iter, 5) == 31);
180+ g_assert (ABS (dee_model_get_double (fix->txn, iter, 6) - 32.0) <= 0.001);
181+ g_assert_cmpstr ("ThirtyThree", ==, dee_model_get_string (fix->txn, iter, 7));
182+ g_assert_cmpstr ("s", ==, g_variant_get_type_string (dee_model_get_value (fix->txn, iter, 7)));
183+
184+ /* COMMIT */
185+ error = NULL;
186+ if (!dee_transaction_commit (DEE_TRANSACTION (fix->txn), &error))
187+ {
188+ g_critical ("Transaction failed to commit: %s", error->message);
189+ g_error_free (error);
190+ }
191+ if (error)
192+ {
193+ g_assert_not_reached ();
194+ }
195+}
196+
197 // FIXME tags
198
199 void
200@@ -1238,5 +1284,8 @@
201 setup, test_double_commit, teardown);
202 g_test_add (PROXY_DOMAIN"/DoubleCommit", Fixture, 0,
203 setup_proxy, test_double_commit, teardown);
204+
205+ g_test_add (DOMAIN"/BasicTypes", Fixture, 0,
206+ setup_basic_types, test_basic_types, teardown);
207 }
208

Subscribers

People subscribed via source and target branches

to all changes: