From dbec0c38450ffdaef16ca3510f88e225878ee122 Mon Sep 17 00:00:00 2001 From: "Jan (janneke) Nieuwenhuizen" Date: Sun, 11 Sep 2022 23:34:20 +0200 Subject: [PATCH] test: Add 60-math-modulo.c. * lib/tests/scaffold/60-math-modulo.c: New test. * build-aux/check-mescc.sh (mes_tests): Add it. --- build-aux/check-mescc.sh | 3 +- lib/tests/scaffold/60-math-modulo.c | 79 +++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 lib/tests/scaffold/60-math-modulo.c diff --git a/build-aux/check-mescc.sh b/build-aux/check-mescc.sh index 16895ee2..46479a04 100755 --- a/build-aux/check-mescc.sh +++ b/build-aux/check-mescc.sh @@ -1,7 +1,7 @@ #! /bin/sh # GNU Mes --- Maxwell Equations of Software -# Copyright © 2017,2018,2019,2020 Jan (janneke) Nieuwenhuizen +# Copyright © 2017,2018,2019,2020,2022 Jan (janneke) Nieuwenhuizen # # This file is part of GNU Mes. # @@ -117,6 +117,7 @@ lib/tests/scaffold/54-argv.c lib/tests/scaffold/55-char-array.c lib/tests/scaffold/60-math.c lib/tests/scaffold/60-math-itoa.c +lib/tests/scaffold/60-math-modulo.c lib/tests/scaffold/61-array.c lib/tests/scaffold/62-array.c lib/tests/scaffold/63-struct.c diff --git a/lib/tests/scaffold/60-math-modulo.c b/lib/tests/scaffold/60-math-modulo.c new file mode 100644 index 00000000..05a6ea8d --- /dev/null +++ b/lib/tests/scaffold/60-math-modulo.c @@ -0,0 +1,79 @@ +/* -*-comment-start: "//";comment-end:""-*- + * GNU Mes --- Maxwell Equations of Software + * Copyright © 2022 Jan (janneke) Nieuwenhuizen + * + * This file is part of GNU Mes. + * + * GNU Mes is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or (at + * your option) any later version. + * + * GNU Mes is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with GNU Mes. If not, see . + */ + +#include +#include +#include + +#include + +int +main () +{ + int i; + + oputs ("\n"); + + oputs ("t: 1 % 2\n"); + i = 1 % 2; + if (i != 1) + return 1; + + oputs ("t: 2 % 4\n"); + i = 2 % 4; + if (i != 2) + return 2; + + oputs ("t: 3 % 4\n"); + i = 3 % 4; + if (i != 3) + return 3; + + oputs ("t: 1 % 256\n"); + i = 1 % 256; + if (i != 1) + return 4; + + unsigned u; + + oputs ("\n"); + + oputs ("t: 1U % 2\n"); + u = 1 % 2; + if (u != 1) + return 5; + + oputs ("t: 2U % 4\n"); + u = 2 % 4; + if (u != 2) + return 6; + + oputs ("t: 3U % 4\n"); + u = 3 % 4; + if (u != 3) + return 7; + + oputs ("t: 1U % 256\n"); + u = 1 % 256; + if (u != 1) + return 8; + + return 0; +}