Skip to content
Snippets Groups Projects
Commit 5f80fe7f authored by Konstantin Osipov's avatar Konstantin Osipov
Browse files

Merge branch 'bug-extra-test-for-update-cmd'

parents e0e1c858 7f9ef7a8
No related branches found
No related tags found
No related merge requests found
......@@ -90,7 +90,8 @@ update_set_str(struct tnt_stream *stream, i32 field, char *str);
/** add update fields operation: splice string */
void
update_splice_str(struct tnt_stream *stream, i32 field, i32 offset, i32 length, char *list);
update_splice_str(struct tnt_stream *stream, i32 field, i32 offset, i32 length,
char *list);
/** add update fields operation: delete field */
void
......@@ -166,6 +167,10 @@ test_set_and_splice();
void
test_delete_field();
/** update fields test case: boundary arguments values test */
void
test_boundary_args();
/*==========================================================================
* function definition
......@@ -185,6 +190,7 @@ main(void)
test_splice();
test_set_and_splice();
test_delete_field();
test_boundary_args();
/* clean-up suite */
test_suite_tear_down();
return EXIT_SUCCESS;
......@@ -413,6 +419,13 @@ test_simple_set()
update(1, stream);
tnt_stream_free(stream);
/* test set primary key */
stream = tnt_buf(NULL);
printf("# test set primary key\n");
update_set_i32(stream, 0, 2);
update(1, stream);
tnt_stream_free(stream);
printf("<<< test simple set done\n");
}
......@@ -684,6 +697,14 @@ test_set_and_splice()
update(1, stream);
tnt_stream_free(stream);
/* test splice to long and set to short */
stream = tnt_buf(NULL);
printf("# test splice to long and set to short\n");
update_splice_str(stream, 3, -5, 5, long_string);
update_set_str(stream, 2, "short name");
update(1, stream);
tnt_stream_free(stream);
printf("<<< test set and splice done\n");
}
......@@ -792,3 +813,36 @@ test_delete_field()
printf("<<< test delete field done\n");
}
void
test_boundary_args()
{
const int max_update_op_cnt = 128;
printf(">>> test boundaty argumets values\n");
/* insert tuple */
printf("# insert tuple\n");
struct tnt_tuple *tuple = tnt_tuple(NULL, "%d%d", 0, 1);
insert_tuple(tuple);
tnt_tuple_free(tuple);
/* test simple delete fields */
struct tnt_stream *stream = tnt_buf(NULL);
printf("# test: try to do update w/o operations\n");
update(0, stream);
tnt_stream_free(stream);
stream = tnt_buf(NULL);
printf("# test: update w/ maximal allowed opearions count\n");
for (int i = 0; i < max_update_op_cnt; ++i)
tnt_update_arith(stream, 1, TNT_UPDATE_ADD, 1);
update(0, stream);
tnt_stream_free(stream);
stream = tnt_buf(NULL);
printf("# test: update w/ grater than maximal allowed opearions count\n");
for (int i = 0; i < max_update_op_cnt + 1; ++i)
tnt_update_arith(stream, 1, TNT_UPDATE_ADD, 1);
update(0, stream);
tnt_stream_free(stream);
}
......@@ -8,6 +8,9 @@ update fields: respond ok (op: 19, reqid: 0, code: 0, count: 1)
# set field
update fields: respond ok (op: 19, reqid: 0, code: 0, count: 1)
(1 (0x00000001), 'field's new value', '', 1130450022 (0x43614c66))
# test set primary key
update fields: respond ok (op: 19, reqid: 0, code: 0, count: 1)
(2 (0x00000002), 'field's new value', '', 1130450022 (0x43614c66))
<<< test simple set done
>>> test long set
# insert tuple
......@@ -165,6 +168,23 @@ Princess Leia races home aboard her
starship, custodian of the stolen plans
that can save her people and restore
freedom to the galaxy....', 'third')
# test splice to long and set to short
update fields: respond ok (op: 19, reqid: 0, code: 0, count: 1)
(1 (0x00000001), 'first', 'short name', 'A long time ago, in a galaxy far, far away...
It is a period of civil war. Rebel
spaceships, striking from a hidden
base, have won their first victory
against the evil Galactic Empire.
During the battle, Rebel spies managed
to steal secret plans to the Empire's
ultimate weapon, the Death Star, an
armored space station with enough
power to destroy an entire planet.
Pursued by the Empire's sinister agents,
Princess Leia races home aboard her
starship, custodian of the stolen plans
that can save her people and restore
freedom to the galaxy....')
<<< test set and splice done
>>> test delete field
# insert tuple
......@@ -195,3 +215,14 @@ update fields: respond ok (op: 19, reqid: 0, code: 13826, count: 0)
select: respond ok (op: 17, reqid: 0, code: 0, count: 1)
(1 (0x00000001), 9 (0x00000009), 10 (0x0000000a), 'fourth', 'fifth', 'eighth', 'ninth')
<<< test delete field done
>>> test boundaty argumets values
# insert tuple
insert: respond ok (op: 13, reqid: 0, code: 0, count: 1)
(0 (0x00000000), 1 (0x00000001))
# test: try to do update w/o operations
update fields: respond ok (op: 19, reqid: 0, code: 514, count: 0)
# test: update w/ maximal allowed opearions count
update fields: respond ok (op: 19, reqid: 0, code: 0, count: 1)
(0 (0x00000000), 129 (0x00000081))
# test: update w/ grater than maximal allowed opearions count
update fields: respond ok (op: 19, reqid: 0, code: 514, count: 0)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment