test_ret_obj.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* This file is part of asmc, a bootstrapping OS with minimal seed
  2. Copyright (C) 2018-2019 Giovanni Mascellani <gio@debian.org>
  3. https://gitlab.com/giomasce/asmc
  4. This program is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <https://www.gnu.org/licenses/>. */
  14. struct len4 {
  15. int x;
  16. };
  17. struct len8 {
  18. int x, y;
  19. };
  20. struct len16 {
  21. int x, y;
  22. long z;
  23. };
  24. struct len4 ret_len4(int x) {
  25. struct len4 r;
  26. r.x = x;
  27. return r;
  28. }
  29. struct len8 ret_len8(int x, int y) {
  30. struct len8 r;
  31. r.x = x;
  32. r.y = y;
  33. return r;
  34. }
  35. struct len16 ret_len16(int x, int y, long z) {
  36. struct len16 r;
  37. r.x = x;
  38. r.y = y;
  39. r.z = z;
  40. return r;
  41. }
  42. int test_ret_obj() {
  43. struct len4 r4 = ret_len4(10);
  44. if (r4.x != 10) return 0;
  45. struct len8 r8 = ret_len8(20, 30);
  46. if (r8.x != 20) return 0;
  47. if (r8.y != 30) return 0;
  48. struct len16 r16 = ret_len16(100, 200, 1000);
  49. if (r16.x != 100) return 0;
  50. if (r16.y != 200) return 0;
  51. if (r16.z != 1000) return 0;
  52. return 1;
  53. }