model: Create a basic unit test
This test doesn't catch everything, but I want to move on anyway! Signed-off-by: Anna Schumaker <Anna@OcarinaProject.net>
This commit is contained in:
parent
09af8d81d2
commit
32bb1c670b
|
@ -12,3 +12,4 @@ tests/*/*-lib
|
|||
*.gcov
|
||||
*.gcda
|
||||
*.gcno
|
||||
core.*
|
||||
|
|
|
@ -1,2 +1,3 @@
|
|||
lib
|
||||
colmgr
|
||||
model
|
||||
|
|
|
@ -25,6 +25,7 @@ res = TestList("lib", [
|
|||
|
||||
LibTest("lib.cpp", "gtkmm-3.0"),
|
||||
LibTest("colmgr.cpp"),
|
||||
LibTest("model.cpp"),
|
||||
|
||||
]).prepare()
|
||||
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* Copyright 2014 (c) Anna Schumaker.
|
||||
*/
|
||||
#include <core/library.h>
|
||||
#include <lib/lib.h>
|
||||
#include <lib/model.h>
|
||||
#include <tests/test.h>
|
||||
|
||||
static void test_qmodel()
|
||||
{
|
||||
QueueModel model(library :: get_queue());
|
||||
Gtk::TreePath path;
|
||||
Gtk::TreeIter iter;
|
||||
Gtk::TreeRow row;
|
||||
bool valid;
|
||||
|
||||
test_equal(model.get_flags(), Gtk::TREE_MODEL_LIST_ONLY);
|
||||
test_equal(model.get_n_columns(), 10);
|
||||
|
||||
for (unsigned int i = 0; i < 10; i++) {
|
||||
if ((i == 0) || (i == 5) || (i == 7))
|
||||
test_equal(model.get_column_type(i), G_TYPE_UINT);
|
||||
else
|
||||
test_equal(model.get_column_type(i), G_TYPE_STRING);
|
||||
}
|
||||
|
||||
path = Gtk::TreePath("42");
|
||||
iter = model.get_iter(path);
|
||||
valid = (iter ? true : false);
|
||||
test_equal(valid, false);
|
||||
|
||||
path = Gtk::TreePath("19");
|
||||
iter = model.get_iter(path);
|
||||
valid = (iter ? true : false);
|
||||
test_equal(valid, true);
|
||||
|
||||
test_equal(model.get_path(iter), path);
|
||||
test_equal(model.get_iter(path), iter);
|
||||
|
||||
test_equal(model.iter_to_id(iter), (unsigned)19);
|
||||
test_equal(model.path_to_id(path), (unsigned)15);
|
||||
|
||||
valid = (++iter ? true : false);
|
||||
test_equal(valid, false);
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
Gtk::Main ocarina(&argc, &argv);
|
||||
test :: cp_data_dir();
|
||||
lib :: init(&argc, &argv, "ocarina6.glade");
|
||||
|
||||
run_test("QueueModel Test", test_qmodel);
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue