trecsize.pas 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. {
  2. Copyright (c) 2021 Karoly Balogh
  3. Test system record/structure sizes on a Sinclair QL
  4. A test program for Free Pascal's Sinclair QL support
  5. This test program is in the Public Domain under the terms of
  6. Unlicense: http://unlicense.org/
  7. **********************************************************************}
  8. program trecsize;
  9. uses
  10. qdos;
  11. type
  12. size_test = record
  13. name: string[16];
  14. size: longint;
  15. size_of: longint;
  16. end;
  17. const
  18. record_sizes: array of size_test = (
  19. { extend with more, as needed }
  20. ( name: 'TQDOS_QUEUE'; size: QDOSQUEUE_SIZE; size_of: sizeof(Tqdos_queue) ),
  21. ( name: 'TCHAN_DEFB'; size: CHAN_DEFBSIZE; size_of: sizeof(Tchan_defb) ),
  22. ( name: 'TSER_CDEFB'; size: SER_CDEFBSIZE; size_of: sizeof(Tser_cdefb) ),
  23. ( name: 'TNET_CDEFB'; size: NET_CDEFBSIZE; size_of: sizeof(Tnet_cdefb) ),
  24. ( name: 'TSCRN_INFO'; size: SCRN_INFOSIZE; size_of: sizeof(Tscrn_info) ),
  25. ( name: 'TSCR_CDEFB'; size: SCR_CDEFBSIZE; size_of: sizeof(Tscr_cdefb) ),
  26. ( name: 'TCON_CDEFB'; size: CON_CDEFBSIZE; size_of: sizeof(Tcon_cdefb) ),
  27. ( name: 'TFS_CDEFB'; size: FS_CDEFBSIZE; size_of: sizeof(Tfs_cdefb) )
  28. );
  29. function test_record_sizes: boolean;
  30. var
  31. i: longint;
  32. begin
  33. test_record_sizes:=false;
  34. for i:=low(record_sizes) to high(record_sizes) do
  35. begin
  36. with record_sizes[i] do
  37. begin
  38. writeln(name,' is ',size_of,' bytes, expected: ',size);
  39. if size_of <> size then
  40. exit;
  41. end;
  42. end;
  43. test_record_sizes:=true;
  44. end;
  45. begin
  46. if test_record_sizes then
  47. writeln('All OK!')
  48. else
  49. writeln('Error! Wrong size!');
  50. end.