?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(Sanity) {                  // just to verify the UnitTest++ test runner works
  20.         CHECK_EQUAL(1, 1);
  21. }
  22.  
  23. TEST(Reader_GetNumericValue_IntBased_1) {
  24.         // for 100% coverage (this error state can't be currently reached through ASM file)
  25.         aint val = 0xBADF00D;
  26.         char p[1] = "";
  27.         char* lp = p;
  28.         CHECK_EQUAL(false, GetNumericValue_IntBased(lp, p, val, 10));
  29.         CHECK_EQUAL(0, val);
  30. }
  31.  
  32. TEST(Reader_GetNumericValue_IntBased_2) {
  33.         // for 100% coverage (this error state can't be currently reached through ASM file)
  34.         aint val = 0xBADF00D;
  35.         char p[] = "42";
  36.         char* lp = p;
  37.         CHECK_EQUAL(false, GetNumericValue_IntBased(lp, p+3, val, 10)); // hit zero-terminator as digit
  38.         CHECK_EQUAL(42, val);
  39. }
  40.  
  41. TEST(Reader_GetNumericValue_IntBased_3) {
  42.         // for 100% coverage (this error state can't be currently reached through ASM file)
  43.         aint val = 0xBADF00D;
  44.         char p[] = "41+";
  45.         char* lp = p;
  46.         CHECK_EQUAL(false, GetNumericValue_IntBased(lp, p+3, val, 10)); // hit non alpha-num char as digit
  47.         CHECK_EQUAL(41, val);
  48. }
  49.  
  50. #endif
  51.