2017-08-06 16:49:19 +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-08-06 16:49:19 +00:00
|
|
|
*
|
2018-07-22 12:24:36 +00:00
|
|
|
* This file is part of GNU Mes.
|
2017-08-06 16:49:19 +00:00
|
|
|
*
|
2018-07-22 12:24:36 +00:00
|
|
|
* GNU Mes is free software; you can redistribute it and/or modify it
|
2017-08-06 16:49:19 +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-08-06 16:49:19 +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-08-06 16:49:19 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "30-test.i"
|
|
|
|
#include <string.h>
|
|
|
|
|
|
|
|
struct string {
|
|
|
|
char *str;
|
|
|
|
int len;
|
|
|
|
};
|
|
|
|
|
2017-09-10 14:59:53 +00:00
|
|
|
typedef struct biggie {
|
|
|
|
int a;
|
|
|
|
int b;
|
|
|
|
int c;
|
|
|
|
char *str;
|
|
|
|
int len;
|
|
|
|
} biggie;
|
|
|
|
|
|
|
|
struct other {
|
|
|
|
struct biggie big;
|
|
|
|
};
|
|
|
|
|
2017-08-06 16:49:19 +00:00
|
|
|
struct string g_t;
|
|
|
|
|
2017-09-10 14:59:53 +00:00
|
|
|
struct biggie tab[2];
|
|
|
|
|
2017-08-06 16:49:19 +00:00
|
|
|
int
|
|
|
|
test ()
|
|
|
|
{
|
|
|
|
struct string s = {"hallo"};
|
|
|
|
s.len = strlen (s.str);
|
2017-09-10 14:59:53 +00:00
|
|
|
eputs (s.str); eputs ("\n");
|
|
|
|
|
2017-08-06 16:49:19 +00:00
|
|
|
struct string t;
|
|
|
|
t = s;
|
|
|
|
|
2017-09-10 14:59:53 +00:00
|
|
|
eputs (t.str); eputs ("\n");
|
2017-08-06 16:49:19 +00:00
|
|
|
if (t.len != s.len) return 1;
|
|
|
|
if (strcmp (t.str, s.str)) return 2;
|
|
|
|
|
|
|
|
g_t = s;
|
2017-09-10 14:59:53 +00:00
|
|
|
eputs (g_t.str); eputs ("\n");
|
2017-08-06 16:49:19 +00:00
|
|
|
if (g_t.len != s.len) return 3;
|
|
|
|
if (strcmp (g_t.str, s.str)) return 4;
|
|
|
|
|
2017-09-10 14:59:53 +00:00
|
|
|
struct biggie b;
|
|
|
|
b.str = "hello";
|
|
|
|
b.len = strlen (b.str);
|
|
|
|
eputs (b.str); eputs ("\n");
|
|
|
|
|
|
|
|
struct biggie tb;
|
|
|
|
tb = b;
|
|
|
|
eputs (tb.str); eputs ("\n");
|
|
|
|
if (tb.len != b.len) return 5;
|
|
|
|
if (strcmp (tb.str, b.str)) return 6;
|
|
|
|
|
|
|
|
b.str = "bye";
|
|
|
|
b.len = strlen (b.str);
|
|
|
|
eputs (b.str); eputs ("\n");
|
|
|
|
//struct biggie *pb = &tb;
|
|
|
|
biggie *pb = &tb;
|
|
|
|
*pb = b;
|
|
|
|
eputs (tb.str); eputs ("\n");
|
|
|
|
if (tb.len != b.len) return 7;
|
|
|
|
if (strcmp (tb.str, b.str)) return 8;
|
|
|
|
|
|
|
|
tb.str = "there";
|
|
|
|
tb.len = strlen (tb.str);
|
|
|
|
|
|
|
|
b = *pb;
|
|
|
|
eputs (b.str); eputs ("\n");
|
|
|
|
if (b.len != tb.len) return 9;
|
|
|
|
if (strcmp (b.str, tb.str)) return 10;
|
|
|
|
|
|
|
|
char **x = &b.str;
|
|
|
|
char *p;
|
|
|
|
p = *x;
|
|
|
|
|
|
|
|
struct other o;
|
|
|
|
struct other* po = &o;
|
|
|
|
po->big = b;
|
|
|
|
eputs (o.big.str); eputs ("\n");
|
|
|
|
if (o.big.len != b.len) return 13;
|
|
|
|
if (strcmp (o.big.str, b.str)) return 14;
|
|
|
|
|
|
|
|
po->big = *pb;
|
|
|
|
eputs (o.big.str); eputs ("\n");
|
|
|
|
if (o.big.len != b.len) return 15;
|
|
|
|
if (strcmp (o.big.str, b.str)) return 16;
|
|
|
|
|
|
|
|
b.str = "* = *";
|
|
|
|
b.len = strlen (b.str);
|
|
|
|
eputs (b.str); eputs ("\n");
|
|
|
|
struct biggie *q = tab;
|
|
|
|
pb = &b;
|
|
|
|
*q++ = *pb;
|
|
|
|
eputs (tab[0].str); eputs ("\n");
|
|
|
|
if (tab[0].len != b.len) return 17;
|
|
|
|
if (strcmp (tab[0].str, b.str)) return 18;
|
|
|
|
|
|
|
|
tab[1] = tab[0];
|
|
|
|
eputs (tab[1].str); eputs ("\n");
|
|
|
|
if (tab[1].len != b.len) return 19;
|
|
|
|
if (strcmp (tab[1].str, b.str)) return 20;
|
|
|
|
|
|
|
|
tab[0].str = "burp";
|
|
|
|
tab[0].len = strlen (tab[1].str);
|
|
|
|
eputs (tab[0].str); eputs ("\n");
|
|
|
|
b = tab[0];
|
|
|
|
eputs (b.str); eputs ("\n");
|
|
|
|
if (b.len != tab[0].len) return 21;
|
|
|
|
if (strcmp (b.str, tab[0].str)) return 22;
|
|
|
|
|
|
|
|
tab[1] = b;
|
|
|
|
eputs (tab[1].str); eputs ("\n");
|
|
|
|
if (tab[1].len != b.len) return 23;
|
|
|
|
if (strcmp (tab[1].str, b.str)) return 24;
|
|
|
|
|
2017-08-06 16:49:19 +00:00
|
|
|
return 0;
|
|
|
|
}
|