?login_element?

Subversion Repositories NedoOS

Rev

Blame | Last modification | View Log | Download

  1. /*
  2. Permission to use, copy, modify, and/or distribute this software for any purpose
  3. with or without fee is hereby granted.
  4.  
  5. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  6. WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  7. AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
  8. INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
  9. OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  10. TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
  11. OF THIS SOFTWARE.
  12. */
  13.  
  14. #ifdef ADD_UNIT_TESTS
  15.  
  16. #include "../sjasm/sjdefs.h"
  17. #include "UnitTest++/UnitTest++.h"
  18.  
  19. TEST(Reader_isLabelCharacter) {
  20.         for (const char testch : "_.?!#@") {
  21.                 if (!testch) break;
  22.                 CHECK_EQUAL(1, islabchar(testch));
  23.         }
  24.         for (char testch = 'A'; testch <= 'Z'; ++testch) {
  25.                 CHECK_EQUAL(1, islabchar(testch));
  26.                 CHECK_EQUAL(1, islabchar(testch+0x20)); //lowercase
  27.         }
  28.         for (char testch = '0'; testch <= '9'; ++testch) {
  29.                 CHECK_EQUAL(1, islabchar(testch));
  30.         }
  31.         for (const char testch : "`~$%^&*()-=+\\|[]{}\"';:/,<>") {      // will test also zero value
  32.                 CHECK_EQUAL(0, islabchar(testch));
  33.         }
  34. }
  35.  
  36. TEST(Reader_isLabelStart) {
  37.         for (const char testch : "_") {
  38.                 if (!testch) break;
  39.                 CHECK_EQUAL(1, isLabelStart(&testch, false));
  40.         }
  41.         for (char testch = 'A'; testch <= 'Z'; ++testch) {
  42.                 CHECK_EQUAL(1, isLabelStart(&testch, false));
  43.         }
  44.         for (char testch = 'a'; testch <= 'z'; ++testch) {
  45.                 CHECK_EQUAL(1, isLabelStart(&testch, false));
  46.         }
  47.         for (char testch = '0'; testch <= '9'; ++testch) {
  48.                 CHECK_EQUAL(0, isLabelStart(&testch, false));
  49.         }
  50.         for (const char testch : ".?!#@`~$%^&*()-=+\\|[]{}\"';:/,<>") { // will test also zero value
  51.                 CHECK_EQUAL(0, isLabelStart(&testch, false));
  52.         }
  53.         char m1 = -1;
  54.         CHECK_EQUAL(0, isLabelStart(&m1, false));
  55.         // with modifiers ("." for local, "@" for global label) enabled:
  56.         CHECK_EQUAL(0, isLabelStart("", true));
  57.         CHECK_EQUAL(0, isLabelStart(".", true));
  58.         CHECK_EQUAL(0, isLabelStart("..", true));
  59.         CHECK_EQUAL(0, isLabelStart(".@", true));
  60.         CHECK_EQUAL(0, isLabelStart(".0", true));
  61.         CHECK_EQUAL(0, isLabelStart(".?", true));
  62.         CHECK_EQUAL(0, isLabelStart(".!", true));
  63.         CHECK_EQUAL(0, isLabelStart(".#", true));
  64.         CHECK_EQUAL(0, isLabelStart("@", true));
  65.         CHECK_EQUAL(0, isLabelStart("@.", true));
  66.         CHECK_EQUAL(0, isLabelStart("@@", true));
  67.         CHECK_EQUAL(0, isLabelStart("@0", true));
  68.         CHECK_EQUAL(0, isLabelStart("@?", true));
  69.         CHECK_EQUAL(0, isLabelStart("@!", true));
  70.         CHECK_EQUAL(0, isLabelStart("@#", true));
  71.         // valid starts of label
  72.         CHECK_EQUAL(1, isLabelStart("._", true));
  73.         CHECK_EQUAL(1, isLabelStart(".A", true));
  74.         CHECK_EQUAL(1, isLabelStart(".a", true));
  75.         CHECK_EQUAL(1, isLabelStart("@_", true));
  76.         CHECK_EQUAL(1, isLabelStart("@A", true));
  77.         CHECK_EQUAL(1, isLabelStart("@a", true));
  78. }
  79.  
  80. #endif
  81.