Skip to content
Snippets Groups Projects
Commit 7f9ef7a8 authored by Konstantin Shulgin's avatar Konstantin Shulgin
Browse files

bug-extra-test-for-update-cmd:

Extra UPDATE command tests was added.
parent 2a754e20
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); ...@@ -90,7 +90,8 @@ update_set_str(struct tnt_stream *stream, i32 field, char *str);
/** add update fields operation: splice string */ /** add update fields operation: splice string */
void 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 */ /** add update fields operation: delete field */
void void
...@@ -166,6 +167,10 @@ test_set_and_splice(); ...@@ -166,6 +167,10 @@ test_set_and_splice();
void void
test_delete_field(); test_delete_field();
/** update fields test case: boundary arguments values test */
void
test_boundary_args();
/*========================================================================== /*==========================================================================
* function definition * function definition
...@@ -185,6 +190,7 @@ main(void) ...@@ -185,6 +190,7 @@ main(void)
test_splice(); test_splice();
test_set_and_splice(); test_set_and_splice();
test_delete_field(); test_delete_field();
test_boundary_args();
/* clean-up suite */ /* clean-up suite */
test_suite_tear_down(); test_suite_tear_down();
return EXIT_SUCCESS; return EXIT_SUCCESS;
...@@ -413,6 +419,13 @@ test_simple_set() ...@@ -413,6 +419,13 @@ test_simple_set()
update(1, stream); update(1, stream);
tnt_stream_free(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"); printf("<<< test simple set done\n");
} }
...@@ -684,6 +697,14 @@ test_set_and_splice() ...@@ -684,6 +697,14 @@ test_set_and_splice()
update(1, stream); update(1, stream);
tnt_stream_free(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"); printf("<<< test set and splice done\n");
} }
...@@ -792,3 +813,36 @@ test_delete_field() ...@@ -792,3 +813,36 @@ test_delete_field()
printf("<<< test delete field done\n"); 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) ...@@ -8,6 +8,9 @@ update fields: respond ok (op: 19, reqid: 0, code: 0, count: 1)
# set field # set field
update fields: respond ok (op: 19, reqid: 0, code: 0, count: 1) update fields: respond ok (op: 19, reqid: 0, code: 0, count: 1)
(1 (0x00000001), 'field's new value', '', 1130450022 (0x43614c66)) (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 simple set done
>>> test long set >>> test long set
# insert tuple # insert tuple
...@@ -165,6 +168,23 @@ Princess Leia races home aboard her ...@@ -165,6 +168,23 @@ Princess Leia races home aboard her
starship, custodian of the stolen plans starship, custodian of the stolen plans
that can save her people and restore that can save her people and restore
freedom to the galaxy....', 'third') 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 set and splice done
>>> test delete field >>> test delete field
# insert tuple # insert tuple
...@@ -195,3 +215,14 @@ update fields: respond ok (op: 19, reqid: 0, code: 13826, count: 0) ...@@ -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) select: respond ok (op: 17, reqid: 0, code: 0, count: 1)
(1 (0x00000001), 9 (0x00000009), 10 (0x0000000a), 'fourth', 'fifth', 'eighth', 'ninth') (1 (0x00000001), 9 (0x00000009), 10 (0x0000000a), 'fourth', 'fifth', 'eighth', 'ninth')
<<< test delete field done <<< 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