Skip to content

Commit

Permalink
Extended SetUnique test cases with nullability.
Browse files Browse the repository at this point in the history
  • Loading branch information
simonask committed Dec 1, 2015
1 parent 8c5264f commit 5cef13d
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion test/test_table.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1442,15 +1442,19 @@ TEST(Table_SetIntUnique)
{
Table table;
table.add_column(type_Int, "ints");
table.add_column(type_String, "strings");
table.add_column(type_Int, "ints_null", true);
table.add_empty_row(10);

CHECK_LOGIC_ERROR(table.set_int_unique(0, 0, 123), LogicError::no_search_index);
CHECK_LOGIC_ERROR(table.set_int_unique(1, 0, 123), LogicError::no_search_index);
table.add_search_index(0);
table.add_search_index(1);

table.set_int_unique(0, 0, 123);
table.set_int_unique(1, 0, 123);

CHECK_LOGIC_ERROR(table.set_int_unique(0, 1, 123), LogicError::unique_constraint_violation);
CHECK_LOGIC_ERROR(table.set_int_unique(1, 1, 123), LogicError::unique_constraint_violation);
}


Expand All @@ -1459,14 +1463,19 @@ TEST(Table_SetStringUnique)
Table table;
table.add_column(type_Int, "ints");
table.add_column(type_String, "strings");
table.add_column(type_String, "strings_nullable", true);
table.add_empty_row(10);

CHECK_LOGIC_ERROR(table.set_string_unique(1, 0, "foo"), LogicError::no_search_index);
table.add_search_index(1);
table.add_search_index(2);

table.set_string_unique(1, 0, "bar");

CHECK_LOGIC_ERROR(table.set_string_unique(1, 1, "bar"), LogicError::unique_constraint_violation);
CHECK_LOGIC_ERROR(table.set_string_unique(1, 0, realm::null()), LogicError::column_not_nullable);

CHECK_LOGIC_ERROR(table.set_string_unique(2, 0, realm::null()), LogicError::unique_constraint_violation);
}


Expand Down

0 comments on commit 5cef13d

Please sign in to comment.