24 for (
unsigned i = 0; i<size; ++i) {
36 for (; (c=*
str); str++) {
39 if (!(c=*str))
return NULp;
42 if (c==
'"')
return (
char *)
str;
52 if (*source !=
'(') deep --;
53 for (; (c=*source); source++) {
60 else if (c==
')') deep++;
61 if (!deep)
return (
char *)source;
64 if (!source)
return NULp;
73 static bool init =
false;
80 for (
const char *p = seps; *p; ++p) tab[
safeCharIndex(*p)] = 1;
86 for (; *source; ++source) {
88 if (chType == 0)
continue;
89 if (chType == 1)
break;
91 if (*source ==
'\\') {
93 if (!source[0])
break;
95 else if (*source ==
'(') {
99 else if (*source ==
'\"') {
104 for (
const char *p = seps; *p; ++p) tab[
safeCharIndex(*p)] = 0;
105 return source && source[0] ? source :
NULp;
113 if (streams.
empty()) {
117 int count = streams.
size();
123 for (
int c = 1; c<count; c++) {
124 if (c == 10 || c == 100 || c == 1000) --
traceIndent;
136 size_t len = strlen(str);
140 if (len>wanted_len) {
141 static char *shortened_str;
142 static size_t short_len = 0;
144 if (short_len >= wanted_len) {
145 memcpy(shortened_str, str, wanted_len-4);
149 short_len = wanted_len;
151 strcpy(shortened_str+wanted_len-4,
"[..]");
152 result = shortened_str;
171 for (; (c = *s1); s1++) {
174 if (!(c=*++s1)) {
break; }
186 while (s1 <= hp) *(s2++) = *(s1++);
190 if (c!=
' ' && c!=
'\t') *(s2++) = c;
205 if (*s1 ==
'|') s1++;
208 for (; s1; s1 = s2) {
225 error =
"Missing second '\"'";
234 char *bracket = strchr(s1,
'(');
237 int slen = strlen(bracket);
238 if (slen<1 || bracket[slen-1] !=
')') {
239 error =
"Missing ')'";
241 else if (slen == 1) {
242 error =
"Invalid empty parameter list '()'. To pass an empty argument use '(\"\")'";
248 for (p1 = bracket; p1; p1 = p2) {
258 if (p1[len2] !=
'\"') {
259 error =
GBS_global_string(
"Invalid parameter syntax for '%s' (needs '\"' at begin AND end of parameter)", p1-1);
269 if (!error && (bracket || *s1)) {
293 #define MAX_PRINT_LEN 200
295 char *paramlist =
NULp;
300 if (!paramlist) paramlist =
ARB_strdup(param_short);
303 char *inputstreams =
NULp;
304 for (
int j = 0; j<args.
input.
size(); ++j) {
305 const char *input = args.
input.
get(j);
308 if (!inputstreams) inputstreams =
ARB_strdup(input_short);
313 error =
GBS_global_string(
"while applying '%s(%s)'\nto '%s':\n%s", s1, paramlist, inputstreams, dup_error);
316 error =
GBS_global_string(
"while applying '%s'\nto '%s':\n%s", s1, inputstreams, dup_error);
329 if (separator ==
'|') {
339 if (!error)
return s1;
354 for (
int i=0; i<count; i++) {
355 const char *
s =
get(i);
401 if (!commands || !commands[0]) {
404 else if (commands[0] ==
':') {
407 else if (commands[0] ==
'/') {
412 if (strcmp(err,
"Missing '/' between search and replace string") == 0) {
417 const char *matched =
GBS_regmatch(str, commands, &matchlen, &err);
419 if (matched) result =
ARB_strndup(matched, matchlen);
427 result =
apply_ACI(str, commands, callEnv);
434 final_msg.
cat(
"CI: result ='");
435 final_msg.
cat(result);
438 final_msg.
cat(
"CI: no result. error ='");
461 void GBL_custom_command_lookup_table::warn_about_overwritten_commands(
const GBL_command_definition *custom_table,
unsigned custom_size)
const {
463 for (
unsigned i = 0; i<custom_size; ++i) {
468 if (base_table.lookup(cmd)) {
469 fprintf(stderr,
"Warning: ACI-command '%s' is substituted w/o permission\n", cmd);
474 fprintf(stderr,
"Warning: Detected probably unwanted substitution of %i ACI-commands\n", errcount);
486 #define TEST_CI__INTERNAL(input,cmd,expected,got,TEST_RESULT,callEnv) do { \
488 TEST_EXPECT_RESULT__NOERROREXPORTED(result = GB_command_interpreter_in_env(input, cmd, callEnv)); \
489 TEST_RESULT(result,expected,got); \
493 #define TEST_CI(input,cmd,expected) TEST_CI__INTERNAL(input, cmd, expected, narg, TEST_EXPECT_EQUAL__IGNARG, callEnv)
494 #define TEST_CI_WITH_ENV(input,env,cmd,expected) TEST_CI__INTERNAL(input, cmd, expected, narg, TEST_EXPECT_EQUAL__IGNARG, env)
495 #define TEST_CI__BROKEN(input,cmd,expected,regr) TEST_CI__INTERNAL(input, cmd, expected, regr, TEST_EXPECT_EQUAL__BROKEN, callEnv)
496 #define TEST_CI_NOOP(inandout,cmd) TEST_CI__INTERNAL(inandout, cmd, inandout, narg, TEST_EXPECT_EQUAL__IGNARG, callEnv)
497 #define TEST_CI_NOOP__BROKEN(inandout,regr,cmd) TEST_CI__INTERNAL(inandout, cmd, inandout, regr, TEST_EXPECT_EQUAL__BROKEN, callEnv)
499 #define TEST_CI_INVERSE(in,cmd,inv_cmd,out) do { \
500 TEST_CI(in, cmd, out); \
501 TEST_CI(out, inv_cmd, in); \
506 #define TEST_CI_ERROR_CONTAINS(input,cmd,errorpart_expected) \
507 TEST_EXPECT_NORESULT__ERROREXPORTED_CONTAINS(GB_command_interpreter_in_env(input, cmd, callEnv), errorpart_expected)
509 #define TEST_CI_ERROR_CONTAINS__BROKEN(input,cmd,errorpart_expected,unexpected_result) do{ \
511 TEST_EXPECT_NORESULT__ERROREXPORTED_CONTAINS__BROKEN(result = GB_command_interpreter_in_env(input, cmd, callEnv), errorpart_expected); \
512 TEST_EXPECT_EQUAL(result, unexpected_result); \
517 static const char *RCI_input =
NULp;
518 static const char *RCI_cmd =
NULp;
521 inline void run_ci() {
527 #define TEST_CI_SEGFAULTS(input,cmd) do{ \
528 RCI_gb_main = gb_main; \
532 TEST_EXPECT_SEGFAULT(run_ci); \
535 #define TEST_CI_SEGFAULTS__UNWANTED(input,cmd) do{ \
536 RCI_gb_main = gb_main; \
540 TEST_EXPECT_SEGFAULT__UNWANTED(run_ci); \
543 #define ACI_SPLIT "|split(\",\",0)"
544 #define ACI_MERGE "|merge(\",\")"
545 #define WITH_SPLITTED(aci) ACI_SPLIT aci ACI_MERGE
549 for (
int i=0; i<args->
input.
size(); ++i) {
563 gb_main(
GB_open(
"TEST_aci.arb",
"rw")),
576 GBDATA *gbspecies()
const {
return gb_species; }
584 GBDATA *
const gb_data = E.gbspecies();
587 TEST_CI_NOOP(
"bla",
"");
589 TEST_CI(
"bla",
":a=u",
"blu");
592 TEST_CI(
"bla",
"/a/u/",
"blu");
594 TEST_CI(
"test",
"/_[0-9]+//",
"test");
596 TEST_CI(
"blabla",
"/l.*b/",
"lab");
597 TEST_CI(
"blabla",
"/b.b/",
"");
599 TEST_CI(
"tx_01_2",
"/_[0-9]+//",
"tx");
600 TEST_CI(
"tx_01_2",
"/_[0-9]+$//",
"tx_01");
602 TEST_CI_ERROR_CONTAINS(
"xx_____",
"/_*//",
"regular expression '_*' matched an empty string");
603 TEST_CI(
"xx_____",
"/_//",
"xx");
604 TEST_CI(
"xx_____yy",
"/(_+)([^_]|$)/-=-\\2/",
"xx-=-yy");
605 TEST_CI(
"xx_____",
"/(_+)([^_]|$)/-=-\\2/",
"xx-=-");
607 TEST_CI(
"xx_____",
"/_*$//",
"xx");
608 TEST_CI(
"xx",
"/_*$//",
"xx");
609 TEST_CI(
"_____yy",
"/^_*//",
"yy");
610 TEST_CI(
"yy",
"/^_*//",
"yy");
612 TEST_CI(
"",
"/^$/ABC/",
"ABC");
613 TEST_CI(
"XXX",
"/^XXX$//",
"");
615 TEST_CI(
"xx/yy/zz",
"/\\//-/",
"xx-yy-zz");
616 TEST_CI(
"xx-yy-zz",
"/-/\\//",
"xx/yy/zz");
618 TEST_CI_ERROR_CONTAINS(
"xx",
"\\///",
"Unknown command");
619 TEST_CI (
"x/x",
"/\\//",
"/");
620 TEST_CI_ERROR_CONTAINS(
"xx",
"//\\/",
"railing backslash");
623 TEST_CI_INVERSE(
"ac",
"|quote",
"|unquote",
"\"ac\"");
624 TEST_CI_INVERSE(
"ac",
"|escape",
"|unescape",
"ac");
625 TEST_CI_INVERSE(
"ac",
"|escape|quote",
"|unquote|unescape",
"\"ac\"");
626 TEST_CI_INVERSE(
"ac",
"|quote|escape",
"|unescape|unquote",
"\\\"ac\\\"");
628 TEST_CI_INVERSE(
"a\"b\\c",
"|quote",
"|unquote",
"\"a\"b\\c\"");
629 TEST_CI_INVERSE(
"a\"b\\c",
"|escape",
"|unescape",
"a\\\"b\\\\c");
630 TEST_CI_INVERSE(
"a\"b\\c",
"|escape|quote",
"|unquote|unescape",
"\"a\\\"b\\\\c\"");
631 TEST_CI_INVERSE(
"a\"b\\c",
"|quote|escape",
"|unescape|unquote",
"\\\"a\\\"b\\\\c\\\"");
633 TEST_CI_NOOP(
"ac",
"|unquote");
634 TEST_CI_NOOP(
"\"ac",
"|unquote");
635 TEST_CI_NOOP(
"ac\"",
"|unquote");
637 TEST_CI (
"blabla",
"|coUNT(ab)",
"4");
638 TEST_CI (
"l",
"|\"b\";dd;\"a\"|dd",
"bla");
639 TEST_CI_ERROR_CONTAINS(
"bla",
"|count()",
"Invalid empty parameter list");
640 TEST_CI (
"bla",
"|count(\"\")",
"0");
641 TEST_CI (
"b a",
"|count(\" \")",
"1");
642 TEST_CI (
"b\\a",
"|count(\\a)",
"2");
643 TEST_CI__BROKEN (
"b\\a",
"|count(\"\\a\")",
"1",
"2");
644 TEST_CI (
"b\\a",
"|count(\"\a\")",
"0");
645 TEST_CI (
"b\a",
"|count(\"\a\")",
"1");
648 TEST_CI(
"b\\a\a",
"|count(\\a)",
"2");
649 TEST_CI(
"b\\a",
"|contains(\"\\\\\")",
"0");
650 TEST_CI(
"b\\a",
"|contains(\"\")",
"0");
651 TEST_CI(
"b\\a",
"|contains(\\)",
"2");
652 TEST_CI(
"b\\\\a",
"|contains(\"\\\\\")",
"2");
654 TEST_CI_ERROR_CONTAINS(
"b\\a",
"|contains(\"\\\")",
"ARB ERROR: unbalanced '\"' in '|contains(\"\\\")'");
659 TEST_CI(
"",
"\"5\";\"7\"|minus",
"-2");
660 TEST_CI(
"",
"\"5\"|minus(\"7\")",
"-2");
662 TEST_CI(
"",
"minus(\"\"5\"\",\"\"7\"\")",
"-2");
663 TEST_CI(
"",
"minus(\"\"5\";\"2\"|mult\",\"\"7\"\")",
"3");
664 TEST_CI(
"",
"minus(\"\"5\";\"2\\,\"|mult\",\"\"7\"\")",
"3");
666 TEST_CI_ERROR_CONTAINS(
"",
"minus(\"\"5\";\"2,\"|mult\",\"\"7\"\")",
"Invalid parameter syntax for '\"\"5\";\"2'");
669 TEST_CI_NOOP(
"ab,bcb,abac", WITH_SPLITTED(
""));
670 TEST_CI (
"ab,bcb,abac", WITH_SPLITTED(
"|len"),
"2,3,4");
671 TEST_CI (
"ab,bcb,abac", WITH_SPLITTED(
"|count(a)"),
"1,0,2");
672 TEST_CI (
"ab,bcb,abac", WITH_SPLITTED(
"|minus(len,count(a))"),
"1,3,2");
673 TEST_CI (
"ab,bcb,abac", WITH_SPLITTED(
"|minus(\"\"5\"\",count(a))"),
"4,5,3");
676 TEST_CI(
"one",
"|dd;\"two\";dd|command(\"dd;\"_\";dd;\"-\"\")",
"one_one-two_two-one_one-");
677 TEST_CI(
"",
"|sequence|command(\"/^([\\\\.-]*)[A-Z].*/\\\\1/\")|len",
"9");
678 TEST_CI(
"one",
"|dd;dd|eval(\"\"up\";\"per\"|merge\")",
"ONEONE");
679 TEST_CI(
"1,2,3", WITH_SPLITTED(
"|select(\"\", \"\"one\"\", \"\"two\"\", \"\"three\"\")"),
"one,two,three");
680 TEST_CI_ERROR_CONTAINS(
"1,4", WITH_SPLITTED(
"|select(\"\", \"\"one\"\", \"\"two\"\", \"\"three\"\")"),
"Illegal param number '4' (allowed [0..3])");
683 TEST_CI(
"ignored",
"define(d4, \"dd;dd;dd;dd\")",
"");
684 TEST_CI(
"ignored",
"define(d16, \"do(d4)|do(d4)\")",
"");
685 TEST_CI(
"ignored",
"define(d64, \"do(d4)|do(d16)\")",
"");
686 TEST_CI(
"ignored",
"define(d4096, \"do(d64)|do(d64)\")",
"");
688 TEST_CI(
"x",
"do(d4)",
"xxxx");
689 TEST_CI(
"xy",
"do(d4)",
"xyxyxyxy");
690 TEST_CI(
"x",
"do(d16)",
"xxxxxxxxxxxxxxxx");
691 TEST_CI(
"x",
"do(d64)|len",
"64");
692 TEST_CI(
"xy",
"do(d4)|len",
"8");
693 TEST_CI(
"xy",
"do(d4)|len(\"\")",
"8");
694 TEST_CI(
"xy",
"do(d4)|len(x)",
"4");
695 TEST_CI(
"x",
"do(d4096)|len",
"4096");
698 TEST_CI(
"x",
"trace(0)|dd;dd|dd;dd|dd;dd|dd;dd|dd;dd|dd;dd|dd;dd|dd;dd|dd;dd|dd;dd|dd;dd|dd;dd|streams",
"4096");
706 GBDATA *
const gb_data = E.gbspecies();
710 TEST_CI(
"x",
"dd;dd|streams",
"2");
711 TEST_CI(
"x",
"dd;dd|dd;dd|streams",
"4");
712 TEST_CI(
"x",
"dd;dd|dd;dd|dd;dd|streams",
"8");
713 TEST_CI(
"x",
"do(d4)|streams",
"1");
715 TEST_CI(
"",
"ali_name",
"ali_16s");
716 TEST_CI(
"",
"sequence_type",
"rna");
719 TEST_CI(
"acgt",
"format",
" acgt");
720 TEST_CI(
"acgt",
"format(firsttab=1)",
" acgt");
721 TEST_CI(
"acgt",
"format(firsttab=1, width=2)",
724 TEST_CI(
"acgt",
"format(firsttab=1,tab=1,width=2)",
727 TEST_CI(
"acgt",
"format(firsttab=0,tab=0,width=2)",
730 TEST_CI(
"acgt",
"format(firsttab=0,tab=0,width=1)",
736 TEST_CI_ERROR_CONTAINS(
"acgt",
"format(gap=0)",
"Unknown Parameter 'gap=0' in command 'format'");
737 TEST_CI_ERROR_CONTAINS(
"acgt",
"format(numleft)",
"Unknown Parameter 'numleft' in command 'format'");
740 TEST_CI_ERROR_CONTAINS(
"acgt",
"format_sequence(numright=5, numleft)",
"You may only specify 'numleft' OR 'numright', not both");
742 TEST_CI(
"acgtacgtacgtacg",
"format_sequence(firsttab=5,tab=5,width=4,numleft=1)",
748 TEST_CI(
"acgtacgtacgtacg",
"format_sequence(firsttab=5,tab=5,width=4,numright=9)",
754 TEST_CI(
"acgtacgtacgtac",
"format_sequence(firsttab=5,tab=5,width=4,gap=2,numright=-1)",
760 TEST_CI(
"acgt",
"format_sequence(firsttab=0,tab=0,width=2,gap=1)",
763 TEST_CI(
"acgt",
"format_sequence(firsttab=0,tab=0,width=4,gap=1)",
"a c g t");
764 TEST_CI(
"acgt",
"format_sequence(firsttab=0,tab=0,width=4,gap=2)",
"ac gt");
765 TEST_CI(
"acgtacgt",
"format_sequence(firsttab=0,width=10,gap=4)",
"acgt acgt");
766 TEST_CI(
"acgtacgt",
"format_sequence(firsttab=1,width=10,gap=4)",
" acgt acgt");
768 TEST_CI(
"acgt",
"format_sequence(firsttab=0,tab=0,gap=0)",
"acgt");
769 TEST_CI(
"acgt",
"format_sequence(firsttab=0,tab=0,gap=-1)",
"acgt");
770 TEST_CI(
"acgt",
"format_sequence(firsttab=0,tab=-1,gap=-1)",
"acgt");
771 TEST_CI(
"acgt",
"format(firsttab=0,tab=0,width=-1)",
"acgt");
773 TEST_CI(
"acgt",
"format(firsttab=-1,tab=0)",
"acgt");
774 TEST_CI(
"acgt",
"format(firsttab=-1,tab=-1)",
"acgt");
775 TEST_CI(
"acgt",
"format(firsttab=-1,tab=-1,width=-1)",
"acgt");
777 TEST_CI(
"acgt",
"format_sequence(firsttab=0,tab=0,gap=0,width=-1)",
"acgt");
778 TEST_CI(
"acgt",
"format_sequence(firsttab=-1,tab=0,gap=-1)",
"acgt");
779 TEST_CI(
"acgt",
"format_sequence(firsttab=-1,tab=-1,gap=-1)",
"acgt");
780 TEST_CI(
"acgt",
"format_sequence(firsttab=-1,tab=-1,gap=-1,width=-1)",
"acgt");
782 TEST_CI_ERROR_CONTAINS(
"acgt",
"format_sequence(nl=c)",
"Unknown Parameter 'nl=c' in command 'format_sequence'");
783 TEST_CI_ERROR_CONTAINS(
"acgt",
"format_sequence(forcenl=)",
"Unknown Parameter 'forcenl=' in command 'format_sequence'");
785 TEST_CI_ERROR_CONTAINS(
"acgt",
"format(width=0)",
"Illegal zero width");
786 TEST_CI_ERROR_CONTAINS(
"acgt",
"format_sequence(width=0)",
"Illegal zero width");
789 TEST_CI_NOOP(
"acgtacgt",
"remove(-.)");
790 TEST_CI (
"..acg--ta-cgt...",
"remove(-.)",
"acgtacgt");
791 TEST_CI (
"..acg--ta-cgt...",
"remove(acgt)",
"..---...");
793 TEST_CI_NOOP(
"acgtacgt",
"keep(acgt)");
794 TEST_CI (
"..acg--ta-cgt...",
"keep(-.)",
"..---...");
795 TEST_CI (
"..acg--ta-cgt...",
"keep(acgt)",
"acgtacgt");
798 TEST_CI(
"x,z,y,y,z,x,x,Z,y,Y,Z,x", WITH_SPLITTED(
"|compare"),
"-1,0,1,1,1,-1");
799 TEST_CI(
"x,z,y,y,z,x,x,Z,y,Y,Z,x", WITH_SPLITTED(
"|icompare"),
"-1,0,1,-1,0,1");
801 TEST_CI(
"x,y,z", WITH_SPLITTED(
"|compare(\"y\")"),
"-1,0,1");
804 TEST_CI(
"a,b,a,a,a,A", WITH_SPLITTED(
"|equals"),
"0,1,0");
805 TEST_CI(
"a,b,a,a,a,A", WITH_SPLITTED(
"|iequals"),
"0,1,1");
808 TEST_CI(
"abc,bcd,BCD", WITH_SPLITTED(
"|contains(\"bc\")"),
"2,1,0");
809 TEST_CI(
"abc,bcd,BCD", WITH_SPLITTED(
"|icontains(\"bc\")"),
"2,1,1");
810 TEST_CI(
"abc,bcd,BCD", WITH_SPLITTED(
"|icontains(\"d\")"),
"0,3,3");
813 TEST_CI(
"abc,BCD,def,deg", WITH_SPLITTED(
"|partof(\"abcdefg\")"),
"1,0,4,0");
814 TEST_CI(
"abc,BCD,def,deg", WITH_SPLITTED(
"|ipartof(\"abcdefg\")"),
"1,2,4,0");
816 TEST_CI(
", , ,x", WITH_SPLITTED(
"|isempty"),
"1,0,0,0");
817 TEST_CI(
", , ,x", WITH_SPLITTED(
"|crop(\" \")|isempty"),
"1,1,1,0");
820 TEST_CI(
"abcdefgh",
"translate(abc,cba)",
"cbadefgh");
821 TEST_CI(
"abcdefgh",
"translate(cba,abc)",
"cbadefgh");
822 TEST_CI(
"abcdefgh",
"translate(hcba,abch,-)",
"hcb----a");
823 TEST_CI(
"abcdefgh",
"translate(aceg,aceg,-)",
"a-c-e-g-");
824 TEST_CI(
"abbaabba",
"translate(ab,ba,-)",
"baabbaab");
825 TEST_CI(
"abbaabba",
"translate(a,x,-)",
"x--xx--x");
826 TEST_CI(
"abbaabba",
"translate(,,-)",
"--------");
829 TEST_CI(
"",
"echo",
"");
830 TEST_CI(
"",
"echo(x,y,z)",
"xyz");
831 TEST_CI(
"",
"echo(x;y,z)",
"xyz");
832 TEST_CI(
"",
"echo(x;y;z)",
"xyz");
833 TEST_CI(
"",
"echo(x,y,z)|streams",
"3");
836 TEST_CI(
"the QUICK brOwn Fox",
"lower",
"the quick brown fox");
837 TEST_CI(
"the QUICK brOwn Fox",
"upper",
"THE QUICK BROWN FOX");
838 TEST_CI(
"the QUICK brOwn FoX",
"caps",
"The Quick Brown Fox");
846 GBDATA *
const gb_data = E.gbspecies();
849 TEST_CI_ERROR_CONTAINS(
"a;b;c",
"split(;)|merge(-)",
"Invalid separator (cannot be empty");
850 TEST_CI (
"a;b;c",
"split(\";\")|merge(-)",
"a-b-c");
853 TEST_CI (
"1234567890",
"head(3)",
"123");
854 TEST_CI (
"1234567890",
"head(9)",
"123456789");
855 TEST_CI_NOOP(
"1234567890",
"head(10)");
856 TEST_CI_NOOP(
"1234567890",
"head(20)");
858 TEST_CI (
"1234567890",
"tail(4)",
"7890");
859 TEST_CI (
"1234567890",
"tail(9)",
"234567890");
860 TEST_CI_NOOP(
"1234567890",
"tail(10)");
861 TEST_CI_NOOP(
"1234567890",
"tail(20)");
863 TEST_CI(
"1234567890",
"tail(0)",
"");
864 TEST_CI(
"1234567890",
"head(0)",
"");
865 TEST_CI(
"1234567890",
"tail(-2)",
"");
866 TEST_CI(
"1234567890",
"head(-2)",
"");
868 TEST_CI(
"1234567890",
"mid(3,5)",
"345");
869 TEST_CI(
"1234567890",
"mid(2,2)",
"2");
871 TEST_CI(
"1234567890",
"mid0(3,5)",
"456");
873 TEST_CI(
"1234567890",
"mid(9,20)",
"90");
874 TEST_CI(
"1234567890",
"mid(20,20)",
"");
876 TEST_CI(
"1234567890",
"tail(3)",
"890");
877 TEST_CI(
"1234567890",
"mid(-2,0)",
"890");
878 TEST_CI(
"1234567890",
"mid0(-3,-1)",
"890");
881 TEST_CI(
"x,xx,xxx", WITH_SPLITTED(
"|tab(2)"),
"x ,xx,xxx");
882 TEST_CI(
"x,xx,xxx", WITH_SPLITTED(
"|tab(3)"),
"x ,xx ,xxx");
883 TEST_CI(
"x,xx,xxx", WITH_SPLITTED(
"|tab(4)"),
"x ,xx ,xxx ");
884 TEST_CI(
"x,xx,xxx", WITH_SPLITTED(
"|pretab(2)"),
" x,xx,xxx");
885 TEST_CI(
"x,xx,xxx", WITH_SPLITTED(
"|pretab(3)"),
" x, xx,xxx");
886 TEST_CI(
"x,xx,xxx", WITH_SPLITTED(
"|pretab(4)"),
" x, xx, xxx");
889 TEST_CI(
" x x ",
"crop(\" \")",
"x x");
890 TEST_CI(
"\n \t x x \n \t",
"crop(\"\t\n \")",
"x x");
893 TEST_CI(
"one,two,three,four,five,six", WITH_SPLITTED(
"|cut(2,3,5)"),
"two,three,five");
894 TEST_CI(
"one,two,three,four,five,six", WITH_SPLITTED(
"|drop(2,3,5)"),
"one,four,six");
896 TEST_CI_ERROR_CONTAINS(
"a",
"drop(2)",
"Illegal stream number '2' (allowed [1..1])");
897 TEST_CI_ERROR_CONTAINS(
"a",
"drop(0)",
"Illegal stream number '0' (allowed [1..1])");
898 TEST_CI_ERROR_CONTAINS(
"a",
"drop",
"syntax: drop(streamnumber[,streamnumber]+)");
899 TEST_CI_ERROR_CONTAINS(
"a",
"cut(2)",
"Illegal stream number '2' (allowed [1..1])");
900 TEST_CI_ERROR_CONTAINS(
"a",
"cut(0)",
"Illegal stream number '0' (allowed [1..1])");
901 TEST_CI_ERROR_CONTAINS(
"a",
"cut",
"syntax: cut(streamnumber[,streamnumber]+)");
902 TEST_CI_ERROR_CONTAINS(
"a",
"cut()",
"Invalid empty parameter list '()'");
903 TEST_CI_ERROR_CONTAINS(
"a",
"cut(\"\")",
"Illegal stream number '0' (allowed [1..1])");
905 TEST_CI(
"one,two,three,four,five,six", WITH_SPLITTED(
"|dropempty|streams"),
"6");
906 TEST_CI(
"one,two,,,five,six", WITH_SPLITTED(
"|dropempty|streams"),
"4");
907 TEST_CI(
",,,,,", WITH_SPLITTED(
"|dropempty"),
"");
908 TEST_CI(
",,,,,", WITH_SPLITTED(
"|dropempty|streams"),
"0");
910 TEST_CI(
"1,0,0,2,3,0", WITH_SPLITTED(
"|dropzero"),
"1,2,3");
911 TEST_CI(
"0,0,0,0,0,0", WITH_SPLITTED(
"|dropzero"),
"");
912 TEST_CI(
"0,0,0,0,0,0", WITH_SPLITTED(
"|dropzero|streams"),
"0");
914 TEST_CI(
"12345",
"|colsplit|streams",
"5");
915 TEST_CI(
"12345",
"|colsplit" ACI_MERGE,
"1,2,3,4,5");
916 TEST_CI(
"12345",
"|colsplit(3)" ACI_MERGE,
"123,45");
917 TEST_CI(
"12345,678,90", WITH_SPLITTED(
"|colsplit(2)"),
"12,34,5,67,8,90");
918 TEST_CI_NOOP(
"12345,678,90", WITH_SPLITTED(
"|colsplit(5)"));
921 TEST_CI(
"1,2,3,four,five,six", WITH_SPLITTED(
"|swap"),
"1,2,3,four,six,five");
922 TEST_CI(
"1,2,3,four,five,six", WITH_SPLITTED(
"|swap(2,3)"),
"1,3,2,four,five,six");
923 TEST_CI(
"1,2,3,four,five,six", WITH_SPLITTED(
"|swap(2,3)|swap(4,3)"),
"1,3,four,2,five,six");
924 TEST_CI_NOOP(
"1,2,3,four,five,six", WITH_SPLITTED(
"|swap(3,3)"));
925 TEST_CI_NOOP(
"1,2,3,four,five,six", WITH_SPLITTED(
"|swap(3,2)|swap(2,3)"));
926 TEST_CI_NOOP(
"1,2,3,four,five,six", WITH_SPLITTED(
"|swap(3,2)|swap(3,1)|swap(2,1)|swap(1,3)"));
928 TEST_CI_ERROR_CONTAINS(
"a",
"swap",
"need at least two input streams");
929 TEST_CI_ERROR_CONTAINS(
"a,b", WITH_SPLITTED(
"|swap(2,3)"),
"Illegal stream number '3' (allowed [1..2])");
930 TEST_CI_ERROR_CONTAINS(
"a,b", WITH_SPLITTED(
"|swap(3,2)"),
"Illegal stream number '3' (allowed [1..2])");
931 TEST_CI_ERROR_CONTAINS(
"a,b", WITH_SPLITTED(
"|swap(1)"),
"syntax: swap[(streamnumber,streamnumber)]");
932 TEST_CI_ERROR_CONTAINS(
"a,b", WITH_SPLITTED(
"|swap(1,2,3)"),
"syntax: swap[(streamnumber,streamnumber)]");
935 TEST_CI (
"front,mid,back", WITH_SPLITTED(
"|toback(2)"),
"front,back,mid");
936 TEST_CI (
"front,mid,back", WITH_SPLITTED(
"|tofront(2)"),
"mid,front,back");
937 TEST_CI_NOOP(
"front,mid,back", WITH_SPLITTED(
"|toback(3)"));
938 TEST_CI_NOOP(
"front,mid,back", WITH_SPLITTED(
"|tofront(1)"));
939 TEST_CI_NOOP(
"a", WITH_SPLITTED(
"|tofront(1)"));
940 TEST_CI_NOOP(
"a", WITH_SPLITTED(
"|toback(1)"));
942 TEST_CI_ERROR_CONTAINS(
"a,b", WITH_SPLITTED(
"|tofront(3)"),
"Illegal stream number '3' (allowed [1..2])");
943 TEST_CI_ERROR_CONTAINS(
"a,b", WITH_SPLITTED(
"|toback(3)"),
"Illegal stream number '3' (allowed [1..2])");
944 TEST_CI_ERROR_CONTAINS(
"a,b", WITH_SPLITTED(
"|tofront"),
"syntax: tofront(streamnumber)");
945 TEST_CI_ERROR_CONTAINS(
"a,b", WITH_SPLITTED(
"|toback(1,2)"),
"syntax: toback(streamnumber)");
946 TEST_CI_ERROR_CONTAINS(
"a,b", WITH_SPLITTED(
"|merge(1,2)"),
"syntax: merge[(\"separator\")]");
949 TEST_CI (
"a\nb",
"|split" ACI_MERGE,
"a,b");
950 TEST_CI (
"a-b",
"|split(-)" ACI_MERGE,
"a,b");
951 TEST_CI (
"a-b",
"|split(-,0)" ACI_MERGE,
"a,b");
952 TEST_CI (
"a-b",
"|split(-,1)" ACI_MERGE,
"a,-b");
953 TEST_CI (
"a-b",
"|split(-,2)" ACI_MERGE,
"a-,b");
954 TEST_CI_ERROR_CONTAINS(
"a-b",
"|split(-,3)" ACI_MERGE,
"Illegal split mode '3' (valid: 0..2)");
955 TEST_CI_ERROR_CONTAINS(
"a\nb",
"|split(1,2,3)" ACI_MERGE,
"syntax: split[(\"separator\"[,mode])]");
957 #define C0_9 "0123456789"
958 #define CA_Z "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
959 #define Ca_z "abcdefghijklmnopqrstuvwxyz"
962 TEST_CI(
"1,2,3,four,five,six",
"extract_words(\"" C0_9
"\",1)",
"1 2 3");
963 TEST_CI(
"1,2,3,four,five,six",
"extract_words(\"" Ca_z
"\", 3)",
"five four six");
964 TEST_CI(
"1,2,3,four,five,six",
"extract_words(\"" CA_Z
"\", 3)",
"");
965 TEST_CI(
"1,2,3,four,five,six",
"extract_words(\"" Ca_z
"\", 4)",
"five four");
966 TEST_CI(
"1,2,3,four,five,six",
"extract_words(\"" Ca_z
"\", 5)",
"");
967 TEST_CI(
"7 3b 12A 1 767 111 1 77",
"extract_words(\"" C0_9 CA_Z Ca_z
"\", 1)",
"1 1 111 12A 3b 7 767 77");
969 TEST_CI (
"1,2,3,four,five,six",
"extract_sequence(\"acgtu\", 1.0)",
"");
970 TEST_CI (
"1,2,3,four,five,six",
"extract_sequence(\"acgtu\", 0.5)",
"");
971 TEST_CI (
"1,2,3,four,five,six",
"extract_sequence(\"acgtu\", 0.0)",
"four five six");
972 TEST_CI (
"..acg--ta-cgt...",
"extract_sequence(\"acgtu\", 1.0)",
"");
973 TEST_CI_NOOP(
"..acg--ta-cgt...",
"extract_sequence(\"acgtu-.\", 1.0)");
974 TEST_CI_NOOP(
"..acg--ta-ygt...",
"extract_sequence(\"acgtu-.\", 0.7)");
975 TEST_CI (
"70 ..acg--ta-cgt... 70",
"extract_sequence(\"acgtu-.\", 1.0)",
"..acg--ta-cgt...");
978 TEST_CI(
"",
"sequence|checksum",
"4C549A5F");
979 TEST_CI(
"",
"sequence | gcgchecksum",
"4308");
982 TEST_CI(
"The quick brown fox",
"srt(\"quick=lazy:brown fox=dog\")",
"The lazy dog");
983 TEST_CI(
"The quick brown fox",
"srt(quick=lazy:brown\\ fox=dog)",
"The lazy dog");
984 TEST_CI_ERROR_CONTAINS(
"x",
"srt(x=y,z)",
"SRT ERROR: no '=' found in command");
985 TEST_CI_ERROR_CONTAINS(
"x",
"srt",
"syntax: srt(expr[,expr]+)");
988 TEST_CI(
"stars*to*stripes",
"/\\*/--/",
"stars--to--stripes");
990 TEST_CI_ERROR_CONTAINS(
"xxx",
"//--",
"Regular expression format is '/expr/' or '/expr/i', not '//--'");
991 TEST_CI_ERROR_CONTAINS(
"xxx",
"/*/bla/",
995 "repetition-operator operand invalid"
997 "Invalid preceding regular expression"
1001 TEST_CI(
"sImILaRWIllBE,GonEEASIly", WITH_SPLITTED(
"|command(/[A-Z]//)"),
"small,only");
1002 TEST_CI(
"sthBIGinside,FATnotCAP", WITH_SPLITTED(
"|command(/([A-Z])+/)"),
"BIG,FAT");
1005 TEST_CI(
"a,bb,ccc", WITH_SPLITTED(
"|\"[\";len;\"]\""),
"[,1,2,3,]");
1006 TEST_CI(
"a,bb,ccc", WITH_SPLITTED(
"|command(\"\"[\";len;\"]\"\")"),
"[1],[2],[3]");
1008 TEST_CI(
"a,bb,ccc", WITH_SPLITTED(
"|len|minus(1)"),
"0,1,2");
1009 TEST_CI(
"a,bb,ccc", WITH_SPLITTED(
"|command(\"len|minus(1)\")"),
"0,1,2");
1011 TEST_CI(
"a,bb,ccc,dd", WITH_SPLITTED(
"|len|minus"),
"-1,1");
1012 TEST_CI_ERROR_CONTAINS(
"a,bb,ccc,dd", WITH_SPLITTED(
"|command(\"len|minus\")"),
"Expect an even number of input streams");
1020 GBDATA *
const gb_data = E.gbspecies();
1024 TEST_CI(
"",
"echo(9.9,3.9) |plus;fplus" ACI_MERGE,
"12,13.8");
1025 TEST_CI(
"",
"echo(9.1,3.9) |minus;fminus" ACI_MERGE,
"6,5.2");
1026 TEST_CI(
"",
"echo(9,3.5) |mult;fmult" ACI_MERGE,
"27,31.5");
1027 TEST_CI(
"",
"echo(9,0.1) |mult;fmult" ACI_MERGE,
"0,0.9");
1028 TEST_CI(
"",
"echo(9,3) |div;fdiv" ACI_MERGE,
"3,3");
1029 TEST_CI(
"",
"echo(10,3) |div;fdiv" ACI_MERGE,
"3,3.33333");
1031 TEST_CI(
"",
"echo(9,3)|rest",
"0");
1032 TEST_CI(
"",
"echo(9,5)|rest",
"4");
1034 TEST_CI(
"",
"echo(9,3) |per_cent;fper_cent" ACI_MERGE,
"300,300");
1035 TEST_CI(
"",
"echo(3,9) |per_cent;fper_cent" ACI_MERGE,
"33,33.3333");
1036 TEST_CI(
"",
"echo(1,8) |per_cent;fper_cent" ACI_MERGE,
"12,12.5");
1037 TEST_CI(
"",
"echo(15,16)|per_cent;fper_cent" ACI_MERGE,
"93,93.75");
1038 TEST_CI(
"",
"echo(1,8) |fper_cent|round(0)",
"13");
1039 TEST_CI(
"",
"echo(15,16)|fper_cent|round(0);round(1)" ACI_MERGE,
"94,93.8");
1041 TEST_CI(
"",
"echo(1,2,3)|plus(1)" ACI_MERGE,
"2,3,4");
1042 TEST_CI(
"",
"echo(1,2,3)|minus(2)" ACI_MERGE,
"-1,0,1");
1043 TEST_CI(
"",
"echo(1,2,3)|mult(42)" ACI_MERGE,
"42,84,126");
1044 TEST_CI(
"",
"echo(1,2,3)|div(2)" ACI_MERGE,
"0,1,1");
1045 TEST_CI(
"",
"echo(1,2,3)|rest(2)" ACI_MERGE,
"1,0,1");
1046 TEST_CI(
"",
"echo(1,2,3)|per_cent(3)" ACI_MERGE,
"33,66,100");
1049 #define ROUND_FLOATS(dig) "echo(0.3826,0.50849,12.58,77.2,700.099,0.9472e-4,0.175e+7)|round(" #dig ")" ACI_MERGE
1051 TEST_CI(
"", ROUND_FLOATS(4),
"0.3826,0.5085,12.58,77.2,700.099,0.0001,1.75e+06");
1052 TEST_CI(
"", ROUND_FLOATS(3),
"0.383,0.508,12.58,77.2,700.099,0,1.75e+06");
1053 TEST_CI(
"", ROUND_FLOATS(2),
"0.38,0.51,12.58,77.2,700.1,0,1.75e+06");
1054 TEST_CI(
"", ROUND_FLOATS(1),
"0.4,0.5,12.6,77.2,700.1,0,1.75e+06");
1055 TEST_CI(
"", ROUND_FLOATS(0),
"0,1,13,77,700,0,1.75e+06");
1056 TEST_CI(
"", ROUND_FLOATS(-1),
"0,0,10,80,700,0,1.75e+06");
1057 TEST_CI(
"", ROUND_FLOATS(-2),
"0,0,0,100,700,0,1.75e+06");
1058 TEST_CI(
"", ROUND_FLOATS(-3),
"0,0,0,0,1000,0,1.75e+06");
1059 TEST_CI(
"", ROUND_FLOATS(-5),
"0,0,0,0,0,0,1.8e+06");
1060 TEST_CI(
"", ROUND_FLOATS(-6),
"0,0,0,0,0,0,2e+06");
1064 TEST_CI(
"",
"echo(9,3)|isBelow;isAbove;isEqual",
"010");
1065 TEST_CI(
"",
"echo(3,9)|isBelow;isAbove;isEqual",
"100");
1066 TEST_CI(
"",
"echo(5,5)|isBelow;isAbove;isEqual",
"001");
1068 TEST_CI(
"",
"echo(1,2,3)|isBelow(2)",
"100");
1069 TEST_CI(
"",
"echo(1,2,3)|isAbove(2)",
"001");
1070 TEST_CI(
"",
"echo(1,2,3)|isEqual(2)",
"010");
1072 TEST_CI(
"",
"echo(1,2,3,4,5)|inRange(2,4)",
"01110");
1073 TEST_CI(
"",
"echo(-1,-2,-3,-4,-5)|inRange(-2,-4)",
"00000");
1074 TEST_CI(
"",
"echo(-1,-2,-3,-4,-5)|inRange(-4,-2)",
"01110");
1077 TEST_CI(
"",
"echo(1.7,1.4) |isBelow;isAbove;isEqual",
"010");
1078 TEST_CI(
"",
"echo(-0.7,0.1) |isBelow;isAbove;isEqual",
"100");
1079 TEST_CI(
"",
"echo(5.10,5.1) |isBelow;isAbove;isEqual",
"001");
1080 TEST_CI(
"",
"echo(0.10,.11) |isBelow;isAbove;isEqual",
"100");
1081 TEST_CI(
"",
"echo(-7.1,-6.9)|isBelow;isAbove;isEqual",
"100");
1082 TEST_CI(
"",
"echo(1e+5,1e+6)|isBelow;isAbove;isEqual",
"100");
1083 TEST_CI(
"",
"echo(2e+5,1e+6)|isBelow;isAbove;isEqual",
"100");
1084 TEST_CI(
"",
"echo(2e+5,1e-6)|isBelow;isAbove;isEqual",
"010");
1085 TEST_CI(
"",
"echo(2e-5,1e+6)|isBelow;isAbove;isEqual",
"100");
1087 TEST_CI(
"",
"echo(.1,.2,.3,.4,.5) |inRange(.2,.4)",
"01110");
1088 TEST_CI(
"",
"echo(.8,.9,1.0,1.1,1.2)|inRange(.9,1.1)",
"01110");
1089 TEST_CI(
"",
"echo(-.2,-.1,0.0,.1,.2)|inRange(-.1,.1)",
"01110");
1092 TEST_CI(
"0",
"Not",
"1");
1093 TEST_CI(
"1",
"Not",
"0");
1095 TEST_CI(
"",
"Not",
"1");
1096 TEST_CI(
"text",
"Not",
"1");
1098 TEST_CI(
"",
"echo(0,1)|Not",
"10");
1099 TEST_CI(
"",
"echo(0,0)|Or;And",
"00");
1100 TEST_CI(
"",
"echo(0,1)|Or;And",
"10");
1101 TEST_CI(
"",
"echo(1,0)|Or;And",
"10");
1102 TEST_CI(
"",
"echo(1,1)|Or;And",
"11");
1104 TEST_CI(
"",
"command(echo(1\\,0)|Or);command(echo(0\\,1)|Or)|And",
"1");
1107 TEST_CI(
"",
"readdb(name)",
"LcbReu40");
1108 TEST_CI(
"",
"readdb(acc)",
"X76328");
1109 TEST_CI(
"",
"readdb(acc,name)",
"X76328LcbReu40");
1111 TEST_CI_ERROR_CONTAINS(
"",
"readdb()",
"Invalid empty parameter list '()'");
1112 TEST_CI_ERROR_CONTAINS(
"",
"readdb",
"syntax: readdb(fieldname[,fieldname]+)");
1113 TEST_CI (
"",
"readdb(\"\")",
"");
1116 TEST_CI(
"",
"taxonomy(1)",
"No default tree");
1117 TEST_CI(
"",
"taxonomy(tree_nuc, 1)",
"group1");
1118 TEST_CI(
"",
"taxonomy(tree_nuc, 5)",
"lower-red/group1");
1125 GBDATA *
const gb_data = E.gbspecies();
1128 GBL_env env_tree_nuc(E.gbmain(),
"tree_nuc");
1131 TEST_CI_ERROR_CONTAINS(
"",
"taxonomy",
"syntax: taxonomy([tree_name,]count)");
1132 TEST_CI_ERROR_CONTAINS(
"",
"taxonomy(1,2,3)",
"syntax: taxonomy([tree_name,]count)");
1133 TEST_CI_WITH_ENV(
"", callEnv_tree_nuc,
"taxonomy(1)",
"group1");
1136 TEST_CI(
"..acg--ta-cgt..." ","
1137 "..acg--ta-cgt...", WITH_SPLITTED(
"|diff(pairwise=1)"),
1138 "................");
1139 TEST_CI(
"..acg--ta-cgt..." ","
1140 "..cgt--ta-acg...", WITH_SPLITTED(
"|diff(pairwise=1,equal==)"),
1141 "==cgt=====acg===");
1142 TEST_CI(
"..acg--ta-cgt..." ","
1143 "..cgt--ta-acg...", WITH_SPLITTED(
"|diff(pairwise=1,differ=X)"),
1144 "..XXX.....XXX...");
1145 TEST_CI(
"",
"sequence|diff(species=LcbFruct)|checksum",
"645E3107");
1147 TEST_CI(
"..XXX.....XXX..." ","
1148 "..acg--ta-cgt...", WITH_SPLITTED(
"|filter(pairwise=1,exclude=X)"),
1150 TEST_CI(
"..XXX.....XXX..." ","
1151 "..acg--ta-cgt...", WITH_SPLITTED(
"|filter(pairwise=1,include=X)"),
1153 TEST_CI(
"",
"sequence|filter(species=LcbFruct,include=.-)",
"-----------T----T-------G----------C-----T----T...");
1155 TEST_CI(
"...XXX....XXX..." ","
1156 "..acg--ta-cgt...", WITH_SPLITTED(
"|change(pairwise=1,include=X,to=C,change=100)"),
1157 "..aCC--ta-CCC...");
1158 TEST_CI(
"...XXXXXXXXX...." ","
1159 "..acg--ta-cgt...", WITH_SPLITTED(
"|change(pairwise=1,include=X,to=-,change=100)"),
1160 "..a---------t...");
1163 TEST_CI(
"x",
":*=*,*(acc)",
"x,X76328");
1164 TEST_CI(
"x",
"srt(\"*=*,*(acc)\")",
"x,X76328");
1165 TEST_CI(
"x",
":*=*,*(acc|dd;\",\";readdb(name))",
"x,X76328,LcbReu40");
1166 TEST_CI(
"x",
"srt(\"*=*,*(acc|dd;\"\\,\";readdb(name))\")",
"x,X76328,LcbReu40");
1167 TEST_CI(
"x",
"command(\"dd;\\\",\\\";readdb(name)\")",
"x,LcbReu40");
1170 TEST_CI_WITH_ENV(
"x", callEnv_tree_nuc,
":*=*,*(acc|dd;\\\",\\\";taxonomy(1))",
"x,X76328,group1");
1171 TEST_CI_WITH_ENV(
"", callEnv_tree_nuc,
"taxonomy(5)|srt(*=*\\,*(acc|dd;\\\",\\\";taxonomy(1)))",
"lower-red/group1,X76328,group1");
1172 TEST_CI_WITH_ENV(
"", callEnv_tree_nuc,
"taxonomy(5)|command(\"dd;\\\",\\\";taxonomy(1)\")",
"lower-red/group1,group1");
1175 TEST_CI(
"x",
":*=*,*(acc|dd;\\\",\\\";ali_name;\\\",\\\";sequence_type)",
"x,X76328,ali_16s,rna");
1176 TEST_CI(
"x",
"srt(\"*=*,*(acc|dd;\\\",\\\";ali_name;\\\",\\\";sequence_type)\")",
"x,X76328,ali_16s,rna");
1177 TEST_CI(
"x",
"command(\"dd;\\\",\\\";ali_name;\\\",\\\";sequence_type\")",
"x,ali_16s,rna");
1180 TEST_CI(
"c,b,c,b,a,a", WITH_SPLITTED(
"|exec(\"(sort|uniq)\")|split|dropempty"),
"a,b,c");
1181 TEST_CI(
"a,aba,cac", WITH_SPLITTED(
"|exec(\"perl\",-pe,s/([bc])/$1$1/g)|split|dropempty"),
"a,abba,ccacc");
1184 TEST_CI_ERROR_CONTAINS(
"",
"nocmd",
"Unknown command 'nocmd'");
1185 TEST_CI_ERROR_CONTAINS(
"",
"|nocmd",
"Unknown command 'nocmd'");
1186 TEST_CI_ERROR_CONTAINS(
"",
"caps(x)",
"syntax: caps (no parameters)");
1187 TEST_CI_ERROR_CONTAINS(
"",
"trace",
"syntax: trace(0|1)");
1188 TEST_CI_ERROR_CONTAINS(
"",
"count",
"syntax: count(\"characters to count\")");
1189 TEST_CI_ERROR_CONTAINS(
"",
"count(a,b)",
"syntax: count(\"characters to count\")");
1190 TEST_CI_ERROR_CONTAINS(
"",
"len(a,b)",
"syntax: len[(\"characters not to count\")]");
1191 TEST_CI_ERROR_CONTAINS(
"",
"plus(a,b,c)",
"syntax: plus[(Expr1[,Expr2])]");
1192 TEST_CI_ERROR_CONTAINS(
"",
"count(a,b",
"Reason: Missing ')'");
1193 TEST_CI_ERROR_CONTAINS(
"",
"count(a,\"b)",
"unbalanced '\"' in 'count(a,\"b)'");
1194 TEST_CI_ERROR_CONTAINS(
"",
"count(a,\"b)\"",
"Reason: Missing ')'");
1195 TEST_CI_ERROR_CONTAINS(
"",
"dd;dd|count",
"syntax: count(\"characters to count\")");
1196 TEST_CI_ERROR_CONTAINS(
"",
"|count(\"a\"x)",
"Invalid parameter syntax for '\"a\"x'");
1197 TEST_CI_ERROR_CONTAINS(
"",
"|count(\"a\"x\")",
"unbalanced '\"' in '|count(\"a\"x\")'");
1198 TEST_CI_ERROR_CONTAINS(
"",
"|count(\"a)",
"unbalanced '\"' in '|count(\"a)'");
1200 TEST_CI_ERROR_CONTAINS__BROKEN(
"",
"|\"xx\"bla",
"bla",
"xx");
1202 TEST_CI_ERROR_CONTAINS(
"",
"translate(a)",
"syntax: translate(old,new[,other])");
1203 TEST_CI_ERROR_CONTAINS(
"",
"translate(a,b,c,d)",
"syntax: translate(old,new[,other])");
1204 TEST_CI_ERROR_CONTAINS(
"",
"translate(a,b,xx)",
"has to be one character");
1205 TEST_CI_ERROR_CONTAINS(
"",
"translate(a,b,)",
"has to be one character");
1207 TEST_CI_ERROR_CONTAINS(
NULp,
"whatever",
"ARB ERROR: Can't read this DB entry as string");
1209 TEST_CI(
"hello",
":??""=(?-?)",
"(h-e)(l-l)o");
1210 TEST_CI(
"hello",
":??""=(?-?)?",
"(h-e)?(l-l)?o");
1211 TEST_CI(
"hello",
":??""=(?-?0)?",
"(h-e0)?(l-l0)?o");
1212 TEST_CI(
"hello",
":??""=(?-?3)?",
"(h-?)e(l-?)lo");
1215 TEST_CI(
"abc",
":?=?\\n",
"a\nb\nc\n");
1216 TEST_CI(
"abc",
":?=?\n",
"a\nb\nc\n");
1219 TEST_CI(
"abc",
":?=?.\\0 ignored:b=d",
"a.b.c.");
1220 TEST_CI(
"abc",
":?=?.\0 ignored:b=d",
"a.b.c.");
1222 TEST_CI(
"",
":*=X*Y*(full_name|len)",
"XY21");
1223 TEST_CI(
"",
":*=*(full_name\\:reuteri=xxx)",
"Lactobacillus xxx");
1224 TEST_CI(
"",
":*=*(abc\\:a=A)",
"");
1225 TEST_CI(
"hello world",
":* =*(\\:*=hi)-",
"hi-world");
1226 TEST_CI_ERROR_CONTAINS(
"",
":*=*(full_name\\:reuteri)",
"no '=' found");
1228 TEST_CI(
"",
":*=*(acc#have no acc)",
"X76328");
1229 TEST_CI(
"",
":*=*(abc#have no abc)",
"have no abc");
1230 TEST_CI(
"",
":*=*(#no field)",
"no field");
1232 TEST_CI_ERROR_CONTAINS(
"",
":*=*(unbalanced",
"Unbalanced parenthesis in '(unbalanced'");
1233 TEST_CI_ERROR_CONTAINS(
"",
":*=*(unba(lan)ced",
"Unbalanced parenthesis in '(unba(lan)ced'");
1234 TEST_CI_ERROR_CONTAINS(
"",
":*=*(unba(lan)c)ed)",
"Invalid char '(' in key 'unba(lan)c'");
1235 TEST_CI (
"",
":*=*(unbalanc)ed)",
"ed)");
1247 TEST_CI(
NULp,
"",
"Lactobacillus reuteri");
1248 TEST_CI(
NULp,
"|len",
"21");
1249 TEST_CI(
NULp,
":tobac=",
"Lacillus reuteri");
1250 TEST_CI(
NULp,
"/ba.*us/B/",
"LactoB reuteri");
1251 TEST_CI(
NULp,
":::*=hello:::hell=heaven:::",
"heaveno");
1252 TEST_CI(
NULp,
":* *=;*2,*1;",
";reuteri,Lactobacillus;");
1253 TEST_CI(
NULp,
":* ??*=;?2,?1,*2,*1;",
";e,r,uteri,Lactobacillus;");
1254 TEST_CI(
NULp,
":Lacto*eutei=*1",
"Lactobacillus reuteri");
1255 TEST_CI(
NULp,
":Lact?bac?lls=?1?2",
"Lactobacillus reuteri");
1256 TEST_CI(
NULp,
":*reuteri?=?1",
"Lactobacillus reuteri");
1259 TEST_CI__BROKEN(
NULp,
":Lacto*?lus=(*1,?1)",
"(baci,l)",
"Lactobacillus reuteri");
1260 TEST_CI__BROKEN(
"Lactobaci\4lus reuteri",
":Lacto*?lus=(*1,?1)",
"<want error instead>",
"(baci,?) reuteri");
1261 TEST_CI_ERROR_CONTAINS__BROKEN(
NULp,
":Lacto**lus=(*1,*2)",
"invalid",
"Lactobacillus reuteri");
1262 TEST_CI_ERROR_CONTAINS__BROKEN(
"Lactobac\3lus reuteri",
":Lacto**lus=(*1,*2)",
"invalid",
"(bac,*) reuteri");
1264 TEST_CI_ERROR_CONTAINS(
NULp,
":*=*(|wot)",
"Unknown command 'wot'");
1265 TEST_CI_ERROR_CONTAINS(
"",
":*=X*Y*(|wot)",
"Unknown command 'wot'");
1267 TEST_CI_ERROR_CONTAINS(
"",
":*=X*Y*(full_name|len)",
"can't read key 'full_name' (DB item is no container)");
1268 TEST_CI (
"",
":*=X*Y*(../full_name|len)",
"XY21");
1270 TEST_CI(
NULp,
"|taxonomy(1)",
"No default tree");
1271 TEST_CI_ERROR_CONTAINS(
NULp,
"|taxonomy(tree_nuc,2)",
"Container has neither 'name' nor 'group_name' entry - can't detect container type");
1278 TEST_CI(
NULp,
"",
"1");
1279 TEST_CI(
"",
"ali_name;\",\";sequence_type",
"ali_16s,rna");
1286 TEST_CI_ERROR_CONTAINS(
NULp,
"",
"no input streams found");
1287 TEST_CI(
"",
":*=\\tA*1Z\t",
"\tAZ\t");
1289 TEST_CI_ERROR_CONTAINS(
"",
":*=X*Y*(|wot)",
"Unknown command 'wot'");
1290 TEST_CI_ERROR_CONTAINS(
"",
":*=X*Y*(nokey|len)",
"can't read key 'nokey' (called w/o database item)");
1291 TEST_CI_ERROR_CONTAINS(
"",
":*=X*Y*(nokey)",
"can't read key 'nokey' (called w/o database item)");
1294 TEST_CI(
"",
"ali_name;\",\";sequence_type",
"ali_16s,rna");
1295 TEST_CI(
"",
"command(\"ali_name;\\\",\\\";sequence_type\")",
"ali_16s,rna");
1298 TEST_CI(
"in",
NULp,
"in");
1299 TEST_CI(
"in",
"",
"in");
1300 TEST_CI(
"in",
":",
"in");
1301 TEST_CI(
"in",
"::",
"in");
1304 TEST_CI(
"in",
NULp,
"in");
1305 TEST_CI(
"in",
"",
"in");
1306 TEST_CI(
"in",
":",
"in");
1307 TEST_CI(
"in",
"::",
"in");
1315 {
"custom", gbx_custom },
1316 {
"upper", stdCmds.
lookup(
"lower") },
1317 {
"lower", stdCmds.
lookup(
"upper") },
1324 GBDATA *
const gb_data = E.gbspecies();
1335 TEST_CI_WITH_ENV (
"abc", customCallEnv,
"dd;custom;dd",
"abc4711abc");
1336 TEST_CI_ERROR_CONTAINS(
"abc",
"dd;custom;dd",
"Unknown command 'custom'");
1339 TEST_CI_WITH_ENV(
"abcDEF,", customCallEnv,
"dd;lower;upper",
"abcDEF,ABCDEF,abcdef,");
1340 TEST_CI (
"abcDEF,",
"dd;lower;upper",
"abcDEF,abcdef,ABCDEF,");
1344 void TEST_GB_command_interpreter_4() {
1349 GBDATA *
const gb_data = E.gbspecies();
1352 TEST_CI(
"LcbReu40",
"findspec(\"readdb (acc)\")",
"X76328");
1353 TEST_CI(
"LcbFruct",
"findspec(\"readdb (acc)\")",
"X76330");
1354 TEST_CI(
"",
"readdb(name)|findspec(\"readdb(acc)\")",
"X76328");
1356 TEST_CI(
"LcbReu40;lcbfruct",
"split(\";\")|findspec(\"readdb(acc)\")|merge(\";\")",
"X76328;X76330");
1357 TEST_CI(
"X76328;x76330",
"split(\";\")|findacc(\"readdb(name)\")|merge(\";\")",
"LcbReu40;LcbFruct");
1359 TEST_CI (
"",
"findspec(\"invalid\")",
"");
1360 TEST_CI_ERROR_CONTAINS(
"LcbReu40",
"findspec(\"invalid\")",
"Unknown command 'invalid'");
1361 TEST_CI_ERROR_CONTAINS(
"unknown",
"findspec(\"invalid\")",
"No species with name 'unknown' found");
1362 TEST_CI_ERROR_CONTAINS(
"unknown",
"findacc(\"invalid\")",
"No species with acc 'unknown' found");
1365 #endif // UNIT_TESTS
const GBL_streams & get_param_streams() const
GBDATA * GB_open(const char *path, const char *opent)
static GB_ERROR tab(GBL_command_arguments *args, bool pretab)
GBDATA * get_item_ref() const
static void dumpStreams(const char *name, const GBL_streams &streams)
GBL_COMMAND lookup_command(const char *identifier) const
char * GBS_string_eval_in_env(const char *insource, const char *icommand, const GBL_call_env &callEnv)
CONSTEXPR_INLINE unsigned char safeCharIndex(char c)
const char * get(int idx) const
char * ARB_strdup(const char *str)
const char * get_cmdName() const
char * GB_read_as_string(GBDATA *gbd)
NOT4PERL char * GB_command_interpreter_in_env(const char *str, const char *commands, const GBL_call_env &callEnv)
const char * GBS_global_string(const char *templat,...)
void nput(char c, size_t count)
char * GBS_regreplace(const char *str, const char *regReplExpr, GB_ERROR *error)
void cat(const char *from)
char * ARB_strpartdup(const char *start, const char *end)
#define ARRAY_ELEMS(array)
char buffer[MESSAGE_BUFFERSIZE]
const char * GBS_regmatch(const char *str, const char *regExpr, size_t *matchlen, GB_ERROR *error)
GB_ERROR GB_export_error(const char *error)
#define TEST_EXPECT(cond)
GB_TYPES GB_read_type(GBDATA *gbd)
GB_ERROR(* GBL_COMMAND)(GBL_command_arguments *args)
void print_trace(const char *text)
const GBL_env & get_env() const
const char * get_param(int idx) const
#define SmartMallocPtr(type)
static void error(const char *msg)
static const char * shortenLongString(const char *str, size_t wanted_len)
#define __ATTR__REDUCED_OPTIMIZE
static const char * search_matching_dquote(const char *str)
#define EXPECT_NO_PARAM(args)
static char * apply_ACI(const char *str, const char *commands, const GBL_call_env &callEnv)
GB_ERROR GB_export_errorf(const char *templat,...)
GB_ERROR close(GB_ERROR error)
char * ARB_strndup(const char *start, int len)
void modify_trace_indent(int diff)
static const char * search_next_separator(const char *source, const char *seps)
virtual GBL_COMMAND lookup(const char *identifier) const
char * GB_command_interpreter(const char *str, const char *commands, GBDATA *gb_main)
GBL_command_lookup_table(const GBL_command_definition *table, unsigned size)
const char * search_matching_parenthesis(const char *source)
static ARB_init_perl_interface init
#define TEST_EXPECT_NO_ERROR(call)
void swap(GBL_streams &other)
GBDATA * GBT_find_species(GBDATA *gb_main, const char *name)
#define __ATTR__REDUCED_OPTIMIZE__NO_GCSE
const char * get_data() const
GB_transaction ta(gb_var)
char * concatenated() const
GB_CSTR GB_read_char_pntr(GBDATA *gbd)
const GBL_command_lookup_table & ACI_get_standard_commands()
char * release_memfriendly()
GBDATA * GB_entry(GBDATA *father, const char *key)
size_t get_position() const
char * GBS_global_string_copy(const char *templat,...)
void GB_close(GBDATA *gbd)
GB_write_int const char s