Move asserts to gtktreemodelrefcount.h for other unit tests to use

This commit is contained in:
Kristian Rietveld 2011-06-02 16:20:08 +02:00
parent bda09159c3
commit d241323b08
2 changed files with 78 additions and 74 deletions

View File

@ -62,4 +62,82 @@ gboolean gtk_tree_model_ref_count_check_node (GtkTreeModelRefCount *ref_mo
GtkTreeIter *iter,
gint expected_ref_count);
/* A couple of helpers for the tests. Since this model will never be used
* outside of unit tests anyway, it is probably fine to have these here
* without namespacing.
*/
static inline void
assert_entire_model_unreferenced (GtkTreeModelRefCount *ref_model)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_level (ref_model, NULL, 0,
TRUE),
==, TRUE);
}
static inline void
assert_root_level_unreferenced (GtkTreeModelRefCount *ref_model)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_level (ref_model, NULL, 0,
FALSE),
==, TRUE);
}
static inline void
assert_level_unreferenced (GtkTreeModelRefCount *ref_model,
GtkTreeIter *iter)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_level (ref_model, iter,
0, FALSE),
==, TRUE);
}
static inline void
assert_entire_model_referenced (GtkTreeModelRefCount *ref_model,
gint ref_count)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_level (ref_model, NULL,
ref_count, TRUE),
==, TRUE);
}
static inline void
assert_not_entire_model_referenced (GtkTreeModelRefCount *ref_model,
gint ref_count)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_level (ref_model, NULL,
ref_count, TRUE),
==, FALSE);
}
static inline void
assert_root_level_referenced (GtkTreeModelRefCount *ref_model,
gint ref_count)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_level (ref_model, NULL,
ref_count, FALSE),
==, TRUE);
}
static inline void
assert_level_referenced (GtkTreeModelRefCount *ref_model,
gint ref_count,
GtkTreeIter *iter)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_level (ref_model, iter,
ref_count, FALSE),
==, TRUE);
}
static inline void
assert_node_ref_count (GtkTreeModelRefCount *ref_model,
GtkTreeIter *iter,
gint ref_count)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_node (ref_model, iter,
ref_count),
==, TRUE);
}
#endif /* __GTK_TREE_MODEL_REF_COUNT_H__ */

View File

@ -20,80 +20,6 @@
#include "gtktreemodelrefcount.h"
#include "treemodel.h"
/* A couple of helpers for the tests */
static inline void
assert_entire_model_unreferenced (GtkTreeModelRefCount *ref_model)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_level (ref_model, NULL, 0,
TRUE),
==, TRUE);
}
static inline void
assert_root_level_unreferenced (GtkTreeModelRefCount *ref_model)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_level (ref_model, NULL, 0,
FALSE),
==, TRUE);
}
static inline void
assert_level_unreferenced (GtkTreeModelRefCount *ref_model,
GtkTreeIter *iter)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_level (ref_model, iter,
0, FALSE),
==, TRUE);
}
static inline void
assert_entire_model_referenced (GtkTreeModelRefCount *ref_model,
gint ref_count)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_level (ref_model, NULL,
ref_count, TRUE),
==, TRUE);
}
static inline void
assert_not_entire_model_referenced (GtkTreeModelRefCount *ref_model,
gint ref_count)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_level (ref_model, NULL,
ref_count, TRUE),
==, FALSE);
}
static inline void
assert_root_level_referenced (GtkTreeModelRefCount *ref_model,
gint ref_count)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_level (ref_model, NULL,
ref_count, FALSE),
==, TRUE);
}
static inline void
assert_level_referenced (GtkTreeModelRefCount *ref_model,
gint ref_count,
GtkTreeIter *iter)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_level (ref_model, iter,
ref_count, FALSE),
==, TRUE);
}
static inline void
assert_node_ref_count (GtkTreeModelRefCount *ref_model,
GtkTreeIter *iter,
gint ref_count)
{
g_assert_cmpint (gtk_tree_model_ref_count_check_node (ref_model, iter,
ref_count),
==, TRUE);
}
/* And the tests themselves */
static void