2017-07-30 16:04:25 +00:00
|
|
|
/* -*-comment-start: "//";comment-end:""-*-
|
2018-07-22 12:24:36 +00:00
|
|
|
* GNU Mes --- Maxwell Equations of Software
|
2017-11-21 18:22:26 +00:00
|
|
|
* Copyright © 2017 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
|
2017-07-30 16:04:25 +00:00
|
|
|
*
|
2018-07-22 12:24:36 +00:00
|
|
|
* This file is part of GNU Mes.
|
2017-07-30 16:04:25 +00:00
|
|
|
*
|
2018-07-22 12:24:36 +00:00
|
|
|
* GNU Mes is free software; you can redistribute it and/or modify it
|
2017-07-30 16:04:25 +00:00
|
|
|
* 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.
|
|
|
|
*
|
2018-07-22 12:24:36 +00:00
|
|
|
* GNU Mes is distributed in the hope that it will be useful, but
|
2017-07-30 16:04:25 +00:00
|
|
|
* 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
|
2018-07-22 12:24:36 +00:00
|
|
|
* along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
|
2017-07-30 16:04:25 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "30-test.i"
|
2017-08-07 17:43:59 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
2017-07-30 16:04:25 +00:00
|
|
|
|
|
|
|
struct file {
|
2017-08-07 17:43:59 +00:00
|
|
|
char buffer[1];
|
2017-07-30 16:04:25 +00:00
|
|
|
};
|
|
|
|
|
2017-08-07 17:43:59 +00:00
|
|
|
struct xfile {
|
|
|
|
char *buffer;
|
|
|
|
};
|
2017-07-30 16:04:25 +00:00
|
|
|
|
|
|
|
struct file file;
|
2017-08-07 17:43:59 +00:00
|
|
|
struct xfile xfile;
|
2017-07-30 16:04:25 +00:00
|
|
|
|
2017-08-07 17:43:59 +00:00
|
|
|
char *buffer = "aaaaaaaaaaaa";
|
|
|
|
char *bufzor = "bbbbbbbbbbbb";
|
2017-07-30 16:04:25 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
test ()
|
|
|
|
{
|
2017-08-07 17:43:59 +00:00
|
|
|
char *p;
|
|
|
|
|
2017-07-30 16:04:25 +00:00
|
|
|
struct file *pfile = &file;
|
|
|
|
strcpy (file.buffer, "0123456789\n");
|
|
|
|
eputs (file.buffer);
|
2017-08-07 17:43:59 +00:00
|
|
|
p = pfile->buffer;
|
|
|
|
if (p[1] != '1') return 1;
|
|
|
|
if (file.buffer[1] != '1') return 2;
|
|
|
|
if (pfile->buffer[1] != '1') return 3;
|
|
|
|
|
|
|
|
strcpy (file.buffer, "0123456789\n");
|
|
|
|
eputs (file.buffer);
|
|
|
|
memcpy (pfile->buffer + 1, " ", 1);
|
|
|
|
eputs (file.buffer);
|
|
|
|
if (p[1] != ' ') return 4;
|
|
|
|
if (file.buffer[1] != ' ') return 5;
|
|
|
|
if (pfile->buffer[1] != ' ') return 6;
|
|
|
|
|
|
|
|
strcpy (file.buffer, "0123456789\n");
|
|
|
|
eputs (file.buffer);
|
|
|
|
p[2] = ' ';
|
|
|
|
eputs (file.buffer);
|
|
|
|
if (p[2] != ' ') return 7;
|
|
|
|
if (file.buffer[2] != ' ') return 8;
|
|
|
|
if (pfile->buffer[2] != ' ') return 9;
|
2017-07-30 16:04:25 +00:00
|
|
|
|
2017-08-07 17:43:59 +00:00
|
|
|
strcpy (file.buffer, "0123456789\n");
|
|
|
|
eputs (file.buffer);
|
|
|
|
file.buffer[3] = ' ';
|
2017-07-31 10:19:23 +00:00
|
|
|
eputs (file.buffer);
|
2017-08-07 17:43:59 +00:00
|
|
|
if (p[3] != ' ') return 10;
|
|
|
|
if (p[4] != '4') return 11;
|
2017-07-30 16:04:25 +00:00
|
|
|
|
|
|
|
strcpy (file.buffer, "0123456789\n");
|
|
|
|
eputs (file.buffer);
|
2017-08-07 17:43:59 +00:00
|
|
|
pfile->buffer[4] = ' ';
|
2017-07-30 16:04:25 +00:00
|
|
|
eputs (file.buffer);
|
2017-08-07 17:43:59 +00:00
|
|
|
if (p[4] != ' ') return 12;
|
|
|
|
if (p[5] != '5') return 13;
|
|
|
|
|
|
|
|
xfile.buffer = &buffer;
|
|
|
|
struct xfile *pxfile = &xfile;
|
|
|
|
strcpy (xfile.buffer, "0123456789\n");
|
|
|
|
eputs (xfile.buffer);
|
|
|
|
p = pxfile->buffer;
|
|
|
|
if (p[5] != '5') return 20;
|
|
|
|
if (xfile.buffer[5] != '5') return 22;
|
|
|
|
if (pxfile->buffer[5] != '5') return 23;
|
|
|
|
|
|
|
|
strcpy (xfile.buffer, "0123456789\n");
|
|
|
|
eputs (xfile.buffer);
|
|
|
|
memcpy (pxfile->buffer + 5, " ", 1);
|
|
|
|
eputs (xfile.buffer);
|
|
|
|
if (p[5] != ' ') return 24;
|
|
|
|
if (xfile.buffer[5] != ' ') return 25;
|
|
|
|
if (pxfile->buffer[5] != ' ') return 26;
|
|
|
|
|
|
|
|
strcpy (xfile.buffer, "0123456789\n");
|
|
|
|
eputs (xfile.buffer);
|
|
|
|
p[6] = ' ';
|
|
|
|
eputs (xfile.buffer);
|
|
|
|
if (p[6] != ' ') return 27;
|
|
|
|
if (xfile.buffer[6] != ' ') return 28;
|
|
|
|
if (pxfile->buffer[6] != ' ') return 29;
|
|
|
|
|
|
|
|
strcpy (xfile.buffer, "0123456789\n");
|
|
|
|
eputs (xfile.buffer);
|
|
|
|
xfile.buffer[7] = ' ';
|
|
|
|
eputs (xfile.buffer);
|
|
|
|
if (p[7] != ' ') return 30;
|
|
|
|
if (p[8] != '8') return 31;
|
2017-07-30 16:04:25 +00:00
|
|
|
|
2017-08-07 17:43:59 +00:00
|
|
|
strcpy (xfile.buffer, "0123456789\n");
|
|
|
|
eputs (xfile.buffer);
|
|
|
|
pxfile->buffer[8] = ' ';
|
|
|
|
eputs (xfile.buffer);
|
|
|
|
if (p[8] != ' ') return 32;
|
|
|
|
if (p[9] != '9') return 33;
|
|
|
|
|
2017-08-08 08:00:13 +00:00
|
|
|
short *ps;
|
|
|
|
ps = pfile->buffer;
|
|
|
|
p = pfile->buffer;
|
|
|
|
|
|
|
|
strcpy (file.buffer, "0123456789\n");
|
|
|
|
eputs (file.buffer);
|
|
|
|
memcpy (ps + 1, " ", 2);
|
|
|
|
eputs (file.buffer);
|
|
|
|
eputs (itoa (ps[1])); eputs ("\n");
|
|
|
|
eputs (itoa (((' ' << 8) + ' '))); eputs ("\n");
|
|
|
|
if (ps[1] != ((' ' << 8) + ' ')) return 40;
|
|
|
|
if (p[4] != '4') return 41;
|
|
|
|
|
|
|
|
strcpy (file.buffer, "0123456789\n");
|
|
|
|
eputs (file.buffer);
|
|
|
|
ps[2] = ((' ' << 8) + ' ');
|
|
|
|
eputs (file.buffer);
|
|
|
|
eputs (itoa (ps[2])); eputs ("\n");
|
|
|
|
eputs (itoa (((' ' << 8) + ' '))); eputs ("\n");
|
|
|
|
if (ps[2] != ((' ' << 8) + ' ')) return 42;
|
|
|
|
if (p[6] != '6') return 43;
|
|
|
|
|
2017-07-30 16:04:25 +00:00
|
|
|
return 0;
|
|
|
|
}
|