tcase13.pp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. { the last range should be converted to single case and give 'expected' value }
  2. {$H+}
  3. var
  4. my_str: string;
  5. my_str_wide: widestring;
  6. my_str_ansi: ansistring;
  7. my_str_uni: unicodestring;
  8. i: integer;
  9. begin
  10. my_str := 'cab';
  11. my_str_wide := 'cab';
  12. my_str_ansi := 'cab';
  13. my_str_uni := 'cab';
  14. i := -1;
  15. case my_str of
  16. 'a'..'b': i := 1;
  17. 'c'..'caa': i := 2;
  18. 'cab'..'cab': i := 3;
  19. else i := 0;
  20. end;
  21. if (i <> 3) then begin
  22. writeln('Error');
  23. Halt(1);
  24. end;
  25. case my_str_wide of
  26. 'a'..'b': i := 1;
  27. 'c'..'caa': i := 2;
  28. 'cab'..'cab': i := 3;
  29. else i := 0;
  30. end;
  31. if (i <> 3) then begin
  32. writeln('Error_wide ', i);
  33. Halt(1);
  34. end;
  35. case my_str_ansi of
  36. 'a'..'b': i := 1;
  37. 'c'..'caa': i := 2;
  38. 'cab'..'cab': i := 3;
  39. else i := 0;
  40. end;
  41. if (i <> 3) then begin
  42. writeln('Error_ansi');
  43. Halt(1);
  44. end;
  45. case my_str_uni of
  46. 'aa': i := 1;
  47. 'ca'..'caa': i := 2;
  48. 'cab': i := 3;
  49. else i := 0;
  50. end;
  51. if (i <> 3) then begin
  52. writeln('Error');
  53. Halt(1);
  54. end;
  55. end.