5 * (c) 2024 Straylight/Edgeware
8 /*----- Licensing notice --------------------------------------------------*
10 * This file is part of the mLib utilities library.
12 * mLib is free software: you can redistribute it and/or modify it under
13 * the terms of the GNU Library General Public License as published by
14 * the Free Software Foundation; either version 2 of the License, or (at
15 * your option) any later version.
17 * mLib is distributed in the hope that it will be useful, but WITHOUT
18 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
19 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
20 * License for more details.
22 * You should have received a copy of the GNU Library General Public
23 * License along with mLib. If not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
28 /*----- Header files ------------------------------------------------------*/
34 /*----- Register allocation -----------------------------------------------*/
43 RX = NROUT, RNAME = RX,
49 /*----- Addition test -----------------------------------------------------*/
51 void test_add(const struct tvec_reg *in, struct tvec_reg *out, void *ctx)
52 { out[RZ].v.i = add(in[RX].v.i, in[RY].v.i); }
54 static const struct tvec_regdef add_regs[] = {
55 { "x", &tvty_int, RX, 0, { &tvrange_int } },
56 { "y", &tvty_int, RY, 0, { &tvrange_int } },
57 { "z", &tvty_int, RZ, 0, { &tvrange_int } },
62 { "add", add_regs, 0, test_add }
64 /*----- Greeting test -----------------------------------------------------*/
66 void test_greet(const struct tvec_reg *in, struct tvec_reg *out, void *ctx)
68 tvec_alloctext(&out[RMSG].v, in[RSZ].v.u);
69 out[RRC].v.i = greet(out[RMSG].v.text.p, in[RSZ].v.u, in[RNAME].v.text.p);
70 out[RMSG].v.text.sz = strlen(out[RMSG].v.text.p);
73 static const struct tvec_regdef greet_regs[] = {
74 { "name", &tvty_text, RNAME, 0 },
75 { "sz", &tvty_size, RSZ, 0, { &tvrange_size } },
76 { "msg", &tvty_text, RMSG, TVRF_UNSET },
77 { "rc", &tvty_int, RRC, 0, { &tvrange_int } },
82 { "greet", greet_regs, 0, test_greet }
84 /*----- Main program ------------------------------------------------------*/
86 static const struct tvec_test tests[] = {
92 static const struct tvec_config test_config =
93 { tests, NROUT, NREG, sizeof(struct tvec_reg) };
95 int main(int argc, char *argv[])
96 { return (tvec_main(argc, argv, &test_config, 0)); }
98 /*----- That's all, folks -------------------------------------------------*/