35-compare-char.c 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /* -*-comment-start: "//";comment-end:""-*-
  2. * GNU Mes --- Maxwell Equations of Software
  3. * Copyright © 2017,2018 Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
  4. *
  5. * This file is part of GNU Mes.
  6. *
  7. * GNU Mes is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 3 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * GNU Mes is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with GNU Mes. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include <mes/lib-mini.h>
  21. char g_arena[10];
  22. char *g_chars = g_arena;
  23. int
  24. main ()
  25. {
  26. int i = 0;
  27. char c = 'C';
  28. char *p = "mes";
  29. char *x = g_arena;
  30. char *y = g_chars;
  31. oputs ("\n");
  32. oputs ("t: p[0] != 'm'\n");
  33. if (p[0] != 'm')
  34. return p[0];
  35. oputs ("t: p[i] != 't'\n");
  36. if (p[i] != 'm')
  37. return p[i];
  38. oputs ("t: *g_chars != 'A'\n");
  39. g_arena[0] = 'A';
  40. if (*g_chars != 'A')
  41. return 1;
  42. oputs ("t: *x != 'A'\n");
  43. if (*x != 'A')
  44. return 1;
  45. oputs ("t: *y != 'A'\n");
  46. if (*y != 'A')
  47. return 1;
  48. oputs ("t: *x != 'Q'\n");
  49. g_chars[0] = 'Q';
  50. if (*x != 'Q')
  51. return 1;
  52. oputs ("t: *x++ != 'C'\n");
  53. *x++ = c;
  54. if (*g_chars != 'C')
  55. return 1;
  56. oputs ("t: *g_chars == 'B'\n");
  57. g_arena[0] = 'B';
  58. if (*g_chars == 'B')
  59. goto ok1;
  60. return 1;
  61. ok1:
  62. oputs ("t: *x == 'B'\n");
  63. x = g_arena;
  64. if (*x == 'B')
  65. goto ok2;
  66. return 1;
  67. ok2:
  68. oputs ("t: *y == 'B'\n");
  69. y = g_chars;
  70. if (*y == 'B')
  71. goto ok3;
  72. return 1;
  73. ok3:
  74. oputs ("t: *x == 'R'\n");
  75. g_chars[0] = 'R';
  76. if (*x == 'R')
  77. goto ok4;
  78. return 1;
  79. ok4:
  80. oputs ("t: *x++ == 'C'\n");
  81. *x++ = c;
  82. if (*g_chars == 'C')
  83. goto ok5;
  84. return 1;
  85. ok5:
  86. return 0;
  87. }