Changeset: 766474a82d2f for MonetDB URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=766474a82d2f Branch: mtest Log Message:
merged diffs (223 lines): diff --git a/clients/examples/C/sample0.c b/clients/examples/C/sample0.c --- a/clients/examples/C/sample0.c +++ b/clients/examples/C/sample0.c @@ -28,7 +28,7 @@ main(int argc, char **argv) MapiHdl hdl = NULL; if (argc != 4) { - printf("usage:%s <host> <port> <language>\n", argv[0]); + fprintf(stderr, "usage:%s <host> <port> <language>\n", argv[0]); exit(-1); } @@ -55,11 +55,26 @@ main(int argc, char **argv) die(dbh, hdl); if ((hdl = mapi_query(dbh, "select * from emp")) == NULL || mapi_error(dbh)) die(dbh, hdl); + int n = 0; while (mapi_fetch_row(hdl)) { char *nme = mapi_fetch_field(hdl, 0); char *age = mapi_fetch_field(hdl, 1); - printf("%s is %s\n", nme, age); + switch (n) { + case 0: + if (strcmp(nme, "John") != 0 || strcmp(age, "23") != 0) + fprintf(stderr, "unexpected result: %s|%s\n", nme, age); + break; + case 1: + if (strcmp(nme, "Mary") != 0 || strcmp(age, "22") != 0) + fprintf(stderr, "unexpected result: %s|%s\n", nme, age); + break; + + default: + fprintf(stderr, "too many results: %s|%s\n", nme, age); + break; + } + n++; } } else if (strcmp(argv[3], "mal") == 0) { if ((hdl = mapi_query(dbh, "emp := bat.new(:oid,:str);")) == NULL || mapi_error(dbh)) @@ -82,10 +97,26 @@ main(int argc, char **argv) die(dbh, hdl); if ((hdl = mapi_query(dbh, "io.print(emp,age);")) == NULL || mapi_error(dbh)) die(dbh, hdl); + int n = 0; while (mapi_fetch_row(hdl)) { char *nme = mapi_fetch_field(hdl, 1); char *age = mapi_fetch_field(hdl, 2); - printf("%s is %s\n", nme, age); + + switch (n) { + case 0: + if (strcmp(nme, "John") != 0 || strcmp(age, "23") != 0) + fprintf(stderr, "unexpected result: %s|%s\n", nme, age); + break; + case 1: + if (strcmp(nme, "Mary") != 0 || strcmp(age, "22") != 0) + fprintf(stderr, "unexpected result: %s|%s\n", nme, age); + break; + + default: + fprintf(stderr, "too many results: %s|%s\n", nme, age); + break; + } + n++; } } else { fprintf(stderr, "%s: unknown language, only mal and sql supported\n", argv[0]); diff --git a/clients/examples/C/sample1.c b/clients/examples/C/sample1.c --- a/clients/examples/C/sample1.c +++ b/clients/examples/C/sample1.c @@ -28,7 +28,7 @@ main(int argc, char **argv) MapiHdl hdl = NULL; if (argc != 4) { - printf("usage:%s <host> <port> <language>\n", argv[0]); + fprintf(stderr, "usage:%s <host> <port> <language>\n", argv[0]); exit(-1); } @@ -56,11 +56,26 @@ main(int argc, char **argv) die(dbh, hdl); if ((hdl = mapi_query(dbh, "select * from emp")) == NULL || mapi_error(dbh)) die(dbh, hdl); + int n = 0; while (mapi_fetch_row(hdl)) { char *nme = mapi_fetch_field(hdl, 0); char *age = mapi_fetch_field(hdl, 1); - printf("%s is %s\n", nme, age); + switch (n) { + case 0: + if (strcmp(nme, "John") != 0 || strcmp(age, "23") != 0) + fprintf(stderr, "unexpected result: %s|%s\n", nme, age); + break; + case 1: + if (strcmp(nme, "Mary") != 0 || strcmp(age, "22") != 0) + fprintf(stderr, "unexpected result: %s|%s\n", nme, age); + break; + + default: + fprintf(stderr, "too many results: %s|%s\n", nme, age); + break; + } + n++; } } else if (strcmp(argv[3], "mal") == 0) { if ((hdl = mapi_query(dbh, "emp := bat.new(:oid,:str);")) == NULL || mapi_error(dbh)) @@ -83,10 +98,26 @@ main(int argc, char **argv) die(dbh, hdl); if ((hdl = mapi_query(dbh, "io.print(emp,age);")) == NULL || mapi_error(dbh)) die(dbh, hdl); + int n = 0; while (mapi_fetch_row(hdl)) { char *nme = mapi_fetch_field(hdl, 1); char *age = mapi_fetch_field(hdl, 2); - printf("%s is %s\n", nme, age); + + switch (n) { + case 0: + if (strcmp(nme, "John") != 0 || strcmp(age, "23") != 0) + fprintf(stderr, "unexpected result: %s|%s\n", nme, age); + break; + case 1: + if (strcmp(nme, "Mary") != 0 || strcmp(age, "22") != 0) + fprintf(stderr, "unexpected result: %s|%s\n", nme, age); + break; + + default: + fprintf(stderr, "too many results: %s|%s\n", nme, age); + break; + } + n++; } } else { fprintf(stderr, "%s: unknown language, only mal and sql supported\n", argv[0]); diff --git a/clients/examples/C/sample4.c b/clients/examples/C/sample4.c --- a/clients/examples/C/sample4.c +++ b/clients/examples/C/sample4.c @@ -30,7 +30,7 @@ main(int argc, char **argv) int64_t rows; if (argc != 4) { - printf("usage:%s <host> <port> <language>\n", argv[0]); + fprintf(stderr, "usage:%s <host> <port> <language>\n", argv[0]); exit(-1); } @@ -62,12 +62,28 @@ main(int argc, char **argv) rows = mapi_fetch_all_rows(hdl); if (mapi_error(dbh)) die(dbh, hdl); - printf("rows received %" PRId64 "\n", rows); + if (rows != 2) + fprintf(stderr, "rows received %" PRId64 "\n", rows); + int n = 0; while (mapi_fetch_row(hdl)) { char *nme = mapi_fetch_field(hdl, 0); char *age = mapi_fetch_field(hdl, 1); - printf("%s is %s\n", nme, age); + switch (n) { + case 0: + if (strcmp(nme, "John") != 0 || strcmp(age, "23") != 0) + fprintf(stderr, "unexpected result: %s|%s\n", nme, age); + break; + case 1: + if (strcmp(nme, "Mary") != 0 || strcmp(age, "22") != 0) + fprintf(stderr, "unexpected result: %s|%s\n", nme, age); + break; + + default: + fprintf(stderr, "too many results: %s|%s\n", nme, age); + break; + } + n++; } } else if (strcmp(argv[3], "mal") == 0) { if ((hdl = mapi_query(dbh, "emp := bat.new(:oid,:str);")) == NULL || mapi_error(dbh)) @@ -93,12 +109,28 @@ main(int argc, char **argv) rows = mapi_fetch_all_rows(hdl); if (mapi_error(dbh)) die(dbh, hdl); - printf("rows received %" PRId64 "\n", rows); + if (rows != 2) + fprintf(stderr, "rows received %" PRId64 "\n", rows); + int n = 0; while (mapi_fetch_row(hdl)) { char *nme = mapi_fetch_field(hdl, 1); char *age = mapi_fetch_field(hdl, 2); - printf("%s is %s\n", nme, age); + switch (n) { + case 0: + if (strcmp(nme, "John") != 0 || strcmp(age, "23") != 0) + fprintf(stderr, "unexpected result: %s|%s\n", nme, age); + break; + case 1: + if (strcmp(nme, "Mary") != 0 || strcmp(age, "22") != 0) + fprintf(stderr, "unexpected result: %s|%s\n", nme, age); + break; + + default: + fprintf(stderr, "too many results: %s|%s\n", nme, age); + break; + } + n++; } } else { fprintf(stderr, "%s: unknown language, only mal and sql supported\n", argv[0]); diff --git a/clients/examples/C/smack01.c b/clients/examples/C/smack01.c --- a/clients/examples/C/smack01.c +++ b/clients/examples/C/smack01.c @@ -72,7 +72,8 @@ main(int argc, char **argv) if ((hdl = mapi_query(dbh, buf)) == NULL || mapi_error(dbh)) die(dbh, hdl); while ((line = mapi_fetch_line(hdl))) { - printf("%s \n", line); + // printf("%s \n", line); + (void) line; } if (mapi_error(dbh)) die(dbh, hdl); _______________________________________________ checkin-list mailing list checkin-list@monetdb.org https://www.monetdb.org/mailman/listinfo/checkin-list